small tool for project config management
Project description
Simple project config for Python.
You can read configuration from environ or local file with it.
Install
$: pip install p_config
Usuage
Suppose there are some config files.
# filename: default.yml
server:
port: 80
hostname: localhost
# filename: override.yml
server:
port: 443
hostname: localhost
backends:
- 127.0.0.1:80
You can read configuration via this way
$: env SERVER.PORT=8080 ipython
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.\
In [1]: from p_config import Config
In [2]: config = Config('default.yml')
In [3]: config['SERVER.PORT']
Out[3]: 80
In [4]: config['SERVER.HOSTNAME']
Out[4]: 'localhost'
In [5]: config.load('override.yml') # update configuration via local file
In [6]: config['SERVER.PORT']
Out[6]: 443
In [7]: config['SERVER.BACKENDS']
Out[7]: ['127.0.0.1:8080']
In [8]: config.load_env() # update configuration via environ
In [9]: config['SERVER.PORT']
Out[9]: '8080'
In [10]: config.get('SERVER.PORT')
Out[10]: '8080'
In [11]: config.get('NONE_EXIST')
Out[11]: None
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
p_config-1.3.3.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file p_config-1.3.3.tar.gz
.
File metadata
- Download URL: p_config-1.3.3.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9df30b355340c8f354b3f52147a19d9d6fca8555856bacf0467cf07d8c7d04f6 |
|
MD5 | ab886a3c441822f474cff2c8596d8627 |
|
BLAKE2b-256 | 93136a30c3812dd66dd54e03e0341ff6cce8d9c1050cfb7aab04d9a811c94edc |
File details
Details for the file p_config-1.3.3-py3-none-any.whl
.
File metadata
- Download URL: p_config-1.3.3-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad41e1e7f849d96a6fa72bb0bfadcffd1e65232213305483502c4b70a81c18b2 |
|
MD5 | 4ea4b61dde1afe494568007e1ca1224d |
|
BLAKE2b-256 | fbcc2661a35a3ed45d3bd19e9da1069a41a7d7b08ca38921ed2b5269e2679a30 |