Loads a json or yaml config file
Project description
configjy
Loads variables from a .json, .yaml or .yml file
Getting started
You can get configjy
from PyPI,
which means it's easily installable with pip
:
python -m pip install configjy
Example usage
from configjy import ConfigFile
# given this file:
"""
{
"key1": 10,
"key2": {
"key3": 20
},
"key4": "{{key1}}"
}
"""
fvar = ConfigFile(config_file_path)
key1 = fvar.get('key1')
print(key1) # 10
key2 = fvar.get('key2')
print(key2) # {"key3": 20}
key3 = fvar.get('key2.key3')
print(key3) # 20
key4 = fvar.get('key4')
print(key4) # str(key1) = "10"
key5 = fvar.get('key5', default=1, print_when_not_exists=False)
print(key5) # 1
try:
key6 = fvar.get('key6', raise_when_not_exists=True) # raises key error
except KeyError:
pass
key6 = fvar.get('key6') # print a warning abou non existent key
print(key6) # None
Changelog
Refer to the CHANGELOG.md file.
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
configjy-0.1.0.5.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for configjy-0.1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83a2341f5275af1226de40d5334162f8439e4f51c981ebb6ebf90e6d4d54756b |
|
MD5 | 5a733c9fc39172a604d6f5d9f46e42d7 |
|
BLAKE2b-256 | a2dda4db3245330f431824cd87b73a1f4ebc8f6aee12ac1394c910c834e47390 |