Another Python configuration tool
Project description
Cool Config
Simple way to use configuration files with Python configuration model.
Usage
pip install cool_config
Simple usage example:
from unittest.mock import patch
from cool_config import *
class Config(AbstractConfig):
"""
Configuration model inherits from AbstractConfig, and all configuration sections from Section
"""
class main(Section):
a = Integer
b = Integer
config = Config() # create global configuration object and import it
# more examples available in test/main.py
if __name__ == '__main__':
config_data = {
'main': {
'a': 5
},
'b': 42
}
# config.load('config.yml') # initialize configuration with config.yml in
# you application entry point (before `config` usage)
config.update_from_dict(config_data)
print(config) # {'b': 42, 'main': {'a': 5}}
print(config.main.a) # 5
print(config.b) # 42
config_data_b = {
'main': {
'a': 55
},
}
config.update_from_dict(config_data_b)
print(config) # {'b': 42, 'main': {'a': 55}}
"""
ENVIRONMENT:
TEST__main__a = '6'
TEST__b = '22'
THE_ANSWER_KEY = '42'
"""
config.update_from_env('TEST', delimiter='__')
print(config) # {'b': '22', 'main': {'a': '6'}}
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
cool_config-0.2.2.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for cool_config-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d35842888a4ba5dc524b4904e789fc10a05c1ce370ad538a348beca8ebb7c27 |
|
MD5 | 951251c09c36844af652a6c662b84db8 |
|
BLAKE2b-256 | 6f0fad5ced3d041b6eabd30f862a03226ab6dd763043ac76247bc360a9180777 |