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
If you are using this lib inside Github Actions, you can format the output accordingly:
read-toml --path my_file.toml --key title --github-actions
# ::set-output name=title::"My TOML file"
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
Close
Hashes for outcome_read_toml-1.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 169952cd2b097b5842a180d3c07cc42e3b455ddae8c0c0e247366a8c0d7e11b7 |
|
MD5 | ba942fd9733a176ccc0390691ef4de81 |
|
BLAKE2b-256 | c0cbe724a4d885ab78b7728c2b6804da70dbc83f44c2e6d0acb5f6a11c88ed2b |