THIS PACKAGE PERMANENTLY MOVED TO https://github.com/spacetab-io/configuration-python
Configuration module for microservices written on Python. Specially created for follow up corporate standards of application configuration.
pip3 install config_pkg
By default path to configuration directory and application stage
loading from /configuration
with defaults
stage.
- Simple
from config_pkg import PKG
pkg = PKG()
pkg.load()
all_config = pkg.get_all()
foo_bar = pkg.get('foo.bar')
- If u would like override default values, you can pass 2 arguments to class constructor or set up use setters.
from config_pkg import PKG
pkg = PKG('/configuration', 'test')
pkg.load()
foo_bar = pkg.get('key') # full example on the top
- If the operating system has an env variables
CONFIG_PATH
andSTAGE
, then values for the package will be taken from there.
export CONFIG_PATH=/configuration
export STAGE=test
from config_pkg import PKG
pkg = PKG()
pkg.load() # loaded files from /configuration for prod stage.
foo_bar = pkg.get('key') # full example on the top
- If u want to see logs and see how load process working, pass you application logger to the following method:
from config_pkg import PKG
pkg = PKG(logger=logger) # loggining.Logger compatible logger
pkg.load()
foo_bar = pkg.get('key') # full example on the top
That all.
- Python 3.x
- pip for install package
MIT