Skip to main content

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

Metadata

Release files for haip-config 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for haip-config 0.1.9
File Size Uploaded
haip-config-0.1.9.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for haip-config 0.1.9
File Interpreter ABI Platform
haip_config-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / haip-config-0.1.9.tar.gz

Download URL haip-config-0.1.9.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bd96c2197dd02e436e44732713a0101fc35b34344921085d628727f5c330323e
BLAKE2b-256 checksum
How to use checksums
2a48662d47690eb8a1ebab1652933837211442054c1705afb7e910759739178a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / haip_config-0.1.9-py3-none-any.whl

Download URL haip_config-0.1.9-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf65797132d646aeef8f638b86e64ec6f31e72ec66c73ae4011729a2e38efd7b
BLAKE2b-256 checksum
How to use checksums
ecd461eec224b58fdb1915bc722100965e86cb2e65a481e958a68e3ffa2eb90a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page