A simple yaml config manager.
Project description
haip.config
haip.config is a simple configuration handling module for Python 3.6+. You define your project configuration in yaml-files and haip.config handles the rest for you.
Features:
- directory based: place your config in multiple files in your configuration directory. haip.config will merge them automatically.
- environment overlay: place your environment specific configuration in a subdirectory. haip.config will overwrite the base configuration.
- attribute-style: access your config like a.b.c instead of a['b']['c']
Getting Started
Installing
pip install haip.config
or from source:
git clone https://github.com/haipdev/config.git
Example:
config-files:
/path-to-my-config-dir/databases.yml
databases:
test:
username: testuser
host: 127.0.0.2
/path-to-my-config-dir/dev/databases.yml
databases:
test:
password: testpassword
python implementation
import haip.config as config
config.load('/path-to-my-config-dir', 'dev')
cfg = config.get('databases', 'test', username=config.MANDATORY, password=config.MANDATORY, host='127.0.0.1', port=3306)
username = cfg.databases.test.username # <-- 'testuser' from base-config
password = cfg.databases.test.password # <-- 'testpassword' from dev subdir
host = cfg.databases.test.host # <-- '127.0.0.2' from base-config (default not used)
port = cfg.databases.test.port # <-- 3306 from default
Running the tests
Tests are written using pytest and located in the "tests" directory.
pytest tests
Contributing
Feel free to use and enhance this project. Pull requests are welcome.
Authors
- Reinhard Hainz - Initial work - haipdev
License
This project is licensed under the MIT License - see the LICENSE file for details
Acknowledgments
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
haip_config-0.1.2.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for haip_config-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 376ebefd2ea0f308823a6a1dbf7d09687fecbc808175c26d781d96fe06eeac3b |
|
MD5 | e8dce4d426ee2c71bf215b0200e5a112 |
|
BLAKE2b-256 | 8193137e1ee90f194726cda0f66c64a70f5719b0a4ee216250577405d361cafd |