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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f3e3a2ab1706444aad4aa0e56d8c857c5813714e52980bec8013a5e7ee000ef |
|
MD5 | 05014d83e28b146f27b6a0f645a3a3df |
|
BLAKE2b-256 | 3b392aec7fbf707d9702bb9a9ac5e0087d89e2fa902a34ce28806efbb71a5d1b |
Hashes for python_configuration_wrapper-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 900021b306a018511b367dc5c9539649aa634e75eb0efbec12dfa2757fc3fedf |
|
MD5 | 70c02b099b97b1639fad1a2852ac5468 |
|
BLAKE2b-256 | 927d07131ee897e094d7adf9562fd7231003d013ad27c1f6afd07629bda60186 |