mergedict


Namemergedict JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/schettino72/mergedict/
SummaryA Python `dict` with a merge() method.
upload_time2020-01-28 14:25:09
maintainer
docs_urlNone
authorEduardo Naufel Schettino
requires_python>=3.4
licenseMIT
keywords dict singledispatch config
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            mergedict - A Python `dict` with a merge() method
===================================================

.. display some badges

.. image:: https://travis-ci.org/schettino72/mergedict.png?branch=master
  :target: https://travis-ci.org/schettino72/mergedict

.. image:: https://coveralls.io/repos/schettino72/mergedict/badge.png
        :target: https://coveralls.io/r/schettino72/mergedict


A MergeDict is a `dict` with a `merge()` method.
`merge()` is like `dict.update()`...

::

    from mergedict import MergeDict

    d1 = MergeDict({'a': 1, 'b': 'one'})
    d1.merge({'a':2, 'c': [2]})

    assert d1 == {'a': 2, 'c': [2], 'b': 'one'}


A MergeDict can be subclassed to create custom "merge" operations
based on the type of an item value.


::

    from mergedict import MergeDict

    class SumDict(MergeDict):
          @MergeDict.dispatch(int)
          def merge_int(this, other):
              return this + other

    d2 = SumDict({'a': 1, 'b': 'one'})
    d2.merge({'a':2, 'b': 'two'})

    assert d2 == {'a': 3, 'b': 'two'}


`mergedict` module comes with a `ConfigDict` that will
extend/update lists/sets/dicts.

::

    from mergedict import ConfigDict

    d3 = ConfigDict({'a': 1, 'my_list': [1, 2]})
    d3.merge({'a':2, 'my_list': [3, 4]})

    assert d3 == {'a': 2, 'my_list': [1, 2, 3, 4]}




Project Details
===============

- Project management on github - https://github.com/schettino72/mergedict/


license
=======

The MIT License
Copyright (c) 2013 Eduardo Naufel Schettino

see LICENSE file


developers / contributors
==========================

- Eduardo Naufel Schettino — main author

- Sebastian Pipping — build system fixes


install
=======

::

 $ pip install mergedict

or download and::

 $ python setup.py install


tests
=======

To run the tests::

  $ py.test




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/schettino72/mergedict/",
    "name": "mergedict",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.4",
    "maintainer_email": "",
    "keywords": "dict,singledispatch,config",
    "author": "Eduardo Naufel Schettino",
    "author_email": "schettino72@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/f2/27542b17a2f3d0b15957684467b9617a518caaf340c5ab86b8e8023945e4/mergedict-1.0.0.tar.gz",
    "platform": "any",
    "description": "mergedict - A Python `dict` with a merge() method\n===================================================\n\n.. display some badges\n\n.. image:: https://travis-ci.org/schettino72/mergedict.png?branch=master\n  :target: https://travis-ci.org/schettino72/mergedict\n\n.. image:: https://coveralls.io/repos/schettino72/mergedict/badge.png\n        :target: https://coveralls.io/r/schettino72/mergedict\n\n\nA MergeDict is a `dict` with a `merge()` method.\n`merge()` is like `dict.update()`...\n\n::\n\n    from mergedict import MergeDict\n\n    d1 = MergeDict({'a': 1, 'b': 'one'})\n    d1.merge({'a':2, 'c': [2]})\n\n    assert d1 == {'a': 2, 'c': [2], 'b': 'one'}\n\n\nA MergeDict can be subclassed to create custom \"merge\" operations\nbased on the type of an item value.\n\n\n::\n\n    from mergedict import MergeDict\n\n    class SumDict(MergeDict):\n          @MergeDict.dispatch(int)\n          def merge_int(this, other):\n              return this + other\n\n    d2 = SumDict({'a': 1, 'b': 'one'})\n    d2.merge({'a':2, 'b': 'two'})\n\n    assert d2 == {'a': 3, 'b': 'two'}\n\n\n`mergedict` module comes with a `ConfigDict` that will\nextend/update lists/sets/dicts.\n\n::\n\n    from mergedict import ConfigDict\n\n    d3 = ConfigDict({'a': 1, 'my_list': [1, 2]})\n    d3.merge({'a':2, 'my_list': [3, 4]})\n\n    assert d3 == {'a': 2, 'my_list': [1, 2, 3, 4]}\n\n\n\n\nProject Details\n===============\n\n- Project management on github - https://github.com/schettino72/mergedict/\n\n\nlicense\n=======\n\nThe MIT License\nCopyright (c) 2013 Eduardo Naufel Schettino\n\nsee LICENSE file\n\n\ndevelopers / contributors\n==========================\n\n- Eduardo Naufel Schettino \u2014 main author\n\n- Sebastian Pipping \u2014 build system fixes\n\n\ninstall\n=======\n\n::\n\n $ pip install mergedict\n\nor download and::\n\n $ python setup.py install\n\n\ntests\n=======\n\nTo run the tests::\n\n  $ py.test\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python `dict` with a merge() method.",
    "version": "1.0.0",
    "split_keywords": [
        "dict",
        "singledispatch",
        "config"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4f298a8757575ae9eb2d2ac8a7dbced7da3214f394b4c7f0716abc8e3292569",
                "md5": "75967ebccd4859557b28b64523828427",
                "sha256": "f0eeede3d2119a002f96d56a6f7617dd2d80e225926809403d54e8c811eca22d"
            },
            "downloads": -1,
            "filename": "mergedict-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75967ebccd4859557b28b64523828427",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.4",
            "size": 4497,
            "upload_time": "2020-01-28T14:25:07",
            "upload_time_iso_8601": "2020-01-28T14:25:07.560691Z",
            "url": "https://files.pythonhosted.org/packages/b4/f2/98a8757575ae9eb2d2ac8a7dbced7da3214f394b4c7f0716abc8e3292569/mergedict-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aaf227542b17a2f3d0b15957684467b9617a518caaf340c5ab86b8e8023945e4",
                "md5": "3436228a2ca7fc26c58d7ca5cccf273b",
                "sha256": "e1992b36a54229014fbcbc7a9c8c28d1f4ae131ea1d8d345c93973f9f0dc6fdc"
            },
            "downloads": -1,
            "filename": "mergedict-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3436228a2ca7fc26c58d7ca5cccf273b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.4",
            "size": 5188,
            "upload_time": "2020-01-28T14:25:09",
            "upload_time_iso_8601": "2020-01-28T14:25:09.129649Z",
            "url": "https://files.pythonhosted.org/packages/aa/f2/27542b17a2f3d0b15957684467b9617a518caaf340c5ab86b8e8023945e4/mergedict-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-01-28 14:25:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "schettino72",
    "github_project": "mergedict",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mergedict"
}
        
Elapsed time: 0.03518s