Lightweight configuration management with layered sources for Python microservices
This project has been quarantined.
PyPI Admins need to review this project before it can be restored. While in quarantine, the project is not installable by clients, and cannot be being modified by its maintainers.
Read more in the project in quarantine help article.
Project description
confighub
Lightweight configuration management with layered sources for Python microservices. Load from JSON, YAML, TOML, INI, .env files with deep merging, interpolation, and change watchers.
Installation
pip install confighub
Usage
from confighub import ConfigManager, load_env, merge_deep, interpolate
# Layer multiple configuration sources
config = ConfigManager({'app': {'name': 'myservice', 'debug': False}})
config.load('config/defaults.json')
config.load('config/local.yaml')
config.from_env({'APP_PORT': 'app.port', 'DB_URL': 'database.url'})
# Access nested values with dot notation
port = config.get('app.port', 8080)
db_url = config.get('database.url')
# Watch for changes
config.watch(lambda data: print('Config updated!'))
config.set('app.debug', True)
# Load .env files
env_vars = load_env('.env', override=False)
# Deep merge configs
merged = merge_deep(base_config, override_config)
# Variable interpolation
template = {'url': 'https://${HOST:-localhost}:${PORT}'}
resolved = interpolate(template, {'HOST': 'prod.example.com', 'PORT': '443'})
Features
- Layered loading — JSON, YAML, TOML, INI, .env with priority ordering
- Deep merge — nested dict merging with override semantics
- Dot notation — access
config.get('database.pool.size') - Interpolation —
${VAR}and${VAR:-default}with env fallback - Change watchers — callback on config mutations
- Env mapping — map environment variables to config paths
- Config diffing — detect changes between versions
- Thread-safe — all operations are lock-protected
API
ConfigManager
ConfigManager(defaults=None)— create manager with optional defaults.load(source, priority=0)— load dict, file path, or env mapping.get(key, default=None)— get value by dot-notation key.set(key, value)— set value.has(key)— check existence.delete(key)— remove key.all()— get full config dict.keys(prefix=None)— list keys.from_env(mapping)— load from environment variables.watch(callback)/.unwatch(callback)
Loaders
load_json(path)/save_json(path, data)load_env(path='.env', override=False)/save_env(path, data)load_ini(path)/load_yaml(path)/load_toml(path)
Utilities
interpolate(value, context)— variable interpolationmerge_deep(base, override)— recursive dict mergefreeze(obj)— make hashable (for caching)diff(old, new)— compute config changes
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
confighub-7.0.2.tar.gz
(6.2 kB
view details)
File details
Details for the file confighub-7.0.2.tar.gz.
File metadata
- Download URL: confighub-7.0.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0baf572ddbafb55c5bd1a046ab7eac15ba6308d7bde900f659d495bb194f8bad
|
|
| MD5 |
409848feddfd073f6cecd7760b3a5f73
|
|
| BLAKE2b-256 |
44dfffecf769c4e31facb713f7b48b6c46e8cd5094f2c6a91c1769bdf15e2fe0
|