patchdiff 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
patchdiff/__init__.py CHANGED
@@ -2,4 +2,4 @@ from .apply import apply, iapply
2
2
  from .diff import diff
3
3
  from .serialize import to_json
4
4
 
5
- __version__ = "0.3.3"
5
+ __version__ = "0.3.4"
patchdiff/diff.py CHANGED
@@ -71,13 +71,13 @@ def diff_lists(input: List, output: List, ptr: Pointer) -> Tuple[List, List]:
71
71
  "path": ptr.append(idx_token),
72
72
  "value": op["value"],
73
73
  }
74
- return [ops + [full_op], padding + 1]
74
+ return [[*ops, full_op], padding + 1]
75
75
  elif op["op"] == "remove":
76
76
  full_op = {
77
77
  "op": "remove",
78
78
  "path": ptr.append(op["idx"] + padding),
79
79
  }
80
- return [ops + [full_op], padding - 1]
80
+ return [[*ops, full_op], padding - 1]
81
81
  else:
82
82
  replace_ptr = ptr.append(op["idx"] + padding)
83
83
  replace_ops, _ = diff(op["original"], op["value"], replace_ptr)
@@ -96,7 +96,7 @@ def diff_dicts(input: Dict, output: Dict, ptr: Pointer) -> Tuple[List, List]:
96
96
  output_keys = set(output.keys())
97
97
  for key in input_keys - output_keys:
98
98
  ops.append({"op": "remove", "path": ptr.append(key)})
99
- rops.insert(0, {"op": "add", "path": ptr.append(key), "value": output[key]})
99
+ rops.insert(0, {"op": "add", "path": ptr.append(key), "value": input[key]})
100
100
  for key in output_keys - input_keys:
101
101
  ops.append(
102
102
  {
patchdiff/pointer.py CHANGED
@@ -1,9 +1,10 @@
1
+ from __future__ import annotations
2
+
1
3
  import re
2
4
  from typing import Any, Hashable, List, Tuple
3
5
 
4
6
  from .types import Diffable
5
7
 
6
-
7
8
  tilde0_re = re.compile("~0")
8
9
  tilde1_re = re.compile("~1")
9
10
  tilde_re = re.compile("~")
@@ -19,21 +20,21 @@ def escape(token: str) -> str:
19
20
 
20
21
 
21
22
  class Pointer:
22
- def __init__(self, tokens: List[Hashable] = None) -> None:
23
+ def __init__(self, tokens: List[Hashable] | None = None) -> None:
23
24
  if tokens is None:
24
25
  tokens = []
25
- self.tokens = tokens
26
+ self.tokens = tuple(tokens)
26
27
 
27
28
  @staticmethod
28
29
  def from_str(path: str) -> "Pointer":
29
- tokens = [unescape(t) for t in path.split("/")]
30
+ tokens = [unescape(t) for t in path.split("/")[1:]]
30
31
  return Pointer(tokens)
31
32
 
32
33
  def __str__(self) -> str:
33
34
  return "/" + "/".join(escape(str(t)) for t in self.tokens)
34
35
 
35
36
  def __repr__(self) -> str:
36
- return f"Pointer({repr(self.tokens)})"
37
+ return f"Pointer({list(self.tokens)!r})"
37
38
 
38
39
  def __hash__(self) -> int:
39
40
  return hash(self.tokens)
@@ -62,4 +63,4 @@ class Pointer:
62
63
 
63
64
  def append(self, token: Hashable) -> "Pointer":
64
65
  """append, creating new Pointer"""
65
- return Pointer(self.tokens + [token])
66
+ return Pointer((*self.tokens, token))
patchdiff/types.py CHANGED
@@ -1,3 +1,3 @@
1
- from typing import Dict, List, Set, Tuple, Union
1
+ from typing import Dict, List, Set, Union
2
2
 
3
- Diffable = Union[Dict, List, Set, Tuple]
3
+ Diffable = Union[Dict, List, Set]
@@ -1,20 +1,14 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: patchdiff
3
- Version: 0.3.3
3
+ Version: 0.3.5
4
4
  Summary: MIT
5
- Home-page: https://github.com/Korijn/patchdiff
6
- Author: Korijn van Golen
7
- Author-email: korijn@gmail.com
8
- Requires-Python: >=3.7
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.10
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
5
+ Project-URL: Homepage, https://github.com/fork-tongue/patchdiff
6
+ Author-email: Korijn van Golen <korijn@gmail.com>, Berend Klein Haneveld <berendkleinhaneveld@gmail.com>
7
+ Requires-Python: >=3.8
14
8
  Description-Content-Type: text/markdown
15
9
 
16
10
  [![PyPI version](https://badge.fury.io/py/patchdiff.svg)](https://badge.fury.io/py/patchdiff)
17
- [![CI status](https://github.com/Korijn/patchdiff/workflows/CI/badge.svg)](https://github.com/Korijn/patchdiff/actions)
11
+ [![CI status](https://github.com/fork-tongue/patchdiff/workflows/CI/badge.svg)](https://github.com/fork-tongue/patchdiff/actions)
18
12
 
19
13
  # Patchdiff 🔍
20
14
 
@@ -58,4 +52,3 @@ print(to_json(ops, indent=4))
58
52
  # }
59
53
  # ]
60
54
  ```
61
-
@@ -0,0 +1,9 @@
1
+ patchdiff/__init__.py,sha256=uQAwiWM9rTop0zZC6Spn0y_v74cfAzuhCxcEFOrAaXY,110
2
+ patchdiff/apply.py,sha256=25TfOTZTYFIjy70mBus5yCzmbJRawbguDffv_4yHjqE,1366
3
+ patchdiff/diff.py,sha256=AQuIhGDnZda-9IykepEHXcfrDJSEJPXuGe8SdLQoquU,5424
4
+ patchdiff/pointer.py,sha256=ZZqJtGYM2uK6P2saOBn0LWxpIb_qgdTFlcE4EQncnRU,1804
5
+ patchdiff/serialize.py,sha256=N0S9e0P49TBMb7ghM--h13MsF59ybiscjZ_auAErTq8,295
6
+ patchdiff/types.py,sha256=BVKXOl3tnQOOml3VI_epTrLn79agi6sD5vNr2acC-yE,77
7
+ patchdiff-0.3.5.dist-info/METADATA,sha256=pea0_lmfx8Y5g5RMNpQGfSJWfQiDQQHFv_yybEQUMkg,1634
8
+ patchdiff-0.3.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ patchdiff-0.3.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry 1.0.7
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- patchdiff/__init__.py,sha256=tbInajLj-9P4K6vxtAKIYq5vicOdacXqP-AMmgV2hkQ,110
2
- patchdiff/apply.py,sha256=25TfOTZTYFIjy70mBus5yCzmbJRawbguDffv_4yHjqE,1366
3
- patchdiff/diff.py,sha256=fQj-2Do6tCivC2W0Y-viCpjCKF3IENh4eBi-SaXSHHI,5425
4
- patchdiff/pointer.py,sha256=GLRt7jMNGhT8GOb3VI5ouzihTBlkO8rdFnX4juX8y3Y,1749
5
- patchdiff/serialize.py,sha256=N0S9e0P49TBMb7ghM--h13MsF59ybiscjZ_auAErTq8,295
6
- patchdiff/types.py,sha256=h-M4VBfJKWfo_kLrTBsqtnHQfl2_FLtbnknOpflgfRg,91
7
- patchdiff-0.3.3.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
8
- patchdiff-0.3.3.dist-info/METADATA,sha256=AeSzfQVS0fMa00jFHT_Snh7Z1pjKJRicybjlMBByLaY,1808
9
- patchdiff-0.3.3.dist-info/RECORD,,