Skip to main content

Simple layered configuraion tool

Project description

Compendium

License Build Status codecov

Overview

Compendium is a simple 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 multiple configurations

>>> from tempfile import NamedTemporaryFile
>>> from textwrap import dedent

>>> from compendium.config_manager import ConfigManager

>>> try:
...     file1 = NamedTemporaryFile(mode='wt', suffix='.toml')
...     _ = file1.write(
...         dedent(
...             """\
...             [default]
...             foo = "bar"
...             foo2 = "bar2"
...             """
...         )
...     )
...     _ = file1.seek(0)
...
...     file2 = NamedTemporaryFile(mode='wt', suffix='.toml')
...     _ = file2.write(
...         dedent(
...             """\
...             [example.settings]
...             foo = "baz"
...             """
...         )
...     )
...     _ = file2.seek(0)
...
...     cfg = ConfigManager(name='app', filepaths=[file1.name, file2.name])
...     cfg.lookup('/example/settings/foo', '/default/foo')
...     cfg.lookup('/default/foo2')
... finally:
...     file1.close()
...     file2.close()
'baz'
'bar2'

Search settings

result = cfg.search('/servers/**/ip')

Create settings

cfg.create('/test', 'test')

Update settings

cfg.set('/owner/name', 'Tom Waits')

Delete settings

cfg.delete('/owner/name')

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

compendium-0.1.2.post3.tar.gz (16.9 kB view hashes)

Uploaded Source

Built Distribution

compendium-0.1.2.post3-py3-none-any.whl (21.4 kB view hashes)

Uploaded Python 3

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