Overview
vartoml allows using variables in TOML config files. It uses the toml package.
Acknowledgent
The idea how to tackle the problem of variable interpolation was taken
from the envtoml package which is at https://github.com/mrshu/envtoml .
Variable names in TOML file
Variables are specified this way: ${section[:section]:variable}, i.e. sections can be nested.
Example usage
from vartoml import VarToml
TOML ="""
[default]
basedir = "/myproject"
bindir = "${default:basedir}/bin"
datadir = "${default:basedir}/data"
[other_dirs-sub]
logdir = "${default:datadir}/logs"
"""
toml = VarToml()
toml.loads(TOML)
assert toml.get('other_dirs-sub', 'logdir') == '/myproject/data/logs'
API
VarToml.load(f, _dict=dict)
same like what the toml package offers
VarToml.loads(s, _dict=dict)
same like what the toml package offers
VarToml.get(v,... )
returns a specific value from the toml dictionary
Example:
```python
toml = VarToml()
toml.loads('some.toml')
val = toml.get('default', 'id' )
```
VarToml.toml()
returns the dictionary of the parsed toml data
Release files for vartoml 0.9.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vartoml-0.9.7.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vartoml-0.9.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / vartoml-0.9.7.tar.gz
| Download URL | vartoml-0.9.7.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92c329d4120e7f788fba35bd223652c0dcc3d1795019e0eda6b33b28eb3afd9b
|
|
BLAKE2b-256 checksum How to use checksums |
a0729affde731095a9bb8ae308d72d0e3b698c22629bdc5e89c26f8179de0c03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.5
|
Release files / vartoml-0.9.7-py3-none-any.whl
| Download URL | vartoml-0.9.7-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab16d664b2c6de7fdccb276099a980e562676707511ba631a3ad794e7c233432
|
|
BLAKE2b-256 checksum How to use checksums |
a3b974a8d38461ce417f15af35eafb3d5db326cbbf8a2cca1a9e66c0a383a9ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.5
|