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.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 723a142c4694300fd4fb742bb245086a77c5b1de79a9f1bfed0877b89ad3f050 |
|
MD5 | c4267c1dbb98095f332c26c0c601d233 |
|
BLAKE2b-256 | 783baed5fcb27acbf6a15716e07ed2c193aa48fb7959f5fbc372ffaf57d2dd99 |
Hashes for python_configuration_wrapper-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d68458803d7a83ad61bea3b00cc3c784ec261374e45498242a69293cb020417e |
|
MD5 | 6d72d6fd748444aee6cf89855947a9e1 |
|
BLAKE2b-256 | 4cd2108c10af3dbaa067a0b32d2da31034785dc57a6b12efd2eb767bd630bae3 |