deepmerge


Namedeepmerge JSON
Version 2.0 PyPI version JSON
download
home_pageNone
SummaryA toolset for deeply merging Python dictionaries.
upload_time2024-08-30 05:31:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT Licence
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =========
deepmerge
=========

.. image:: https://img.shields.io/pypi/v/deepmerge.svg
   :target: https://pypi.org/project/deepmerge/

.. image:: https://img.shields.io/pypi/status/deepmerge.svg
   :target: https://pypi.org/project/deepmerge/

.. image:: https://img.shields.io/pypi/pyversions/pillar.svg
   :target: https://github.com/toumorokoshi/deepmerge

.. image:: https://img.shields.io/github/license/toumorokoshi/deepmerge.svg
   :target: https://github.com/toumorokoshi/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 tool to handle merging of nested data structures in Python.

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

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

.. 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/>`_

------------------
Supported Versions
------------------

deepmerge is supported on Python 3.8+.

For older Python versions the last supported version of deepmerge is listed
below:

- 3.7 : 1.1.1

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "deepmerge",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Yusuke Tsutsumi <yusuke@tsutsumi.io>",
    "download_url": "https://files.pythonhosted.org/packages/a8/3a/b0ba594708f1ad0bc735884b3ad854d3ca3bdc1d741e56e40bbda6263499/deepmerge-2.0.tar.gz",
    "platform": null,
    "description": "=========\ndeepmerge\n=========\n\n.. image:: https://img.shields.io/pypi/v/deepmerge.svg\n   :target: https://pypi.org/project/deepmerge/\n\n.. image:: https://img.shields.io/pypi/status/deepmerge.svg\n   :target: https://pypi.org/project/deepmerge/\n\n.. image:: https://img.shields.io/pypi/pyversions/pillar.svg\n   :target: https://github.com/toumorokoshi/deepmerge\n\n.. image:: https://img.shields.io/github/license/toumorokoshi/deepmerge.svg\n   :target: https://github.com/toumorokoshi/deepmerge\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 tool to handle merging of nested data structures in Python.\n\n------------\nInstallation\n------------\n\ndeepmerge is available on `pypi <https://pypi.org/project/deepmerge/>`_:\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\n------------------\nSupported Versions\n------------------\n\ndeepmerge is supported on Python 3.8+.\n\nFor older Python versions the last supported version of deepmerge is listed\nbelow:\n\n- 3.7 : 1.1.1\n",
    "bugtrack_url": null,
    "license": "MIT Licence",
    "summary": "A toolset for deeply merging Python dictionaries.",
    "version": "2.0",
    "project_urls": {
        "GitHub": "https://github.com/toumorokoshi/deepmerge",
        "Homepage": "http://deepmerge.readthedocs.io/en/latest/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d82e5d2c1c67d19841e9edc74954c827444ae826978499bde3dfc1d007c8c11",
                "md5": "3423a06cf071f65c9970f9ddef4226dd",
                "sha256": "6de9ce507115cff0bed95ff0ce9ecc31088ef50cbdf09bc90a09349a318b3d00"
            },
            "downloads": -1,
            "filename": "deepmerge-2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3423a06cf071f65c9970f9ddef4226dd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13475,
            "upload_time": "2024-08-30T05:31:48",
            "upload_time_iso_8601": "2024-08-30T05:31:48.659571Z",
            "url": "https://files.pythonhosted.org/packages/2d/82/e5d2c1c67d19841e9edc74954c827444ae826978499bde3dfc1d007c8c11/deepmerge-2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a83ab0ba594708f1ad0bc735884b3ad854d3ca3bdc1d741e56e40bbda6263499",
                "md5": "49f75a0780f287d95ce6eb7e02a44237",
                "sha256": "5c3d86081fbebd04dd5de03626a0607b809a98fb6ccba5770b62466fe940ff20"
            },
            "downloads": -1,
            "filename": "deepmerge-2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "49f75a0780f287d95ce6eb7e02a44237",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 19890,
            "upload_time": "2024-08-30T05:31:50",
            "upload_time_iso_8601": "2024-08-30T05:31:50.308762Z",
            "url": "https://files.pythonhosted.org/packages/a8/3a/b0ba594708f1ad0bc735884b3ad854d3ca3bdc1d741e56e40bbda6263499/deepmerge-2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-30 05:31:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "toumorokoshi",
    "github_project": "deepmerge",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "deepmerge"
}
        
Elapsed time: 0.27963s