Skip to main content

A simple yaml config manager.

Project description

haip.config

License Build Status

haip.config is a simple yaml configuration handling module for Python 3.6+.

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: a.b.c = 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

Dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
haip_config-0.1.8-py3-none-any.whl (4.9 kB) Copy SHA256 hash SHA256 Wheel py3
haip-config-0.1.8.tar.gz (3.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page