Skip to main content

a toolset to deeply merge python dictionaries.

Project description

A tools to handle merging of nested data structures in python.

example

from deepmerge import Merger

my_merger = Merger(
    # pass in a list of tuple, with the
    # strategies you are looking to apply
    # to each type.
    [
        (list, ["append"]),
        (dict, ["merge"])
    ],
    # next, choose the fallback strategies,
    # applied to all other types:
    ["override"],
    # finally, choose the strategies in
    # the case where the types conflict:
    ["override"]
)

Strategies are passed as a list, and the merge runs through each strategy sequentially, and raises an exception if none are able to resolve the merge.

You can also pass in your own merge functions, instead of a string. Your function should take the arguments of (merger, path, base_value, value_to_merge_in).

A default merge does not exist, due to the numerous choices that have to be made for every merger. However, some very generic mergers are supplied:

  • always_merger: will never raise a merge exception, and will merge when possible.

  • merge_or_raise: will merge when possible, raise an exception when there is a conflict.

The best resource for now is the unit tests.

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

deepmerge-0.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

deepmerge-0.0.2-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file deepmerge-0.0.2.tar.gz.

File metadata

  • Download URL: deepmerge-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for deepmerge-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4bb7b1261df6a13527218d7318a74d8bca962fc61001900c91ce01b8b41a9a1b
MD5 9021c8dfe72763588a7035c1fd85d850
BLAKE2b-256 3d0197b3db70b639989079209891d99b4e84573d7d707277bc0942af8bcae0e7

See more details on using hashes here.

Provenance

File details

Details for the file deepmerge-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for deepmerge-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 67c863fbf0974f7f1e51c1aa41bdb522264e44bd30fb5ac71d3a68dfa1ce0c2b
MD5 70ba34ccbe65d9dddf340f97818f5f7b
BLAKE2b-256 61946ef6dacf633e6b52c70b9f64730f5366ecb68d7166de27b501cb574f9f4f

See more details on using hashes here.

Provenance

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