deepmerge


Namedeepmerge JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttp://deepmerge.readthedocs.io/en/latest/
Summarya toolset to deeply merge python dictionaries.
upload_time2023-12-18 22:14:13
maintainer
docs_urlNone
author
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =========
deepmerge
=========

.. image:: https://github.com/toumorokoshi/deepmerge/actions/workflows/python-package.yaml/badge.svg
    :target: https://github.com/toumorokoshi/deepmerge/actions/workflows/python-package.yaml

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

------------
Installation
------------

deepmerge is available on `pypi <https://pypi.python.org/>`_:

.. code-block:: bash

   pip install deepmerge

-------
Example
-------

**Generic Strategy**

.. code-block:: python

    from deepmerge import always_merger

    base = {"foo": ["bar"]}
    next = {"foo": ["baz"]}

    expected_result = {'foo': ['bar', 'baz']}
    result = always_merger.merge(base, next)

    assert expected_result == result


**Custom Strategy**

.. code-block:: python

    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"]),
            (set, ["union"])
        ],
        # next, choose the fallback strategies,
        # applied to all other types:
        ["override"],
        # finally, choose the strategies in
        # the case where the types conflict:
        ["override"]
    )
    base = {"foo": ["bar"]}
    next = {"bar": "baz"}
    my_merger.merge(base, next)
    assert base == {"foo": ["bar"], "bar": "baz"}


You can also pass in your own merge functions, instead of a string.

For more information, see the `docs <https://deepmerge.readthedocs.io/en/latest/>`_

            

Raw data

            {
    "_id": null,
    "home_page": "http://deepmerge.readthedocs.io/en/latest/",
    "name": "deepmerge",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/e7/53/09255a8dc8aaab38182f5c3d559022de2970413cbad385938bcc2cce6bfb/deepmerge-1.1.1.tar.gz",
    "platform": null,
    "description": "=========\ndeepmerge\n=========\n\n.. image:: https://github.com/toumorokoshi/deepmerge/actions/workflows/python-package.yaml/badge.svg\n    :target: https://github.com/toumorokoshi/deepmerge/actions/workflows/python-package.yaml\n\nA tools to handle merging of\nnested data structures in python.\n\n------------\nInstallation\n------------\n\ndeepmerge is available on `pypi <https://pypi.python.org/>`_:\n\n.. code-block:: bash\n\n   pip install deepmerge\n\n-------\nExample\n-------\n\n**Generic Strategy**\n\n.. code-block:: python\n\n    from deepmerge import always_merger\n\n    base = {\"foo\": [\"bar\"]}\n    next = {\"foo\": [\"baz\"]}\n\n    expected_result = {'foo': ['bar', 'baz']}\n    result = always_merger.merge(base, next)\n\n    assert expected_result == result\n\n\n**Custom Strategy**\n\n.. code-block:: python\n\n    from deepmerge import Merger\n\n    my_merger = Merger(\n        # pass in a list of tuple, with the\n        # strategies you are looking to apply\n        # to each type.\n        [\n            (list, [\"append\"]),\n            (dict, [\"merge\"]),\n            (set, [\"union\"])\n        ],\n        # next, choose the fallback strategies,\n        # applied to all other types:\n        [\"override\"],\n        # finally, choose the strategies in\n        # the case where the types conflict:\n        [\"override\"]\n    )\n    base = {\"foo\": [\"bar\"]}\n    next = {\"bar\": \"baz\"}\n    my_merger.merge(base, next)\n    assert base == {\"foo\": [\"bar\"], \"bar\": \"baz\"}\n\n\nYou can also pass in your own merge functions, instead of a string.\n\nFor more information, see the `docs <https://deepmerge.readthedocs.io/en/latest/>`_\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "a toolset to deeply merge python dictionaries.",
    "version": "1.1.1",
    "project_urls": {
        "Homepage": "http://deepmerge.readthedocs.io/en/latest/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65a4eeb5295637d5c85a50474d347cf6c610be43e45ce8a0211d4849fbc1701b",
                "md5": "c29b83b04c4015e42ccba99667c50677",
                "sha256": "7219dad9763f15be9dcd4bcb53e00f48e4eed6f5ed8f15824223eb934bb35977"
            },
            "downloads": -1,
            "filename": "deepmerge-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c29b83b04c4015e42ccba99667c50677",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8610,
            "upload_time": "2023-12-18T22:14:11",
            "upload_time_iso_8601": "2023-12-18T22:14:11.692001Z",
            "url": "https://files.pythonhosted.org/packages/65/a4/eeb5295637d5c85a50474d347cf6c610be43e45ce8a0211d4849fbc1701b/deepmerge-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e75309255a8dc8aaab38182f5c3d559022de2970413cbad385938bcc2cce6bfb",
                "md5": "870bb618e6cc37859d0d23c5d9aa9001",
                "sha256": "53a489dc9449636e480a784359ae2aab3191748c920649551c8e378622f0eca4"
            },
            "downloads": -1,
            "filename": "deepmerge-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "870bb618e6cc37859d0d23c5d9aa9001",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17960,
            "upload_time": "2023-12-18T22:14:13",
            "upload_time_iso_8601": "2023-12-18T22:14:13.394374Z",
            "url": "https://files.pythonhosted.org/packages/e7/53/09255a8dc8aaab38182f5c3d559022de2970413cbad385938bcc2cce6bfb/deepmerge-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-18 22:14:13",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "deepmerge"
}
        
Elapsed time: 0.17458s