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
If 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
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.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 668a76dd51f84eb962f2a66e41d0074d691fec2d7a0c8d8acca216af5df8ece1 |
|
MD5 | e8d12b35b5dc5f15c21358c966ee55a5 |
|
BLAKE2b-256 | 2f54124f3fae43f2f14bc6ebe7a697e067418decc9cf41ecd431a6ef14baaf5b |
Hashes for python_configuration_wrapper-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80885c6e246bec169ecc6c2f0150729a724d432a7a286404891563d470a2a230 |
|
MD5 | cea3b8d76f552b4683331980addcdd19 |
|
BLAKE2b-256 | 9cbe5781621d063820f63cac4a5162b62237da3a9982d04bf25bd8536ca6e4ed |