Skip to main content

A small utility to read keys from TOML files.

Project description

read-toml-py

ci-badge version-badge

A small utility to read keys from TOML files.

Usage

Installation

poetry add outcome-read-toml

Usage

The utility reads the value specified by the key from the provided TOML file, and prints it to stdout.

The path parameter should be a '.' separated sequences of keys that correspond to a path in the TOML structure.

Example TOML file:

title = "My TOML file"

[info]
version = "1.0.1"

[tools.poetry]
version = "1.1.2"
files = ['a.py', 'b.py']

Read standard keys:

read-toml --path my_file.toml --key title 
# "My TOML file"

read-toml --path my_file.toml --key info.version
# "1.0.1"

Read arrays:

read-toml --path my_file.toml --key tools.poetry.files
# "a.py b.py"

read-toml --path my_file.toml[0] --key tools.poetry.files
# "a.py"

You can't read non-leaf keys:

read_toml.py --path my_file.toml --key tools
# KeyError

You can check if a key exists:

read-toml --path my_file.toml --key title --check-only 
# 1

read-toml --path my_file.toml --key unknown_key --check-only
# 0

Development

Remember to run ./pre-commit.sh when you clone the repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outcome-read-toml-2.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

outcome_read_toml-2.0.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file outcome-read-toml-2.0.4.tar.gz.

File metadata

  • Download URL: outcome-read-toml-2.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.6 Linux/5.4.0-1031-azure

File hashes

Hashes for outcome-read-toml-2.0.4.tar.gz
Algorithm Hash digest
SHA256 f8c2e150d4d1fecddb3d56c7cc5ddb83033803729f5b3164950254f52410ce25
MD5 fc294f54b3b46e39b81dd80b99d83a95
BLAKE2b-256 c49cb89a7138fbc77798988354b3d76fe6e31f1bfa210c25dbea29126972b130

See more details on using hashes here.

File details

Details for the file outcome_read_toml-2.0.4-py3-none-any.whl.

File metadata

  • Download URL: outcome_read_toml-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.6 Linux/5.4.0-1031-azure

File hashes

Hashes for outcome_read_toml-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4dafe735905ea121220a6f86bb6dd1c2a52acb8df2946f42d09d2bb9ec7c9f91
MD5 9a53b2638f8e8c44981190534f3df928
BLAKE2b-256 6f7d0f740aa049d8cf9dd3f3b1f12ad83aa6d5432bd279ed671fc52fc117405e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page