MIT
Project description
Patchdiff 🔍
Install
pip install patchdiff
Quick-start
from patchdiff import apply, diff, iapply, to_json
input = {"a": [5, 7, 9, {"a", "b", "c"}], "b": 6}
output = {"a": [5, 2, 9, {"b", "c"}], "b": 6, "c": 7}
ops, reverse_ops = diff(input, output)
assert apply(input, ops) == output
assert apply(output, reverse_ops) == input
iapply(input, ops) # apply in-place
assert input == output
print(to_json(ops, indent=4))
# [
# {
# "op": "add",
# "path": "/c",
# "value": 7
# },
# {
# "op": "replace",
# "path": "/a/1",
# "value": 2
# },
# {
# "op": "remove",
# "path": "/a/3/a"
# }
# ]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
patchdiff-0.3.0.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for patchdiff-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff4a9237e28a8e5ea55b04b537615928c327293af523d517d583348b513e298e |
|
MD5 | 4d1cc6cefdfbaad2152580ae0cac3cde |
|
BLAKE2b-256 | e0c597254bebf3c92c148447a00c6c35e1e974907f8b7278d5dbd5ca9205aba9 |