Skip to main content

configmerger

merge multi level configurations.

Usage

from configmerger import Merger

# your configurations, read from app.json, machine.yaml, user.toml, or more
confs = [
    read_from_app(),
    read_from_machine(),
    read_from_user(),
]

# merge all configurations into one.
runtime_conf = Merger().merge(confs)

Merge Rules

Here is the default merge rules:

merger = Merger()

# for dict, a little like Chainmap
merger.merge([
    {'a': 1},
    {'a': 2, 'b': 3},
    {        'b': 4}
])
#   {'a': 2, 'b': 4}

# for list, default behavior is connect each
# change `merger.connect_list` to `False` can change this behavior
merger.merge([ [1, 2, 3], [4, 5] ]) # [4, 5, 1, 2, 3]

# for str, int and others, latest have highest priority
merger.merge([ 'first', 'last' ]) # 'last'

# basic, `None` is ignored
merger.merge([ 1, None ]) # 1

# but if all values is `None`, return `None`
merger.merge([ None, None ]) # None

# if type changed, merge will stop,
merger.merge([
    {'a': 1},   # <--- ignored
    1,          # <--- type changed, ignore all before this
    {'b': 2},
    None,       # <--- None is ignored
    {'c': 3},
])# {'b': 2, 'c': 3}

Override any methods to modify the default behavior.

Metadata

Release files for configmerger 0.2.0

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

Source distribution (sdist)

Source distribution for configmerger 0.2.0
File Size Uploaded Provenance
configmerger-0.2.0.tar.gz 4.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for configmerger 0.2.0
File Interpreter ABI Platform
configmerger-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 kB

Release files / configmerger-0.2.0.tar.gz

Download URL configmerger-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
02e2b028f099bff6ac8ad032a34734f14383a3c999e2f7058b0d70536feffbad
BLAKE2b-256 checksum
How to use checksums
804ab4cd29d02638c1da6665764b0cfb306f582d77cc908bd12c85ac7e198a46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.9.6 Linux/5.8.0-1040-azure

Release files / configmerger-0.2.0-py3-none-any.whl

Download URL configmerger-0.2.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adb3203ed0f49baf5604a2f9c50ab27cdafcd3d2d226eaa0ba4f93fa22a41a6f
BLAKE2b-256 checksum
How to use checksums
5720bdc453a241c1d86a424c1b76ea223656b900a54303c55449c927b43a11f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.9.6 Linux/5.8.0-1040-azure

Security for configmerger 0.2.0

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.

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