A wrapper of python-configuration
Project description
Python Configuration Wrapper
This lib is basically a wrapper of the python-configuration.
It aims at making configuration easy !
Features
Read multi-level configuration values from multiple sources (precedency ordered):
-
Command line arguments given by
--additional-config
or-C
parameter.Example:
python app.py -C "database.dialect=postgresql" --additional-config "database.host=postgres.mydomain.org" -C "database.user=admin"
-
Environment variables starting with prefix set in the
CONFIG_PREFIX
environment variable. Level separator is__
(double underscore).Example:
CONFIG_PREFIX=TEST TEST__database__user=root python app.py
-
Config directories given by
--config-path
or-P
parameter. The value of this parameter must be a directory path in which the sub-directories are multi-level keys, and plain-text files content are values. It's very practical when using secrets in containers.Example:
mkdir /var/run/secrets/database -p echo -n 123456 > /var/run/secrets/database/password python app.py --config-path /var/run/secrets
-
Config files given by
--config-file
or-F
parameter. File formats must be among those handled by python-configuration:- json
- ini
- yaml
- toml
- python
Example:
python app.py -F config.json --config-file config.yaml
Installation
pip install python-configuration-wrapper
Usage
# import the config object from the module
# you can do this in every python file you want
from python_configuration_wrapper import config
# get some value from a multi-level key
myvalue = config.myfirstlevel.mysecondlevel.mykey
Example
See test
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
Hashes for python-configuration-wrapper-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c5ee178957ea3a014ddf4b0a4cfc3af0cb31dc9bd406b274b33fb00fb9a8fb1 |
|
MD5 | c140e099da44e3dae6126cbf23a79ee4 |
|
BLAKE2b-256 | c4eb4fcd6ce7217f4afda837bd97e4d504359618401e52a64027cda4e0f4ef05 |
Hashes for python_configuration_wrapper-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e436c8ba950a4d20834c0f251e59823054dc7cec2e466217dc53d00c468a9b90 |
|
MD5 | da08144954d98413dea2a277850988ee |
|
BLAKE2b-256 | ebd1d3a1b5eae5a2316e59e1fd04e9e5395b48469f54f4c66d5124cbb8e0faf9 |