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.6.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file configjy-0.1.0.6.tar.gz
.
File metadata
- Download URL: configjy-0.1.0.6.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 736082f8d3cc4c7285b02ad6b4c838ec0b590e08aa7a566edb1e5dd5836bfc3d |
|
MD5 | 5ef641003e1cb1ba816e3966225db6dc |
|
BLAKE2b-256 | ed42888517a8fc5ec0fcd6f6cf9bed0edd810e8631047f9e52cc19e4779c6086 |
File details
Details for the file configjy-0.1.0.6-py3-none-any.whl
.
File metadata
- Download URL: configjy-0.1.0.6-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab520dbc58b917e7632301edd30f4ae912e10d91f4c03d9868f07f94071173d |
|
MD5 | 38d2d9d652d908df3bbb0852b467be39 |
|
BLAKE2b-256 | 769d24bc89cfc4e1de73993f34506d119dcd06d50b29d9085051ba203725fe36 |