Plugin-Based configuration manager
Project description
Configerus
Dynamic and abstract configuration management
An extendable plugin based configuration system, which allows abstract config primitives to be loaded from various prioritized sources. Config from higher priority source plugins takes precedence over lower priority, with some simple deep merging.
Configerus makes config easy by:
- having a simple construction method
- allowing config to be pulled from a variatey of sources, such as json/yml in file paths, or custom dicts
- using priorities, configerus allows config override, where some sources can override others.
- deep configuration retrieval is easy using "dot" (one.two.three) notation to search in config trees
Configerus offers a few tricks for complex use-cases
- you can apply simple validation (such as jsonschema) on retrieved config
- you can use a templating syntax to embed config from one source into another at the time of retrieval
- you can use a templating syntax to direct configeraus to replace a string file path with the contents of that file. Some files will be unmarshalled for the replacement.
Configerus makes advanced config management possible by:
- allowing you to define your own sources, formatters and validators and inject them at run time
- allowing you to extend using setuptools entrypoints for advanced functionality bootstrapping.
Usage
Configerus has a bit of steep learning curve in its approach and construction but it easy to use if it is set up correctly.
A cheap and dirty example:
If you have a folder ./config
that has to config files in it:
- settings.yaml
- values.json
import configerus
from configerus.contrib.dict import PLUGIN_ID_SOURCE_DICT
from configerus.contrib.files import PLUGIN_ID_SOURCE_PATH
config = configerus.new_config()
# tell configerus to read files from a path
config.add_source(PLUGIN_ID_SOURCE_PATH).set_path('./config')
# add a dynamic dict to configerus, with a 90/100 priority
config.add_source(PLUGIN_ID_SOURCE_DICT, priority=90).set_data({
'values': {
'one': 'overriden from dict'
}
})
# load all of the settings
settings = config.load('settings')
user_id = settings.get('user.id') # expects that settings had {user: {id: 'some value'}}
# load some overriding values
values = config.load('values') # loads the value file, but overrides from the dict
assert values.get('one') == 'overriden from dict'
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
Built Distribution
File details
Details for the file configerus-3.0.1.tar.gz
.
File metadata
- Download URL: configerus-3.0.1.tar.gz
- Upload date:
- Size: 33.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25e074179e847099222d82128d398e6735f602fa8184938a0c98d5083e7fed92 |
|
MD5 | a77f981db3efeab8c64590f899306516 |
|
BLAKE2b-256 | feb1314eda2ebfd59a4a8c561277e2bf4ba684cffca832ef48073ddbcc82012a |
File details
Details for the file configerus-3.0.1-py3-none-any.whl
.
File metadata
- Download URL: configerus-3.0.1-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35b8f553f78b388ed01edaf9a5dbacc669ac7f105670d986bbab914348704986 |
|
MD5 | c5fe257a1f00c4d8d5022507f1c28b57 |
|
BLAKE2b-256 | 638c146281c957bd8afbd4c46b502fd7ab00869bd9056be411f9f60b382bc095 |