buba
Multi-environment yaml settings following 12 Factor App methodology.
Inspired by gem rubyconfig.
Features:
- simple YAML config files
- config files support inheritance and multiple environments
- access config information via convenient object member notation
- support for multi-level settings (Settings.group.subgroup.setting)
Install:
pip install buba
Usage:
Create config directories and files in project root directory:
.
+-- ...
+-- _config
| +-- environments
| +-- development.db.yaml
| +-- production.db.yaml
| +-- production.common.yaml
| +-- db.yaml
| +-- common.yaml
+-- ...
+-- ...
+-- main.py
-
files loaded by app env (default - development).
- First loaded config/*.yaml files
- Then loaded config/environment/{APP_ENV}*.yaml files (overrides values, there is option to override/merge list values)
- Then check all loaded keys for overrides in environment variables (db.host will be mapped to PREFIX__DB__HOST)
-
app env defined by env ver APP_ENV (there is option to override)
-
app env config prefix default value is 'APP_CONFIG' (there is option to override)
-
app env config splitter default value is '__' (there is option to override)
from os import environ
from buba import Buba
if __name__ == '__main__':
config = Buba(env_name='APP_ENV', prefix='CONFIG', splitter='::')
assert config.app_name == 'my_app'
assert config.db.host == 'localhost_default'
assert config.db.user == 'user_development'
assert config.db.password == 'password_development'
environ['APP_ENV'] = 'production'
config.load()
assert config.app_name == 'my_app'
assert config.db.host == 'localhost_default'
assert config.db.user == 'user_production'
assert config.db.password == 'password_production'
environ['APP_ENV'] = 'production'
environ['CONFIG::DB::HOST'] = 'production_host'
environ['CONFIG::APP_NAME'] = 'production_app_name'
config.load()
assert config.app_name == 'production_app_name'
assert config.db.host == 'production_host'
assert config.db.user == 'user_production'
assert config.db.password == 'password_production'
Metadata
Release files for buba 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| buba-0.0.1.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| buba-0.0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 8.5 kB
Release files / buba-0.0.1.tar.gz
| Download URL | buba-0.0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df07489d4b6b1ea3746879c7a53dc56c070e1b19c081de79dcc6d96988b6f749
|
|
BLAKE2b-256 checksum How to use checksums |
992d925831cae8fc4a46f672e8ec025233c0cb18055aeb3de5f6bb867fc8601b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.12
|
Release files / buba-0.0.1-py2.py3-none-any.whl
| Download URL | buba-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
688a8727853cba5da2acafbfb43eaebbf433aa9051229f2fba210f95c6f179d9
|
|
BLAKE2b-256 checksum How to use checksums |
5546eb82cd17fd44946f2e3ccf619d099d12a4d6e9dd6c3cafc2e0911144dfff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.12
|