A small utility to read keys from TOML files.
Project description
read-toml-py
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file outcome-read-toml-2.1.0.tar.gz
.
File metadata
- Download URL: outcome-read-toml-2.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fa2b16bab1a7a0c8c65d2b9295d578562e4f89ea51a15acb7bbb220b9139c44 |
|
MD5 | 2663efde7f6b839df445b9bf8283e9da |
|
BLAKE2b-256 | 44cd6c2b727d7770912b43ffe3c7181e256c12d1551a2e72c457d2bfaf180c3b |
File details
Details for the file outcome_read_toml-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: outcome_read_toml-2.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c676c98f606fe9819937f56561aa3a348c4a10bde6352c44b7670610a080155 |
|
MD5 | 535975039cd5824792d06ae559b569d1 |
|
BLAKE2b-256 | 3d166e5346ef855527a76e3df504cbb59c31c58f9fa0a7d03a0dabd30ce6b797 |