MIT
Project description
Patchdiff 🔍
Based on rfc6902 this library provides a simple API to generate bi-directional diffs between composite python datastructures composed out of lists, sets, tuples and dicts. The diffs are jsonpatch compliant, and can optionally be serialized to json format. Patchdiff can also be used to apply lists of patches to objects, both in-place or on a deepcopy of the input.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patchdiff-0.3.7.tar.gz.
File metadata
- Download URL: patchdiff-0.3.7.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfa4699aa416a9e4e838ddf9368c18281b8b7db771fe3b9c2171fbcd6597580e
|
|
| MD5 |
68c4a6f4a1fe2d467d95552927caa964
|
|
| BLAKE2b-256 |
5e751bc2ba493d94be2cb00425ca01fa1bdad5084dbcd9497641331bae198953
|
Provenance
The following attestation bundles were made for patchdiff-0.3.7.tar.gz:
Publisher:
ci.yml on fork-tongue/patchdiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
patchdiff-0.3.7.tar.gz -
Subject digest:
dfa4699aa416a9e4e838ddf9368c18281b8b7db771fe3b9c2171fbcd6597580e - Sigstore transparency entry: 763990691
- Sigstore integration time:
-
Permalink:
fork-tongue/patchdiff@b895e58bbc6f806876bba19f7caa7e9e6a217e8a -
Branch / Tag:
refs/tags/v0.3.7 - Owner: https://github.com/fork-tongue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b895e58bbc6f806876bba19f7caa7e9e6a217e8a -
Trigger Event:
push
-
Statement type:
File details
Details for the file patchdiff-0.3.7-py3-none-any.whl.
File metadata
- Download URL: patchdiff-0.3.7-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9c5890f0bd94a60ad2244963c25082558547dfcd8e55ec02cca9b6b1f7652dc
|
|
| MD5 |
8ac2b91958a825f271381c46a2ee7e61
|
|
| BLAKE2b-256 |
8072fea7fecf2c77fecff074bf57e4b8cd3dc8275e1e8b351d4e24464fad3f13
|
Provenance
The following attestation bundles were made for patchdiff-0.3.7-py3-none-any.whl:
Publisher:
ci.yml on fork-tongue/patchdiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
patchdiff-0.3.7-py3-none-any.whl -
Subject digest:
b9c5890f0bd94a60ad2244963c25082558547dfcd8e55ec02cca9b6b1f7652dc - Sigstore transparency entry: 763990693
- Sigstore integration time:
-
Permalink:
fork-tongue/patchdiff@b895e58bbc6f806876bba19f7caa7e9e6a217e8a -
Branch / Tag:
refs/tags/v0.3.7 - Owner: https://github.com/fork-tongue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b895e58bbc6f806876bba19f7caa7e9e6a217e8a -
Trigger Event:
push
-
Statement type: