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.7.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for pyutil_cfg-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 254dc3665d9a2482a0c2315432e9c7045b04116fa5587372df72c01dda193e09 |
|
MD5 | e55f07bb80899304470be9c3d731fcc6 |
|
BLAKE2b-256 | 56fb8dfb3a73c84f06eb47add892abbe7b9c79c524bb6ba57880296c4997e884 |