python util for cfg (configurations)
Project description
pyutil_cfg
python utils for cfg
This package helps parse json-like configurations in .ini.
Usage
import pyutil_cfg as cfg
logger, config = cfg.init(name, ini_filename)
Example
Assume that you have the following development.ini
:
[demo:main]
VAR_INT = 1
VAR_BOOL = true
VAR_DICT = {"A": 1, "B": "a"}
VAR_LIST = [
{"A": 2, "B": "b"},
{"A": 3, "B": "c"},
{"A": 4, "B": "d"}]
VAR_SET_set = ["a", "b", "c", "a"]
Then with the following code:
import pyutil_cfg as cfg
logger, config = cfg.init('demo', 'development.ini')
logger
is a logger with name = 'demo'
config
ia as follow:
config = {
"VAR_INT": 1,
"VAR_BOOL": true,
"VAR_DICT": {"A": 1, "B": "a"},
"VAR_LIST": [
{"A": 2, "B": "b"},
{"A": 3, "B": "c"},
{"A": 4, "B": "d"}
],
"VAR_SET_set": set(["a", "b", "c"])
}
Advanced Usage
Separated Log ini filename
import pyutil_cfg as cfg
logger, config = cfg.init(name, ini_filename, log_ini_filename=log_ini_filename)
Additional customized config parameters (specified as dict)
import pyutil_cfg as cfg
params = {}
logger, config = cfg.init(name, ini_filename, params=params)
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
pyutil-cfg-0.0.6.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for pyutil_cfg-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abd13662c613370c2357b142820f5abed06b9ec4af94465b04562cec7afa5df0 |
|
MD5 | 865e4b2f2aaba04793e992f824e1afcd |
|
BLAKE2b-256 | f6732519be2789f5936ac20930d3bda79902e9c105704b893bace3437580b619 |