Skip to main content

Small config manager for parsing configs from different sources

Project description

config_manager

Configuration manger

Usage

Create class with config variables and inherit it from config_manager.config.Config. You can define variables and their types or even define values. Then we can parse variables from different sources. For example, this is example_parser.py:

from config_manager import config


class TestConfig(config.Config):
    name: str
    age: int
    is_useful: bool = False


my_config = TestConfig()
config.parse_env(my_config, prefix="test_config_")
config.parse_json(my_config, json_path="test_config.json")
config.parse_arguments(my_config, "TestConfig parser")

print(my_config)

If we run it:

test_config_age=33 python example_parser.py --name hello

It will output something like and all the primitive types will be parsed correctly:

age = 33
is_useful = True
name = hello

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

config_manager_evjeny-0.1.0.tar.gz (2.3 kB view hashes)

Uploaded Source

Built Distribution

config_manager_evjeny-0.1.0-py3-none-any.whl (2.6 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