pax_global_header00006660000000000000000000000064140073121620014506gustar00rootroot0000000000000052 comment=ab871aff9eccb5e1bf0ea237c3cff8f6787ebc56 mergedeep-1.3.4/000077500000000000000000000000001400731216200134505ustar00rootroot00000000000000mergedeep-1.3.4/.coveragerc000066400000000000000000000002111400731216200155630ustar00rootroot00000000000000[run] include = mergedeep/mergedeep.py omit = */test_* */__main__.py */__init__.py setup.py manage.py venv/* mergedeep-1.3.4/.gitignore000066400000000000000000000024001400731216200154340ustar00rootroot00000000000000# Created by .ignore support plugin (hsz.mobi) ### Python template # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ coverage mergedeep-1.3.4/.readthedocs.yml000066400000000000000000000001521400731216200165340ustar00rootroot00000000000000build: image: latest python: version: 3.6 pip_install: true formats: - htmlzip - pdf - epub mergedeep-1.3.4/LICENSE000066400000000000000000000021651400731216200144610ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2019 Travis Clarke (https://www.travismclarke.com/) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mergedeep-1.3.4/MANIFEST.in000066400000000000000000000000641400731216200152060ustar00rootroot00000000000000include LICENSE README.md global-exclude *test_*.py mergedeep-1.3.4/Makefile000066400000000000000000000030171400731216200151110ustar00rootroot00000000000000PYTHON := python project:=mergedeep version:=$(shell $(PYTHON) -c 'import sys, os; sys.path.insert(0, os.path.abspath(".")); print(__import__("${project}").__version__)') .PHONY: list list help: @make -pq | awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | sed '/Makefile/d' | sort .PHONY: format format: @$(PYTHON) -m black *.py ./mergedeep/*.py -l 120 .PHONY: build build: clean @rm -rf ./dist/* @$(PYTHON) setup.py sdist bdist_wheel .PHONY: test-setup test-setup: @pyenv install -s 3.6.10 @pyenv install -s 3.7.7 @pyenv install -s 3.8.2 @pyenv install -s 3.9.1 .PHONY: test test: test-setup @pyenv local 3.6.10 3.7.7 3.8.2 3.9.1 @$(PYTHON) -m tox .PHONY: clean clean: @rm -rf ./dist ./build ./*.egg-info ./htmlcov @find . -name '*.pyc' -delete @find . -name '__pycache__' -delete .PHONY: check check: @twine check dist/* .PHONY: upload-test upload-test: test clean build check @twine upload --repository-url https://test.pypi.org/legacy/ dist/* .PHONY: tag tag: ifeq (,$(shell git tag --list | grep "${version}")) @git tag "v${version}" endif .PHONY: release release: tag ifdef version @curl -XPOST \ -H "Authorization: token ${GITHUB_ACCESS_TOKEN}" \ -H "Content-Type: application/json" \ "https://api.github.com/repos/clarketm/${project}/releases" \ --data "{\"tag_name\": \"v${version}\",\"target_commitish\": \"master\",\"name\": \"v${version}\",\"draft\": false,\"prerelease\": false}" endif .PHONY: upload publish upload: test clean build check @twine upload dist/* mergedeep-1.3.4/Pipfile000066400000000000000000000003571400731216200147700ustar00rootroot00000000000000[[source]] name = "pypi" url = "https://pypi.org/simple" verify_ssl = true [dev-packages] black = "*" tox = "<3.8" twine = "*" pytest = "*" tox-pyenv = "*" [packages] [requires] python_version = "3.8" [pipenv] allow_prereleases = true mergedeep-1.3.4/Pipfile.lock000066400000000000000000000463231400731216200157220ustar00rootroot00000000000000{ "_meta": { "hash": { "sha256": "d4c190fcf775240b742702ea3c1b7ea23beb67b0b287f8f477294d1f238ed9d2" }, "pipfile-spec": 6, "requires": { "python_version": "3.8" }, "sources": [ { "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true } ] }, "default": {}, "develop": { "appdirs": { "hashes": [ "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41", "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128" ], "version": "==1.4.4" }, "attrs": { "hashes": [ "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6", "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==20.3.0" }, "black": { "hashes": [ "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea" ], "index": "pypi", "version": "==20.8b1" }, "bleach": { "hashes": [ "sha256:52b5919b81842b1854196eaae5ca29679a2f2e378905c346d3ca8227c2c66080", "sha256:9f8ccbeb6183c6e6cddea37592dfb0167485c1e3b13b3363bc325aa8bda3adbd" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==3.2.1" }, "certifi": { "hashes": [ "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c", "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830" ], "version": "==2020.12.5" }, "chardet": { "hashes": [ "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa", "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==4.0.0" }, "click": { "hashes": [ "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==7.1.2" }, "colorama": { "hashes": [ "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b", "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==0.4.4" }, "distlib": { "hashes": [ "sha256:8c09de2c67b3e7deef7184574fc060ab8a793e7adbb183d942c389c8b13c52fb", "sha256:edf6116872c863e1aa9d5bb7cb5e05a022c519a4594dc703843343a9ddd9bff1" ], "version": "==0.3.1" }, "docutils": { "hashes": [ "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af", "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==0.16" }, "filelock": { "hashes": [ "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59", "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836" ], "version": "==3.0.12" }, "idna": { "hashes": [ "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.10" }, "iniconfig": { "hashes": [ "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" ], "version": "==1.1.1" }, "keyring": { "hashes": [ "sha256:1746d3ac913d449a090caf11e9e4af00e26c3f7f7e81027872192b2398b98675", "sha256:4be9cbaaaf83e61d6399f733d113ede7d1c73bc75cb6aeb64eee0f6ac39b30ea" ], "markers": "python_version >= '3.6'", "version": "==21.8.0" }, "mypy-extensions": { "hashes": [ "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" ], "version": "==0.4.3" }, "packaging": { "hashes": [ "sha256:24e0da08660a87484d1602c30bb4902d74816b6985b93de36926f5bc95741858", "sha256:78598185a7008a470d64526a8059de9aaa449238f280fc9eb6b13ba6c4109093" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==20.8" }, "pathspec": { "hashes": [ "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd", "sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d" ], "version": "==0.8.1" }, "pkginfo": { "hashes": [ "sha256:a6a4ac943b496745cec21f14f021bbd869d5e9b4f6ec06918cffea5a2f4b9193", "sha256:ce14d7296c673dc4c61c759a0b6c14bae34e34eb819c0017bb6ca5b7292c56e9" ], "version": "==1.6.1" }, "pluggy": { "hashes": [ "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==0.13.1" }, "py": { "hashes": [ "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.10.0" }, "pygments": { "hashes": [ "sha256:ccf3acacf3782cbed4a989426012f1c535c9a90d3a7fc3f16d231b9372d2b716", "sha256:f275b6c0909e5dafd2d6269a656aa90fa58ebf4a74f8fcf9053195d226b24a08" ], "markers": "python_version >= '3.5'", "version": "==2.7.3" }, "pyparsing": { "hashes": [ "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" ], "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.4.7" }, "pytest": { "hashes": [ "sha256:1969f797a1a0dbd8ccf0fecc80262312729afea9c17f1d70ebf85c5e76c6f7c8", "sha256:66e419b1899bc27346cb2c993e12c5e5e8daba9073c1fbce33b9807abc95c306" ], "index": "pypi", "version": "==6.2.1" }, "readme-renderer": { "hashes": [ "sha256:267854ac3b1530633c2394ead828afcd060fc273217c42ac36b6be9c42cd9a9d", "sha256:6b7e5aa59210a40de72eb79931491eaf46fefca2952b9181268bd7c7c65c260a" ], "version": "==28.0" }, "regex": { "hashes": [ "sha256:02951b7dacb123d8ea6da44fe45ddd084aa6777d4b2454fa0da61d569c6fa538", "sha256:0d08e71e70c0237883d0bef12cad5145b84c3705e9c6a588b2a9c7080e5af2a4", "sha256:1862a9d9194fae76a7aaf0150d5f2a8ec1da89e8b55890b1786b8f88a0f619dc", "sha256:1ab79fcb02b930de09c76d024d279686ec5d532eb814fd0ed1e0051eb8bd2daa", "sha256:1fa7ee9c2a0e30405e21031d07d7ba8617bc590d391adfc2b7f1e8b99f46f444", "sha256:262c6825b309e6485ec2493ffc7e62a13cf13fb2a8b6d212f72bd53ad34118f1", "sha256:2a11a3e90bd9901d70a5b31d7dd85114755a581a5da3fc996abfefa48aee78af", "sha256:2c99e97d388cd0a8d30f7c514d67887d8021541b875baf09791a3baad48bb4f8", "sha256:3128e30d83f2e70b0bed9b2a34e92707d0877e460b402faca908c6667092ada9", "sha256:38c8fd190db64f513fe4e1baa59fed086ae71fa45083b6936b52d34df8f86a88", "sha256:3bddc701bdd1efa0d5264d2649588cbfda549b2899dc8d50417e47a82e1387ba", "sha256:4902e6aa086cbb224241adbc2f06235927d5cdacffb2425c73e6570e8d862364", "sha256:49cae022fa13f09be91b2c880e58e14b6da5d10639ed45ca69b85faf039f7a4e", "sha256:56e01daca75eae420bce184edd8bb341c8eebb19dd3bce7266332258f9fb9dd7", "sha256:5862975b45d451b6db51c2e654990c1820523a5b07100fc6903e9c86575202a0", "sha256:6a8ce43923c518c24a2579fda49f093f1397dad5d18346211e46f134fc624e31", "sha256:6c54ce4b5d61a7129bad5c5dc279e222afd00e721bf92f9ef09e4fae28755683", "sha256:6e4b08c6f8daca7d8f07c8d24e4331ae7953333dbd09c648ed6ebd24db5a10ee", "sha256:717881211f46de3ab130b58ec0908267961fadc06e44f974466d1887f865bd5b", "sha256:749078d1eb89484db5f34b4012092ad14b327944ee7f1c4f74d6279a6e4d1884", "sha256:7913bd25f4ab274ba37bc97ad0e21c31004224ccb02765ad984eef43e04acc6c", "sha256:7a25fcbeae08f96a754b45bdc050e1fb94b95cab046bf56b016c25e9ab127b3e", "sha256:83d6b356e116ca119db8e7c6fc2983289d87b27b3fac238cfe5dca529d884562", "sha256:8b882a78c320478b12ff024e81dc7d43c1462aa4a3341c754ee65d857a521f85", "sha256:8f6a2229e8ad946e36815f2a03386bb8353d4bde368fdf8ca5f0cb97264d3b5c", "sha256:9801c4c1d9ae6a70aeb2128e5b4b68c45d4f0af0d1535500884d644fa9b768c6", "sha256:a15f64ae3a027b64496a71ab1f722355e570c3fac5ba2801cafce846bf5af01d", "sha256:a3d748383762e56337c39ab35c6ed4deb88df5326f97a38946ddd19028ecce6b", "sha256:a63f1a07932c9686d2d416fb295ec2c01ab246e89b4d58e5fa468089cab44b70", "sha256:b2b1a5ddae3677d89b686e5c625fc5547c6e492bd755b520de5332773a8af06b", "sha256:b2f4007bff007c96a173e24dcda236e5e83bde4358a557f9ccf5e014439eae4b", "sha256:baf378ba6151f6e272824b86a774326f692bc2ef4cc5ce8d5bc76e38c813a55f", "sha256:bafb01b4688833e099d79e7efd23f99172f501a15c44f21ea2118681473fdba0", "sha256:bba349276b126947b014e50ab3316c027cac1495992f10e5682dc677b3dfa0c5", "sha256:c084582d4215593f2f1d28b65d2a2f3aceff8342aa85afd7be23a9cad74a0de5", "sha256:d1ebb090a426db66dd80df8ca85adc4abfcbad8a7c2e9a5ec7513ede522e0a8f", "sha256:d2d8ce12b7c12c87e41123997ebaf1a5767a5be3ec545f64675388970f415e2e", "sha256:e32f5f3d1b1c663af7f9c4c1e72e6ffe9a78c03a31e149259f531e0fed826512", "sha256:e3faaf10a0d1e8e23a9b51d1900b72e1635c2d5b0e1bea1c18022486a8e2e52d", "sha256:f7d29a6fc4760300f86ae329e3b6ca28ea9c20823df123a2ea8693e967b29917", "sha256:f8f295db00ef5f8bae530fc39af0b40486ca6068733fb860b42115052206466f" ], "version": "==2020.11.13" }, "requests": { "hashes": [ "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804", "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==2.25.1" }, "requests-toolbelt": { "hashes": [ "sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f", "sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0" ], "version": "==0.9.1" }, "rfc3986": { "hashes": [ "sha256:112398da31a3344dc25dbf477d8df6cb34f9278a94fee2625d89e4514be8bb9d", "sha256:af9147e9aceda37c91a05f4deb128d4b4b49d6b199775fd2d2927768abdc8f50" ], "version": "==1.4.0" }, "six": { "hashes": [ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.15.0" }, "toml": { "hashes": [ "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" ], "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==0.10.2" }, "tox": { "hashes": [ "sha256:04f8f1aa05de8e76d7a266ccd14e0d665d429977cd42123bc38efa9b59964e9e", "sha256:25ef928babe88c71e3ed3af0c464d1160b01fca2dd1870a5bb26c2dea61a17fc" ], "index": "pypi", "version": "==3.7.0" }, "tox-pyenv": { "hashes": [ "sha256:916c2213577aec0b3b5452c5bfb32fd077f3a3196f50a81ad57d7ef3fc2599e4", "sha256:e470c18af115fe52eeff95e7e3cdd0793613eca19709966fc2724b79d55246cb" ], "index": "pypi", "version": "==1.1.0" }, "tqdm": { "hashes": [ "sha256:556c55b081bd9aa746d34125d024b73f0e2a0e62d5927ff0e400e20ee0a03b9a", "sha256:b8b46036fd00176d0870307123ef06bb851096964fa7fc578d789f90ce82c3e4" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==4.55.1" }, "twine": { "hashes": [ "sha256:2f6942ec2a17417e19d2dd372fc4faa424c87ee9ce49b4e20c427eb00a0f3f41", "sha256:fcffa8fc37e8083a5be0728371f299598870ee1eccc94e9a25cef7b1dcfa8297" ], "index": "pypi", "version": "==3.3.0" }, "typed-ast": { "hashes": [ "sha256:07d49388d5bf7e863f7fa2f124b1b1d89d8aa0e2f7812faff0a5658c01c59aa1", "sha256:14bf1522cdee369e8f5581238edac09150c765ec1cb33615855889cf33dcb92d", "sha256:240296b27397e4e37874abb1df2a608a92df85cf3e2a04d0d4d61055c8305ba6", "sha256:36d829b31ab67d6fcb30e185ec996e1f72b892255a745d3a82138c97d21ed1cd", "sha256:37f48d46d733d57cc70fd5f30572d11ab8ed92da6e6b28e024e4a3edfb456e37", "sha256:4c790331247081ea7c632a76d5b2a265e6d325ecd3179d06e9cf8d46d90dd151", "sha256:5dcfc2e264bd8a1db8b11a892bd1647154ce03eeba94b461effe68790d8b8e07", "sha256:7147e2a76c75f0f64c4319886e7639e490fee87c9d25cb1d4faef1d8cf83a440", "sha256:7703620125e4fb79b64aa52427ec192822e9f45d37d4b6625ab37ef403e1df70", "sha256:8368f83e93c7156ccd40e49a783a6a6850ca25b556c0fa0240ed0f659d2fe496", "sha256:84aa6223d71012c68d577c83f4e7db50d11d6b1399a9c779046d75e24bed74ea", "sha256:85f95aa97a35bdb2f2f7d10ec5bbdac0aeb9dafdaf88e17492da0504de2e6400", "sha256:8db0e856712f79c45956da0c9a40ca4246abc3485ae0d7ecc86a20f5e4c09abc", "sha256:9044ef2df88d7f33692ae3f18d3be63dec69c4fb1b5a4a9ac950f9b4ba571606", "sha256:963c80b583b0661918718b095e02303d8078950b26cc00b5e5ea9ababe0de1fc", "sha256:987f15737aba2ab5f3928c617ccf1ce412e2e321c77ab16ca5a293e7bbffd581", "sha256:9ec45db0c766f196ae629e509f059ff05fc3148f9ffd28f3cfe75d4afb485412", "sha256:9fc0b3cb5d1720e7141d103cf4819aea239f7d136acf9ee4a69b047b7986175a", "sha256:a2c927c49f2029291fbabd673d51a2180038f8cd5a5b2f290f78c4516be48be2", "sha256:a38878a223bdd37c9709d07cd357bb79f4c760b29210e14ad0fb395294583787", "sha256:b4fcdcfa302538f70929eb7b392f536a237cbe2ed9cba88e3bf5027b39f5f77f", "sha256:c0c74e5579af4b977c8b932f40a5464764b2f86681327410aa028a22d2f54937", "sha256:c1c876fd795b36126f773db9cbb393f19808edd2637e00fd6caba0e25f2c7b64", "sha256:c9aadc4924d4b5799112837b226160428524a9a45f830e0d0f184b19e4090487", "sha256:cc7b98bf58167b7f2db91a4327da24fb93368838eb84a44c472283778fc2446b", "sha256:cf54cfa843f297991b7388c281cb3855d911137223c6b6d2dd82a47ae5125a41", "sha256:d003156bb6a59cda9050e983441b7fa2487f7800d76bdc065566b7d728b4581a", "sha256:d175297e9533d8d37437abc14e8a83cbc68af93cc9c1c59c2c292ec59a0697a3", "sha256:d746a437cdbca200622385305aedd9aef68e8a645e385cc483bdc5e488f07166", "sha256:e683e409e5c45d5c9082dc1daf13f6374300806240719f95dc783d1fc942af10" ], "version": "==1.4.2" }, "typing-extensions": { "hashes": [ "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918", "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c", "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f" ], "version": "==3.7.4.3" }, "urllib3": { "hashes": [ "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08", "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", "version": "==1.26.2" }, "virtualenv": { "hashes": [ "sha256:54b05fc737ea9c9ee9f8340f579e5da5b09fb64fd010ab5757eb90268616907c", "sha256:b7a8ec323ee02fb2312f098b6b4c9de99559b462775bc8fe3627a73706603c1b" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==20.2.2" }, "webencodings": { "hashes": [ "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" ], "version": "==0.5.1" } } } mergedeep-1.3.4/README.md000066400000000000000000000071441400731216200147350ustar00rootroot00000000000000# [mergedeep](https://mergedeep.readthedocs.io/en/latest/) [![PyPi release](https://img.shields.io/pypi/v/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![PyPi versions](https://img.shields.io/pypi/pyversions/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![Downloads](https://pepy.tech/badge/mergedeep)](https://pepy.tech/project/mergedeep) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Documentation Status](https://readthedocs.org/projects/mergedeep/badge/?version=latest)](https://mergedeep.readthedocs.io/en/latest/?badge=latest) A deep merge function for 🐍. [Check out the mergedeep docs](https://mergedeep.readthedocs.io/en/latest/) ## Installation ```bash $ pip install mergedeep ``` ## Usage ```text merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping ``` Deep merge without mutating the source dicts. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` Deep merge into an existing dict. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merge(a, b, c) print(a) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` ### Merge strategies: 1. Replace (*default*) > `Strategy.REPLACE` ```python3 # When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default). # Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": [3, 4]} merge(dst, src, strategy=Strategy.REPLACE) # same as: merge(dst, src) print(dst) # {"key": [3, 4]} ``` 2. Additive > `Strategy.ADDITIVE` ```python3 # When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`. # Additive collection types include: `list`, `tuple`, `set`, and `Counter` # Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})} src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})} merge(dst, src, strategy=Strategy.ADDITIVE) print(dst) # {"key": [1, 2, 3, 4], "count": Counter({"a": 2, "b": 1, "c": 1})} ``` 3. Typesafe replace > `Strategy.TYPESAFE_REPLACE` or `Strategy.TYPESAFE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_REPLACE) # same as: `Strategy.TYPESAFE` # TypeError: destination type: differs from source type: for key: "key" ``` 4. Typesafe additive > `Strategy.TYPESAFE_ADDITIVE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `ADDITIVE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_ADDITIVE) # TypeError: destination type: differs from source type: for key: "key" ``` ## License MIT © [**Travis Clarke**](https://blog.travismclarke.com/) mergedeep-1.3.4/docs/000077500000000000000000000000001400731216200144005ustar00rootroot00000000000000mergedeep-1.3.4/docs/Makefile000066400000000000000000000011101400731216200160310ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SOURCEDIR = source BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)mergedeep-1.3.4/docs/source/000077500000000000000000000000001400731216200157005ustar00rootroot00000000000000mergedeep-1.3.4/docs/source/_static/000077500000000000000000000000001400731216200173265ustar00rootroot00000000000000mergedeep-1.3.4/docs/source/_static/forkme_right_red_aa0000.png000066400000000000000000000173671400731216200243250ustar00rootroot00000000000000PNG  IHDRQOtEXtSoftwareAdobe ImageReadyqe<IDATx]yT׵\qdRQ1jf2qH5[歾&PzUش]Mx}/͠MҦi1N8Atyw8Lrk};pۯ+|Wi{_y艃D ?!ZW{$^ v񻧭;y§Me&<*g]G '/i S)pQV\XO|Q_SˍlD >n+,=p,']$Ϛ*۔v; M+*#jv,pH]jjȑuUUk u0ۣG:$Aus=+vGq7ߜ3wJW8bhW]Rź ǰD?KKHX;ᇩ* qO0m0a݇Uw'6h_2y8YD:WV}if 5"og@gR7Sҽf-+H3w+ 01p) z&ip{ʕbY_k5"`8 1nᳯՌ!23q1_"c(jL畡-8C tA$MZ8hXTf1WAN ]_Hw }gQXj*E0c}ޭ@&O`xo`(Sjw`CB(fjzϽ\[{?? lR.J\s粋>_FӦp\Nu423O}!8 Tˆn@b2+ٳe*;rDB/2یUxZΕhĉ4UؓjZsFHGMJ)KŻ-Znj5>4|X78{zqq\y*VN [Іo 4"ۡ P 2rf o߮۠rXDD++gHXfRuD jvyۢ@:}0]!Ͻr+*w3SA.~yZ!5 *wK4YJT7\޽1YջCݚE9 Zgwfֲ 3}S:c}%TLM W֯d )`$*X\!}eˈwG;t(ԛoRKSEϞNP4"Tc@E(G\d*OqFKzg"Yu@[Z'=}Pw*Ɇnk)ݏ=9+Wsr(^8L9j]pk}&;7-kĈAUrX'O.bOD}7+HfVeD~]wMc~Zw.ɓ)~޼ħ5V(t6)CSvC a n~X)n})ŽU] V6 r~~559WK :lsPb@!PtR@3cF@ Ued[@CHHa^68Uinn;79 Yn꿸ng\3h"WȫԒ;+rWc!W T,Zcg I;pU"`(0:4`v 7`@~>EϙC-4& 5^_P@W7hV^SŲ hmWWVirf5\GB?]`/!8RtZ zP,ك cY$< jEq_f7.6"$ËbJSOq|&Q?oOuMrX'.|]+q+#XgaG4JhȘ^B "c2dzӧEk>dȀ]`*(^ JzQg o"f?i YY4M[d@i7کST"o )PxM ѯD6QWzjD-{"B xM0vRrW]Əe3dHʭU! E=\:犐7fq$2Q*34]CY`y?dؕ 6ՄNjmc! *w QƍT[NLg1;2bWU~@Sc_!_ )MI%hl>T5`' ff@k (s`U7?Wi4o۴:mZ4Sy&oOJ*D*b,  S.^FQG b^!ܸᵔz)'A }.}e@ "t̽VQAl- 0*j{o7Ѡca@.g8c3av{)A LaVqsW* Uh j A)Ʋٞ%KDhj3p+W2@J{Z!*o(" CZ{R?p:MAxC㎞;W EFh>B5>o,?TBY;nd߾'xLpIv*˹?  Rڬ'(=\ތ.wu^  i /?4f>7|{T6VcYu @yLb=zj슱 m$WAW:s&/՚ |j^8 [XWZCg ЋouK+{Ws !Qbub PR X}!E=ބZZ2rqq>c[pC]]v [ox^ڂ-EfYrdP81-֬9D" YZŽj +5">ŋA`5Rn"(E:tԻD^Bw?K2ހy+Ycn6Ѡ`MFS)SgSRӲDAE~ V{/Hyq+PY =Űq{[]?p K>?EpU KE)MŬP\)Wyb޳WG:0!sJ Ѥddf&%qG !!jz=<\1²# uXB0b03Ug`mn GytiDz:fK a ޓ[A_]壅ڛ(OnR.5 U*ޒ94~)Ȃd }U 7 x4OAëTY>Ydn$j5>|fddwbRx1RlUgvO6f{L!dT6$+>|xj*?v`}umA~A5|XإSXؒ9nWx)Y,s`-$|WZswրM~ Ê3G<)ڲǓ rq5|XiGwf[SZi k)T1쐵wVKdn3/]0aU$!p8Қ{+9bG N6F0 ,#llj_Z OB%KҲg&tj(ᆰ0+P1@@npXH t.i Pɔ$n3J7XkQj "3!z,@_j2V<7zպ:oB0(6+WcM6QyP0 w8*gPƠ0e=H&~d9FjK+ti[~nNr8N`uiy ޘ~sr^ab_aNâ %[jP q`}{d'Gs6^`: ź .W6nu4cY1VauuN7Phb/fA*CCz-W"-L5X{}}vM^E{:s}4S nƚ8vTc6kRB=^1h-Wx,|f 9"gLs<|x[Sf*wlLͽpCmh ˖RTfN1S}I(L-z-@}57bϧkB *mnٳ٨s˦ i+LS1Fhc 2`I5Sic BFTc ׯp5 م99iWc/4){+LcTV`%8,*nM361V\bf*m0@ /OU< 35SicFGPΝT<I))mJ*Nwh]a\ rJW-M4Sic%e_)ȎΦ 4c^T:$F^5Sis`J }r"WҢJ[gDo׿]}h{f EEiPisXo۷.n i+lב7D?M+ *m=VVo>qTz ,W +4X泳Mh6QV´iϺ N~}V?<G;W#끦Z%Amp=۪A7^,P?꤇6o4y\-4yaT4 \PiӦAMJ6mT_YMUQBt-IENDB`mergedeep-1.3.4/docs/source/conf.py000066400000000000000000000165771400731216200172170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config import sys, os sys.path.append(os.path.abspath("../../")) from recommonmark.parser import CommonMarkParser from recommonmark.transform import AutoStructify # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- project = "" copyright = "2019, Travis Clarke" author = "Travis Clarke" # The full version, including alpha/beta/rc tags release = __import__("mergedeep").__version__ # The short X.Y version version = release # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "sphinx.ext.autodoc", "sphinx.ext.doctest", "sphinx.ext.intersphinx", "sphinx.ext.todo", "sphinx.ext.coverage", "sphinx.ext.mathjax", "sphinx.ext.ifconfig", "sphinx.ext.viewcode", # 'sphinx.ext.githubpages', ] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # Enable Markdown source_parsers = {".md": CommonMarkParser} source_suffix = [".rst", ".md"] # source_suffix = '.rst' # The master toctree document. master_doc = "index" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. pygments_style = None # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "alabaster" # html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = { "github_user": "clarketm", "github_repo": "mergedeep", "github_type": "star", "github_banner": "forkme_right_red_aa0000.png", "show_powered_by": False, } # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # # html_sidebars = {} html_sidebars = {"**": ["about.html", "localtoc.html", "searchbox.html"]} # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = "mergedeepdoc" # -- Options for LaTeX output ------------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, "mergedeep.tex", "mergedeep Documentation", "Travis Clarke", "manual") ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, "mergedeep", "mergedeep Documentation", [author], 1)] # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, "mergedeep", "mergedeep Documentation", author, "mergedeep", "One line description of project.", "Miscellaneous", ) ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ["search.html"] # -- Extension configuration ------------------------------------------------- # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {"https://docs.python.org/": None} # -- Options for todo extension ---------------------------------------------- # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True # -- Options for todo extension ---------------------------------------------- class PatchedAutoStructify(AutoStructify, object): """AutoStructify by default can't handle contents directives.""" def patched_nested_parse(self, *args, **kwargs): """Sets match_titles then calls stored_nested_parse.""" kwargs["match_titles"] = True return self.stored_nested_parse(*args, **kwargs) def auto_code_block(self, *args, **kwargs): """Modified auto_code_block that patches nested_parse.""" self.stored_nested_parse = self.state_machine.state.nested_parse self.state_machine.state.nested_parse = self.patched_nested_parse try: return super(PatchedAutoStructify, self).auto_code_block(*args, **kwargs) finally: self.state_machine.state.nested_parse = self.stored_nested_parse def setup(app): app.add_config_value( "recommonmark_config", { "enable_auto_toc_tree": False, "enable_inline_math": False, "enable_auto_doc_ref": False, }, True, ) app.add_transform(PatchedAutoStructify) mergedeep-1.3.4/docs/source/index.md000066400000000000000000000064511400731216200173370ustar00rootroot00000000000000```eval_rst .. meta:: :description: mergedeep: A deep merge function for 🐍. .. title:: mergedeep ``` # [mergedeep](https://pypi.org/project/mergedeep/) ```eval_rst Version |version| .. image:: https://img.shields.io/pypi/v/mergedeep.svg :target: https://pypi.org/project/mergedeep/ .. image:: https://img.shields.io/pypi/pyversions/mergedeep.svg :target: https://pypi.org/project/mergedeep/ .. image:: https://pepy.tech/badge/mergedeep :target: https://pepy.tech/project/mergedeep ``` **A deep merge function for 🐍.** ## Installation ```bash $ pip install mergedeep ``` ## Usage ```text merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping ``` Deep merge without mutating the source dicts. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` Deep merge into an existing dict. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merge(a, b, c) print(a) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` ### Merge strategies: * Replace (*default*) > `Strategy.REPLACE` ```python3 # When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default). # Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": [3, 4]} merge(dst, src, strategy=Strategy.REPLACE) # same as: merge(dst, src) print(dst) # {"key": [3, 4]} ``` * Additive > `Strategy.ADDITIVE` ```python3 # When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`. # Additive collection types include: `list`, `tuple`, `set`, and `Counter` # Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})} src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})} merge(dst, src, strategy=Strategy.ADDITIVE) print(dst) # {"key": [1, 2, 3, 4], "count": Counter({"a": 2, "b": 1, "c": 1})} ``` * Typesafe replace > `Strategy.TYPESAFE_REPLACE` or `Strategy.TYPESAFE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_REPLACE) # same as: `Strategy.TYPESAFE` # TypeError: destination type: differs from source type: for key: "key" ``` * Typesafe additive > `Strategy.TYPESAFE_ADDITIVE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `ADDITIVE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_ADDITIVE) # TypeError: destination type: differs from source type: for key: "key" ``` ## License MIT © [**Travis Clarke**](https://blog.travismclarke.com/) mergedeep-1.3.4/example.py000066400000000000000000000002771400731216200154630ustar00rootroot00000000000000from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} mergedeep-1.3.4/mergedeep/000077500000000000000000000000001400731216200154055ustar00rootroot00000000000000mergedeep-1.3.4/mergedeep/__init__.py000066400000000000000000000001501400731216200175120ustar00rootroot00000000000000__version__ = "1.3.4" from mergedeep.mergedeep import merge, Strategy __all__ = ["merge", "Strategy"] mergedeep-1.3.4/mergedeep/mergedeep.py000077500000000000000000000104101400731216200177130ustar00rootroot00000000000000from collections import Counter from collections.abc import Mapping from copy import deepcopy from enum import Enum from functools import reduce, partial from typing import MutableMapping class Strategy(Enum): # Replace `destination` item with one from `source` (default). REPLACE = 0 # Combine `list`, `tuple`, `set`, or `Counter` types into one collection. ADDITIVE = 1 # Alias to: `TYPESAFE_REPLACE` TYPESAFE = 2 # Raise `TypeError` when `destination` and `source` types differ. Otherwise, perform a `REPLACE` merge. TYPESAFE_REPLACE = 3 # Raise `TypeError` when `destination` and `source` types differ. Otherwise, perform a `ADDITIVE` merge. TYPESAFE_ADDITIVE = 4 def _handle_merge_replace(destination, source, key): if isinstance(destination[key], Counter) and isinstance(source[key], Counter): # Merge both destination and source `Counter` as if they were a standard dict. _deepmerge(destination[key], source[key]) else: # If a key exists in both objects and the values are `different`, the value from the `source` object will be used. destination[key] = deepcopy(source[key]) def _handle_merge_additive(destination, source, key): # Values are combined into one long collection. if isinstance(destination[key], list) and isinstance(source[key], list): # Extend destination if both destination and source are `list` type. destination[key].extend(deepcopy(source[key])) elif isinstance(destination[key], set) and isinstance(source[key], set): # Update destination if both destination and source are `set` type. destination[key].update(deepcopy(source[key])) elif isinstance(destination[key], tuple) and isinstance(source[key], tuple): # Update destination if both destination and source are `tuple` type. destination[key] = destination[key] + deepcopy(source[key]) elif isinstance(destination[key], Counter) and isinstance(source[key], Counter): # Update destination if both destination and source are `Counter` type. destination[key].update(deepcopy(source[key])) else: _handle_merge[Strategy.REPLACE](destination, source, key) def _handle_merge_typesafe(destination, source, key, strategy): # Raise a TypeError if the destination and source types differ. if type(destination[key]) is not type(source[key]): raise TypeError( f'destination type: {type(destination[key])} differs from source type: {type(source[key])} for key: "{key}"' ) else: _handle_merge[strategy](destination, source, key) _handle_merge = { Strategy.REPLACE: _handle_merge_replace, Strategy.ADDITIVE: _handle_merge_additive, Strategy.TYPESAFE: partial(_handle_merge_typesafe, strategy=Strategy.REPLACE), Strategy.TYPESAFE_REPLACE: partial(_handle_merge_typesafe, strategy=Strategy.REPLACE), Strategy.TYPESAFE_ADDITIVE: partial(_handle_merge_typesafe, strategy=Strategy.ADDITIVE), } def _is_recursive_merge(a, b): both_mapping = isinstance(a, Mapping) and isinstance(b, Mapping) both_counter = isinstance(a, Counter) and isinstance(b, Counter) return both_mapping and not both_counter def _deepmerge(dst, src, strategy=Strategy.REPLACE): for key in src: if key in dst: if _is_recursive_merge(dst[key], src[key]): # If the key for both `dst` and `src` are both Mapping types (e.g. dict), then recurse. _deepmerge(dst[key], src[key], strategy) elif dst[key] is src[key]: # If a key exists in both objects and the values are `same`, the value from the `dst` object will be used. pass else: _handle_merge.get(strategy)(dst, src, key) else: # If the key exists only in `src`, the value from the `src` object will be used. dst[key] = deepcopy(src[key]) return dst def merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping: """ A deep merge function for 🐍. :param destination: The destination mapping. :param sources: The source mappings. :param strategy: The merge strategy. :return: """ return reduce(partial(_deepmerge, strategy=strategy), sources, destination) mergedeep-1.3.4/mergedeep/test_mergedeep.py000066400000000000000000000324621400731216200207620ustar00rootroot00000000000000"""mergedeep test module""" import inspect import unittest from collections import Counter from copy import deepcopy from mergedeep import merge, Strategy class test_mergedeep(unittest.TestCase): """mergedeep function tests.""" ############################################################################################################################## # REPLACE ############################################################################################################################## def test_should_merge_3_dicts_into_new_dict_using_replace_strategy_and_only_mutate_target(self,): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "f": [4, 5, 6], "g": (100, 200), "h": Counter({"a": 5, "b": 1, "c": 1}), "i": 2, "j": Counter({"z": 2}), "z": Counter({"a": 2}), } a = { "a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": [1, 2, 3], "g": (2, 4, 6), "h": Counter({"a": 1, "b": 1}), "j": 1, } a_copy = deepcopy(a) b = { "a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": [4, 5, 6], "g": (100, 200), "h": Counter({"a": 5, "c": 1}), "i": Counter({"a": 1}), "z": Counter({"a": 2}), } b_copy = deepcopy(b) c = { "a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "i": 2, "j": Counter({"z": 2}), "z": Counter({"a": 2}), } c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.REPLACE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_merge_2_dicts_into_existing_dict_using_replace_strategy_and_only_mutate_target(self,): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "f": [4, 5, 6], "g": (100, 200), "h": Counter({"a": 1, "b": 1, "c": 1}), "i": 2, "j": Counter({"z": 2}), } a = { "a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": [1, 2, 3], "g": (2, 4, 6), "h": Counter({"a": 1, "b": 1}), "j": 1, } a_copy = deepcopy(a) b = { "a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": [4, 5, 6], "g": (100, 200), "h": Counter({"a": 1, "c": 1}), "i": Counter({"a": 1}), } b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "i": 2, "j": Counter({"z": 2})} c_copy = deepcopy(c) actual = merge(a, b, c, strategy=Strategy.REPLACE) self.assertEqual(actual, expected) self.assertEqual(actual, a) self.assertNotEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_have_default_strategy_of_replace(self): func_spec = inspect.getfullargspec(merge) default_strategy = Strategy.REPLACE self.assertEqual(func_spec.kwonlydefaults.get("strategy"), default_strategy) # mock_merge.method.assert_called_with(target, source, strategy=Strategy.REPLACE) ############################################################################################################################## # ADDITIVE ############################################################################################################################## def test_should_merge_3_dicts_into_new_dict_using_additive_strategy_on_lists_and_only_mutate_target(self,): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "f": [1, 2, 3, 4, 5, 6], } a = {"a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": [1, 2, 3]} a_copy = deepcopy(a) b = {"a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": [4, 5, 6]} b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}} c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.ADDITIVE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_merge_3_dicts_into_new_dict_using_additive_strategy_on_sets_and_only_mutate_target(self,): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "f": {1, 2, 3, 4, 5, 6}, } a = {"a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": {1, 2, 3}} a_copy = deepcopy(a) b = {"a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": {4, 5, 6}} b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}} c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.ADDITIVE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_merge_3_dicts_into_new_dict_using_additive_strategy_on_tuples_and_only_mutate_target(self,): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "f": (1, 2, 3, 4, 5, 6), } a = {"a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": (1, 2, 3)} a_copy = deepcopy(a) b = {"a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": (4, 5, 6)} b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}} c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.ADDITIVE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_merge_3_dicts_into_new_dict_using_additive_strategy_on_counters_and_only_mutate_target(self,): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "f": Counter({"a": 2, "c": 1, "b": 1}), "i": 2, "j": Counter({"z": 2}), "z": Counter({"a": 4}), } a = { "a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": Counter({"a": 1, "c": 1}), "i": Counter({"f": 9}), "j": Counter({"a": 1, "z": 4}), } a_copy = deepcopy(a) b = { "a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": Counter({"a": 1, "b": 1}), "j": [1, 2, 3], "z": Counter({"a": 2}), } b_copy = deepcopy(b) c = { "a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}, "i": 2, "j": Counter({"z": 2}), "z": Counter({"a": 2}), } c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.ADDITIVE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_not_copy_references(self): before = 1 after = 99 o1 = {"key1": before} o2 = {"key2": before} expected = {"list": deepcopy([o1, o2]), "tuple": deepcopy((o1, o2))} a = {"list": [o1], "tuple": (o1,)} b = {"list": [o2], "tuple": (o2,)} actual = merge({}, a, b, strategy=Strategy.ADDITIVE) o1["key1"] = after o2["key2"] = after self.assertEqual(actual, expected) # Copied dicts should `not` mutate self.assertEqual(actual["list"][0]["key1"], before) self.assertEqual(actual["list"][1]["key2"], before) self.assertEqual(actual["tuple"][0]["key1"], before) self.assertEqual(actual["tuple"][1]["key2"], before) # Non-copied dicts should mutate self.assertEqual(a["list"][0]["key1"], after) self.assertEqual(b["list"][0]["key2"], after) self.assertEqual(a["tuple"][0]["key1"], after) self.assertEqual(b["tuple"][0]["key2"], after) ############################################################################################################################## # TYPESAFE # TYPESAFE_REPLACE ############################################################################################################################## def test_should_raise_TypeError_using_typesafe_strategy_if_types_differ(self): a = {"a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": [1, 2, 3]} b = {"a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": [4, 5, 6]} c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}} with self.assertRaises(TypeError): merge({}, a, b, c, strategy=Strategy.TYPESAFE) def test_should_raise_TypeError_using_typesafe_replace_strategy_if_types_differ(self,): a = {"a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": [1, 2, 3]} b = {"a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": [4, 5, 6]} c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}} with self.assertRaises(TypeError): merge({}, a, b, c, strategy=Strategy.TYPESAFE_REPLACE) def test_should_merge_3_dicts_into_new_dict_using_typesafe_strategy_and_only_mutate_target_if_types_are_compatible( self, ): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "f": [4, 5, 6], "g": {2, 3, 4}, "h": (1, 3), "z": Counter({"a": 1, "b": 1, "c": 1}), } a = {"a": {"b": {"c": 5}}, "d": 1, "f": [1, 2, 3], "g": {1, 2, 3}, "z": Counter({"a": 1, "b": 1})} a_copy = deepcopy(a) b = {"a": {"B": {"C": 10}}, "d": 2, "f": [4, 5, 6], "g": {2, 3, 4}, "h": (1,)} b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "h": (1, 3), "z": Counter({"a": 1, "c": 1})} c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.TYPESAFE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) def test_should_merge_3_dicts_into_new_dict_using_typesafe_replace_strategy_and_only_mutate_target_if_types_are_compatible( self, ): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "f": [4, 5, 6], "g": {2, 3, 4}, "h": (1, 3), "z": Counter({"a": 1, "b": 1, "c": 1}), } a = {"a": {"b": {"c": 5}}, "d": 1, "f": [1, 2, 3], "g": {1, 2, 3}, "z": Counter({"a": 1, "b": 1})} a_copy = deepcopy(a) b = {"a": {"B": {"C": 10}}, "d": 2, "f": [4, 5, 6], "g": {2, 3, 4}, "h": (1,)} b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "h": (1, 3), "z": Counter({"a": 1, "c": 1})} c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.TYPESAFE_REPLACE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) ############################################################################################################################## # TYPESAFE_ADDITIVE ############################################################################################################################## def test_should_raise_TypeError_using_typesafe_additive_strategy_if_types_differ(self,): a = {"a": {"b": {"c": 5}}, "d": 1, "e": {2: 3}, "f": [1, 2, 3]} b = {"a": {"B": {"C": 10}}, "d": 2, "e": 2, "f": [4, 5, 6]} c = {"a": {"b": {"_c": 15}}, "d": 3, "e": {1: 2, "a": {"f": 2}}} with self.assertRaises(TypeError): merge({}, a, b, c, strategy=Strategy.TYPESAFE_ADDITIVE) def test_should_merge_3_dicts_into_new_dict_using_typesafe_additive_strategy_and_only_mutate_target_if_types_are_compatible( self, ): expected = { "a": {"b": {"c": 5, "_c": 15}, "B": {"C": 10}}, "d": 3, "f": [1, 2, 3, 4, 5, 6], "g": {1, 2, 3, 4}, "h": (1, 1, 3), "z": Counter({"a": 2, "b": 1, "c": 1}), } a = {"a": {"b": {"c": 5}}, "d": 1, "f": [1, 2, 3], "g": {1, 2, 3}, "z": Counter({"a": 1, "b": 1})} a_copy = deepcopy(a) b = {"a": {"B": {"C": 10}}, "d": 2, "f": [4, 5, 6], "g": {2, 3, 4}, "h": (1,)} b_copy = deepcopy(b) c = {"a": {"b": {"_c": 15}}, "d": 3, "h": (1, 3), "z": Counter({"a": 1, "c": 1})} c_copy = deepcopy(c) actual = merge({}, a, b, c, strategy=Strategy.TYPESAFE_ADDITIVE) self.assertEqual(actual, expected) self.assertEqual(a, a_copy) self.assertEqual(b, b_copy) self.assertEqual(c, c_copy) if __name__ == "__main__": unittest.main() mergedeep-1.3.4/py.typed000066400000000000000000000000001400731216200151350ustar00rootroot00000000000000mergedeep-1.3.4/setup.cfg000066400000000000000000000000601400731216200152650ustar00rootroot00000000000000[metadata] version = attr: mergedeep.__version__mergedeep-1.3.4/setup.py000066400000000000000000000020441400731216200151620ustar00rootroot00000000000000import setuptools, os def open_local(paths, mode="r", encoding="utf8"): path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths) return open(path, mode=mode, encoding=encoding) with open_local(["README.md"]) as f: long_description = f.read() setuptools.setup( name="mergedeep", author="Travis Clarke", author_email="travis.m.clarke@gmail.com", description="A deep merge function for 🐍.", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/clarketm/mergedeep", python_requires=">=3.6", packages=setuptools.find_packages(), package_data={"mergedeep": ["py.typed"]}, classifiers=( "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ), ) mergedeep-1.3.4/tox.ini000066400000000000000000000001171400731216200147620ustar00rootroot00000000000000[tox] envlist = py36,py37,py38,py39 [testenv] deps = pytest commands = pytest