pyconfman2
pyconfman2 is designed to handle schema configurations by loading properties from a dictionary or a YAML configuration file. It provides methods for adding, getting, and removing properties from the schema.
Installation
python -m pip install pyconfman2
Usage
Basic
In it's most basic form, a Schema can be created which will load a local "config.yaml" or "config.yml" file present.
>>> from pyconfman2 import Schema
>>> config = Schema.ConfigSchema()
>>> print(config)
{}
Provide a default config
>>> from pyconfman2 import Schema
>>> config=Schema.ConfigSchema({"foo": "bar"})
>>> print(config)
{'foo': 'bar'}
Specify the default config file to load
>>> from pyconfman2 import Schema
>>> config=Schema.ConfigSchema(default_config="default_config.yaml")
>>> print(config)
{'foo': 'bar', 'zoo': {'jar': ['car', 'far']}}
Specify the config file to load
>>> from pyconfman2 import Schema
>>> config=Schema.ConfigSchema(default_config="default_config.yaml", filepath="another_config.yaml")
>>> print(config)
{'foo': 'overwritten_by_another_config', 'zoo': {'jar': ['car', 'far']}}
Schema Loading breakdown
- Load the hard-coded defaults
- Load (and override) using the "default config" file if present
- Load (and override) using the config file if present