Skip to main content

Zenconf documentation

Zenconf is an unopinionated config management system. You put dicts in, it recursively merges them, then returns a single dict with values from later dicts overwriting values from earlier dicts.

A default implementation shows how to pull values from a dictionary of defaults, a config file, environment variables and command line parameters. Simply create your own custom config class and add values from whatever data sources you like in your chosen order of precedence. Then, request the merged dictionary and use it throughout the rest of your code.

Features

  • Simple. Just add dicts (or OrderedDicts) from wherever you like, and get the merged dictionary back.

  • No constraints on using a particular config file system, arg parser, etc.

  • Key names can be normalised by applying a function to keys recursively to make for easier comparison between keys from different data sources (e.g. from environment variables or yaml files, where one uses underscores to separate words, the other hyphens). By default keys will be converted to lowercase, have hyphens converted to underscores and then have leading underscores removed.

  • Support for filtering by, and stripping an app-specific prefix from keys (configurable per data source). This means that if your app is called MYAPP, only environment variables with a prefix of MYAPP_ could be added, e.g. MYAPP_LOG_LEVEL=debug could override a commandline argument –log-level.

Installation

Clone the repo then run ./setup.py install.

Or, install from pypi with:

pip install zenconf

Run tests with:

./setup.py test

Usage

Usage is simple. Just instantiate an instance of zenconf.MergedConfig:

  • The appname parameter can be used to namespace keys (such as environment variables).

  • The dict_boundary parameter specifies a string that indicates that we should look up the next string fragment in a subdictionary. E.g. using a default of ‘__’, the string LOG__LEVEL refers to config[‘log’][‘level’].

Next, add dicts via the add() method.

To get the merged dict, just call get_merged_config().

See comments in the code for more information about parameters. Also see the example in the examples directory of one way to use the class.

Metadata

Release files for zenconf 0.1.4

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

Source distribution (sdist)

Source distribution for zenconf 0.1.4
File Size Uploaded Provenance Actions
zenconf-0.1.4.tar.gz 5.1 kB Without provenance Details for zenconf-0.1.4.tar.gz

Release files / zenconf-0.1.4.tar.gz

Download URL zenconf-0.1.4.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a5a21982506750c76b82a690222e5e278ba574352adde5953821e940c6323aff
BLAKE2b-256 checksum
How to use checksums
2edb78e5cf4eeb06c1ed049db90c8c06e3b0447c44b583cd30e5966970f549f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for zenconf 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.

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