{ "info": { "author": "Michael Samoglyadov", "author_email": "mixas.sr@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Nested-Diff.py\n\nRecursive diff for python nested structures, implementation of\n[Nested-Diff](https://github.com/mr-mixas/Nested-Diff)\n\nBuiltin containers traversed recursively, all other types compared by values.\n\n[![Build Status](https://travis-ci.org/mr-mixas/Nested-Diff.py.svg?branch=master)](https://travis-ci.org/mr-mixas/Nested-Diff.py)\n[![Coverage Status](https://coveralls.io/repos/github/mr-mixas/Nested-Diff.py/badge.svg)](https://coveralls.io/github/mr-mixas/Nested-Diff.py)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/nested_diff.svg)](https://pypi.org/project/nested_diff/)\n[![License](https://img.shields.io/pypi/l/nested_diff.svg)](https://pypi.org/project/nested_diff/)\n\n## Diff format\n\nDiff is a dict and may contain following keys:\n\n* `A` stands for 'added', it's value - added item.\n* `D` means 'different' and contains subdiff.\n* `E` diffed entity (optional), value - empty instance of entity's class.\n* `I` index for sequence item, used only when prior item was omitted.\n* `N` is a new value for changed item.\n* `O` is a changed item's old value.\n* `R` key used for removed item.\n* `U` represent unchanged item.\n\nDiff metadata alternates with actual data; simple types specified as is, dicts,\nlists and tuples contain subdiffs for their items with native for such types\naddressing: indexes for lists and tuples and keys for dictionaries. Each status\ntype, except `D`. `E` and `I`, may be omitted during diff computation. `E` tag\nis used with `D` when entity unable to contain diff by itself (set, frozenset);\n`D` contain a list of subdiffs in this case.\n\nAnnotated example:\n\n```\na: {\"one\": [5,7]}\nb: {\"one\": [5], \"two\": 2}\nopts: U=False # omit unchanged items\n\ndiff:\n{\"D\": {\"one\": {\"D\": [{\"I\": 1, \"R\": 7}]}, \"two\": {\"A\": 2}}}\n| | | | | | || | | | | | | | |\n| | | | | | || | | | | | | | +- with value 2\n| | | | | | || | | | | | | +- key 'two' was added\n| | | | | | || | | | | | +- subdiff for it\n| | | | | | || | | | | +- another key from top-level\n| | | | | | || | | | +- what it was (item's value: 7)\n| | | | | | || | | +- what happened to item (removed)\n| | | | | | || | +- list item's actual index\n| | | | | | || +- prior item was omitted\n| | | | | | |+- subdiff for list item\n| | | | | | +- it's value - list\n| | | | | +- it is deeply changed\n| | | | +- subdiff for key 'one'\n| | | +- it has key 'one'\n| | +- top-level thing is a dict\n| +- changes somewhere deeply inside\n+- diff is always a dict\n```\n\n## Examples\n\n```\n>>> from nested_diff import diff, patch\n>>>\n>>> a = {'one': 1, 'two': 2, 'three': 3}\n>>> b = {'one': 1, 'two': 42}\n>>>\n>>> diff(a, b)\n{'D': {'three': {'R': 3}, 'two': {'O': 2, 'N': 42}, 'one': {'U': 1}}}\n>>>\n>>> diff(a, b, O=False, U=False)\n{'D': {'two': {'N': 42}, 'three': {'R': 3}}}\n>>>\n>>>\n>>> c = [0,1,2,3]\n>>> d = [ 1,2,4,5]\n>>>\n>>> diff(c, d, O=False, U=False)\n{'D': [{'R': 0}, {'I': 3, 'N': 4}, {'A': 5}]}\n>>>\n>>>\n>>> c = patch(c, diff(c, d))\n>>> assert c == d\n```\n\n## Subclassing\n\n```\nfrom nested_diff import Differ\n\n\nclass CustomDiffer(Differ):\n \"\"\"\n Use custom precision for floats.\n\n \"\"\"\n def __init__(self, float_precision=2, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.set_differ(float, self.diff_float)\n self.float_precision = float_precision\n\n def diff_float(self, a, b):\n if round(a, self.float_precision) == round(b, self.float_precision):\n return {'U': a} if self.op_u else {}\n\n return super().diff__default(a, b)\n\n\ndiffer = CustomDiffer(float_precision=1, U=False)\n\na = [0.001, 0.01, 0.1]\nb = [0.002, 0.02, 0.2]\n\nassert {'D': [{'I': 2, 'N': 0.2, 'O': 0.1}]} == differ.diff(a, b)\n```\n\n## License\n\nLicensed under the terms of the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0>).\n\n## See Also\n\n[deepdiff](https://pypi.org/project/deepdiff/),\n[jsondiff](https://pypi.org/project/jsondiff/),\n[jsonpatch](https://pypi.org/project/jsonpatch/),\n[json-delta](https://pypi.org/project/json-delta/)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mr-mixas/Nested-Diff.py", "keywords": "diff nested-diff recursive-diff nested-data data-structures", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "nested-diff", "package_url": "https://pypi.org/project/nested-diff/", "platform": "", "project_url": "https://pypi.org/project/nested-diff/", "project_urls": { "Homepage": "https://github.com/mr-mixas/Nested-Diff.py" }, "release_url": "https://pypi.org/project/nested-diff/0.5/", "requires_dist": null, "requires_python": "", "summary": "Recursive diff for nested structures", "version": "0.5" }, "last_serial": 5766616, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "a3eb89be0757950eb9ba8180d6f61044", "sha256": "5372821d3b007451dfcb2a5f87987f24afc4be4e7c8bc0170127b40e7f7d392d" }, "downloads": -1, "filename": "nested_diff-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a3eb89be0757950eb9ba8180d6f61044", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7284, "upload_time": "2018-11-26T07:21:00", "url": "https://files.pythonhosted.org/packages/9c/a6/3345a31c7c848299eda61ae58eac0c48ed5b1855162b74724fd5969670ca/nested_diff-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f38e7b10f1a727dcefc8dbb20b8e5f10", "sha256": "f5d3d5d4c213143a41a30ffc094f19d7fcab13f2e3dfdb88f900be0ee824c45c" }, "downloads": -1, "filename": "nested_diff-0.1.tar.gz", "has_sig": false, "md5_digest": "f38e7b10f1a727dcefc8dbb20b8e5f10", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2895, "upload_time": "2018-11-26T07:21:02", "url": "https://files.pythonhosted.org/packages/38/db/d6c927db16cb28e5118ae3eb36b4018703b6fc0fb4852b822122fe6998d8/nested_diff-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "da7d7204523d50e2287aa50f8c01b200", "sha256": "9f58cdb3672699d89055b2b9ab3b582e7118f161be85d57b19b5caae68dbfe36" }, "downloads": -1, "filename": "nested_diff-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "da7d7204523d50e2287aa50f8c01b200", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7660, "upload_time": "2018-12-01T11:45:18", "url": "https://files.pythonhosted.org/packages/26/ed/a5362aeb4bfb34cb75ba39687591bcd90eee778d08d486bda36c060419e5/nested_diff-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3156df168d9ab9eddc00e0d0916473a4", "sha256": "0f45810f2f5cebc52b4aedf2b92b45989000bb53f7d64eb7d8378cae00a271de" }, "downloads": -1, "filename": "nested_diff-0.2.tar.gz", "has_sig": false, "md5_digest": "3156df168d9ab9eddc00e0d0916473a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3299, "upload_time": "2018-12-01T11:45:20", "url": "https://files.pythonhosted.org/packages/c9/26/4966adc375b7568a03207ffa674910c268bf97b42e55b9f1d8279f04fbdd/nested_diff-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "7fa3b4393bf82510e0bef4223f32b159", "sha256": "e175bd359bb06289fc12a24b9faaa42c270b2028367ccdf3e0561e2e9def09bd" }, "downloads": -1, "filename": "nested_diff-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "7fa3b4393bf82510e0bef4223f32b159", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9747, "upload_time": "2019-01-05T11:04:25", "url": "https://files.pythonhosted.org/packages/97/09/50202333259866706b8dbba169e6e89814518f51f2e24c4058dbede58afe/nested_diff-0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fcb2dee8edf65ff1b5009a8ea2bcaf5a", "sha256": "bf9a8f51ba477252d13fe49e093a26e9386dd733217db2ae442a6e83ebb5fdef" }, "downloads": -1, "filename": "nested_diff-0.3.tar.gz", "has_sig": false, "md5_digest": "fcb2dee8edf65ff1b5009a8ea2bcaf5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5400, "upload_time": "2019-01-05T11:04:26", "url": "https://files.pythonhosted.org/packages/4d/36/18d2ad7304e43525e9dd905f33ffe1996e906310ec3039f1eb2915102392/nested_diff-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "5d327003ba074ddee4548e977216b4f8", "sha256": "1ca6906f018b3ffc287cf0b2f051a02e5283c59a1f8a294301e518ad26de75d9" }, "downloads": -1, "filename": "nested_diff-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "5d327003ba074ddee4548e977216b4f8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10719, "upload_time": "2019-01-23T19:35:51", "url": "https://files.pythonhosted.org/packages/3c/eb/5ab2b5df5c9e5e3a4186dab69fafc9076b159d52c48c7c9f3bb93734e607/nested_diff-0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9f4cd970d431b73f70a70b15e93707a2", "sha256": "c2aac151d501218633398a20350c7443f4e6b09d8920c3285905a0a206774999" }, "downloads": -1, "filename": "nested_diff-0.4.tar.gz", "has_sig": false, "md5_digest": "9f4cd970d431b73f70a70b15e93707a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6086, "upload_time": "2019-01-23T19:35:53", "url": "https://files.pythonhosted.org/packages/61/f5/7990a5c63ec055866f461370b440ee4bb3d762bd3d205a33378396b3e5a9/nested_diff-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "5b993c5dd2175923fae97af64227af7d", "sha256": "9f7b871a30ad7e47794d23b340988f9bf29ba05ba2a47eb7df3779849b99dd55" }, "downloads": -1, "filename": "nested_diff-0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "5b993c5dd2175923fae97af64227af7d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20394, "upload_time": "2019-09-01T10:44:18", "url": "https://files.pythonhosted.org/packages/23/f2/ddb0ef06d231b719b7c0fbcd9632d046a6a355178f186cdad383e2da7df8/nested_diff-0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "72466c6c24825933a173bd905dab6dfd", "sha256": "c160a9398410ea3c396e3b4276e795474f0db9186ca23bec74b061a88012c4c2" }, "downloads": -1, "filename": "nested_diff-0.5.tar.gz", "has_sig": false, "md5_digest": "72466c6c24825933a173bd905dab6dfd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11230, "upload_time": "2019-09-01T10:44:20", "url": "https://files.pythonhosted.org/packages/74/3a/5fb8aa998d68399665fc9ef2dff4510261072c0f5a88d8bee3743e0cfa1f/nested_diff-0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5b993c5dd2175923fae97af64227af7d", "sha256": "9f7b871a30ad7e47794d23b340988f9bf29ba05ba2a47eb7df3779849b99dd55" }, "downloads": -1, "filename": "nested_diff-0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "5b993c5dd2175923fae97af64227af7d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20394, "upload_time": "2019-09-01T10:44:18", "url": "https://files.pythonhosted.org/packages/23/f2/ddb0ef06d231b719b7c0fbcd9632d046a6a355178f186cdad383e2da7df8/nested_diff-0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "72466c6c24825933a173bd905dab6dfd", "sha256": "c160a9398410ea3c396e3b4276e795474f0db9186ca23bec74b061a88012c4c2" }, "downloads": -1, "filename": "nested_diff-0.5.tar.gz", "has_sig": false, "md5_digest": "72466c6c24825933a173bd905dab6dfd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11230, "upload_time": "2019-09-01T10:44:20", "url": "https://files.pythonhosted.org/packages/74/3a/5fb8aa998d68399665fc9ef2dff4510261072c0f5a88d8bee3743e0cfa1f/nested_diff-0.5.tar.gz" } ] }