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.

Source Distribution

haip-config-0.1.9.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

haip_config-0.1.9-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file haip-config-0.1.9.tar.gz.

File metadata

  • Download URL: haip-config-0.1.9.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for haip-config-0.1.9.tar.gz
Algorithm Hash digest
SHA256 bd96c2197dd02e436e44732713a0101fc35b34344921085d628727f5c330323e
MD5 25d8ccc0ecabbd2d5bac29c37629071b
BLAKE2b-256 2a48662d47690eb8a1ebab1652933837211442054c1705afb7e910759739178a

See more details on using hashes here.

File details

Details for the file haip_config-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: haip_config-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for haip_config-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bf65797132d646aeef8f638b86e64ec6f31e72ec66c73ae4011729a2e38efd7b
MD5 262ea1f920ee2d166eb186a2e1d6416a
BLAKE2b-256 ecd461eec224b58fdb1915bc722100965e86cb2e65a481e958a68e3ffa2eb90a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page