Skip to main content

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


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)

Uploaded Source

Built Distribution

pyutil_cfg-0.0.6-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page