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-configor-Cparameter.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_PREFIXenvironment variable. Level separator is__(double underscore).Example:
CONFIG_PREFIX=TEST TEST__database__user=root python app.py -
Config directories given by
--config-pathor-Pparameter. 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-fileor-Fparameter. 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.yamlIf no config file is given, the lib will look for config.{yaml|json|ini|toml|python} in the working directory.
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
Metadata
Release files for python-configuration-wrapper 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python-configuration-wrapper-1.2.0.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_configuration_wrapper-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.6 kB
Release files / python-configuration-wrapper-1.2.0.tar.gz
| Download URL | python-configuration-wrapper-1.2.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
668a76dd51f84eb962f2a66e41d0074d691fec2d7a0c8d8acca216af5df8ece1
|
|
BLAKE2b-256 checksum How to use checksums |
2f54124f3fae43f2f14bc6ebe7a697e067418decc9cf41ecd431a6ef14baaf5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.7.1 requests/2.26.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.1
|
Release files / python_configuration_wrapper-1.2.0-py3-none-any.whl
| Download URL | python_configuration_wrapper-1.2.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80885c6e246bec169ecc6c2f0150729a724d432a7a286404891563d470a2a230
|
|
BLAKE2b-256 checksum How to use checksums |
9cbe5781621d063820f63cac4a5162b62237da3a9982d04bf25bd8536ca6e4ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.7.1 requests/2.26.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.1
|