Compendium
Overview
Compendium is a layered configuration management tool. It has the capability to manage configuration files writen in JSON, TOML, XML and YAML. Settings from these configuration files can then be managed easily with the help of dpath.
Documentation
https://kuwv.github.io/python-compendium/
Install
pip install compendium
Manage a configuration file
>>> import os
>>> from compendium import ConfigFile
>>> basedir = os.path.join(os.getcwd(), 'tests')
>>> filepath = os.path.join(basedir, 'config.toml')
>>> cfg = ConfigFile(filepath)
>>> settings = cfg.load()
Simple lookup for title
>>> settings['/title']
'TOML Example'
Query values within list
>>> settings.values('/servers/**/ip')
['10.0.0.1', '10.0.0.2']
Check the current server IP address
>>> settings['/database/server']
'192.168.1.1'
Update the server IP address
>>> settings['/database/server'] = '192.168.1.2'
>>> settings['/database/server']
'192.168.1.2'
Check the database max connections
>>> settings['/database/connection_max']
5000
Delete the max connections
>>> del settings['/database/connection_max']
Check that the max connections have been removed
>>> settings.get('/database/connection_max')
Manage multiple layered configurations
The ConfigManager is a layered dictionary mapping. It allows multiple
configurations to be loaded from various files. Settings from each file
is overlapped in order so that the first setting found will be used.
>>> import os
>>> from compendium import ConfigManager
Reference config files from examples
>>> basedir = os.path.join(os.getcwd(), 'examples', 'config_manager')
>>> config1 = os.path.join(basedir, 'config1.toml')
>>> config2 = os.path.join(basedir, 'config2.toml')
Retrieve settings from config files
>>> cfg = ConfigManager(name='app', filepaths=[config1, config2])
Get using dpath
>>> cfg.get('/default/foo2')
'bar2'
Lookup with multi-query
>>> cfg.lookup('/example/settings/foo', '/default/foo')
'baz'
Manage nested configurations
>>> import os
>>> from anytree import RenderTree
>>> from compendium.config_manager import ConfigManager, TreeConfigManager
>>> basedir = os.path.join(os.getcwd(), 'examples', 'tree')
>>> cfg = TreeConfigManager(
... name='fruit',
... basedir=basedir,
... filename='node.toml',
... load_root=True,
... load_children=True,
... )
>>> cfg.defaults == {}
True
>>> 'succulant' in cfg['/fruit/children']
True
>>> succulant = cfg.get_config('/fruit/succulant')
>>> succulant.name
'succulant'
Manage configurations using Hierarchy File System (HFS)
TBD
Development
python -m venv .vev
pip install -e .[dev]
python -m doctest README.md
Metadata
Release files for compendium 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| compendium-0.1.4.tar.gz | 34.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| compendium-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.2 kB
Release files / compendium-0.1.4.tar.gz
| Download URL | compendium-0.1.4.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c3fdb93e45c5f18fd235b0a058af3a393c6fe1c6b96005393f7d074ebf45140
|
|
BLAKE2b-256 checksum How to use checksums |
e00af68239d704cba810839d10431fd1d92463aad5ab07a7987628b42bd62473
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / compendium-0.1.4-py3-none-any.whl
| Download URL | compendium-0.1.4-py3-none-any.whl |
|---|---|
| Size | 26.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
caa32b66e962b0ca127ae1efc602829e5075ee64bee5b7a7f19a8c0fc91999ba
|
|
BLAKE2b-256 checksum How to use checksums |
1ecb7e01a5cdb64ae58aa95662e10ab0e3c841d9bb6b226bafe1e7a3f9f9b51e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for compendium 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.