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
File details
Details for the file python-configuration-wrapper-1.2.0.tar.gz
.
File metadata
- Download URL: python-configuration-wrapper-1.2.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
668a76dd51f84eb962f2a66e41d0074d691fec2d7a0c8d8acca216af5df8ece1
|
|
MD5 |
e8d12b35b5dc5f15c21358c966ee55a5
|
|
BLAKE2b-256 |
2f54124f3fae43f2f14bc6ebe7a697e067418decc9cf41ecd431a6ef14baaf5b
|
File details
Details for the file python_configuration_wrapper-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: python_configuration_wrapper-1.2.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
80885c6e246bec169ecc6c2f0150729a724d432a7a286404891563d470a2a230
|
|
MD5 |
cea3b8d76f552b4683331980addcdd19
|
|
BLAKE2b-256 |
9cbe5781621d063820f63cac4a5162b62237da3a9982d04bf25bd8536ca6e4ed
|