PySerials 0.0.0.dev25__py3-none-any.whl → 0.0.0.dev26__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.
- {PySerials-0.0.0.dev25.dist-info → PySerials-0.0.0.dev26.dist-info}/METADATA +3 -3
- {PySerials-0.0.0.dev25.dist-info → PySerials-0.0.0.dev26.dist-info}/RECORD +5 -5
- {PySerials-0.0.0.dev25.dist-info → PySerials-0.0.0.dev26.dist-info}/WHEEL +1 -1
- pyserials/update.py +28 -11
- {PySerials-0.0.0.dev25.dist-info → PySerials-0.0.0.dev26.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PySerials
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev26
|
|
4
4
|
Requires-Python: >=3.10
|
|
5
5
|
Requires-Dist: jsonschema <5,>=4.21.0
|
|
6
6
|
Requires-Dist: referencing >=0.35.1
|
|
@@ -8,7 +8,7 @@ Requires-Dist: jsonpath-ng <2,>=1.6.1
|
|
|
8
8
|
Requires-Dist: ruamel.yaml <0.18,>=0.17.32
|
|
9
9
|
Requires-Dist: ruamel.yaml.string <1,>=0.1.1
|
|
10
10
|
Requires-Dist: tomlkit <0.12,>=0.11.8
|
|
11
|
-
Requires-Dist: MDit ==0.0.0.
|
|
12
|
-
Requires-Dist: ExceptionMan ==0.0.0.
|
|
11
|
+
Requires-Dist: MDit ==0.0.0.dev23
|
|
12
|
+
Requires-Dist: ExceptionMan ==0.0.0.dev23
|
|
13
13
|
Requires-Dist: ProtocolMan ==0.0.0.dev2
|
|
14
14
|
|
|
@@ -3,7 +3,7 @@ pyserials/compare.py,sha256=j62A1UIiAm08_xONlbZmU2EcH1GMEpDyEQH66dZ2YMM,1297
|
|
|
3
3
|
pyserials/format.py,sha256=dTukpab6WHSyVRQ9SteY5fhr3GFjWFboEl-1cw_udVY,1729
|
|
4
4
|
pyserials/nested_dict.py,sha256=8cPs4LykXh4stFpaLINPjrAeSyaOyyTdhg0FZZ2YOYA,3361
|
|
5
5
|
pyserials/read.py,sha256=uucYQH1V4GStwRgRZ2eQIXkH4ukB5qz0EA885grwi68,6592
|
|
6
|
-
pyserials/update.py,sha256=
|
|
6
|
+
pyserials/update.py,sha256=rYf-wFQaqyEu5gbJ9a3P1_w0nQpTpUk4KwaRpmsXtLI,9968
|
|
7
7
|
pyserials/validate.py,sha256=ti0D_yLzB_HELvf1d5qrarx1Ac-opBMN1Xh5lADRAQU,3664
|
|
8
8
|
pyserials/write.py,sha256=pN8w78qVsKJjZd_jvPUcZjYp_RJkP7uQzpiXvPOv4lM,1776
|
|
9
9
|
pyserials/exception/__init__.py,sha256=ZhbggwJUMlTyBhifAivC8ZQxP1Na6lJAwzZs7_YjOSU,151
|
|
@@ -11,7 +11,7 @@ pyserials/exception/_base.py,sha256=IdaZwBPBYgiUaWnvN0eMXvQQBqLbN1t766034CK7Hlc,
|
|
|
11
11
|
pyserials/exception/read.py,sha256=QyG6ulExXH9u8oDRjUfter70SMDVQqL4nig5s-JzWN4,9252
|
|
12
12
|
pyserials/exception/update.py,sha256=P0js2-iY2fgO_KLdqedgWE3TTS5Xz15cusZY_wuKIW4,4222
|
|
13
13
|
pyserials/exception/validate.py,sha256=7UkQEEqCa8HJ20gpTFnLDhT3P5OPLD2oD9fUK2Jcuns,7466
|
|
14
|
-
PySerials-0.0.0.
|
|
15
|
-
PySerials-0.0.0.
|
|
16
|
-
PySerials-0.0.0.
|
|
17
|
-
PySerials-0.0.0.
|
|
14
|
+
PySerials-0.0.0.dev26.dist-info/METADATA,sha256=Uqw0SeAg3Byf11FqeJOlQS-pCWx7pfuCoYzprl25bvk,438
|
|
15
|
+
PySerials-0.0.0.dev26.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
16
|
+
PySerials-0.0.0.dev26.dist-info/top_level.txt,sha256=SAks7WjSjdkv3i9Hvt4gY_P7VQbhhYJN5mf5dqx1aao,10
|
|
17
|
+
PySerials-0.0.0.dev26.dist-info/RECORD,,
|
pyserials/update.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from __future__ import annotations as _annotations
|
|
2
|
+
from typing import TYPE_CHECKING as _TYPE_CHECKING
|
|
2
3
|
import re as _re
|
|
3
4
|
|
|
4
5
|
import jsonpath_ng as _jsonpath
|
|
@@ -6,6 +7,9 @@ from jsonpath_ng import exceptions as _jsonpath_exceptions
|
|
|
6
7
|
|
|
7
8
|
import pyserials.exception as _exception
|
|
8
9
|
|
|
10
|
+
if _TYPE_CHECKING:
|
|
11
|
+
from typing import Literal, Callable
|
|
12
|
+
|
|
9
13
|
|
|
10
14
|
def dict_from_addon(
|
|
11
15
|
data: dict,
|
|
@@ -18,7 +22,7 @@ def dict_from_addon(
|
|
|
18
22
|
"""Recursively update a dictionary from another dictionary."""
|
|
19
23
|
def recursive(source: dict, add: dict, path: str, log: dict):
|
|
20
24
|
|
|
21
|
-
def raise_error(typ:
|
|
25
|
+
def raise_error(typ: Literal["duplicate", "type_mismatch"]):
|
|
22
26
|
raise _exception.update.PySerialsUpdateDictFromAddonError(
|
|
23
27
|
problem_type=typ,
|
|
24
28
|
path=fullpath,
|
|
@@ -89,15 +93,23 @@ class TemplateFiller:
|
|
|
89
93
|
self,
|
|
90
94
|
marker_start: str = "${{",
|
|
91
95
|
marker_end: str = "}}",
|
|
96
|
+
marker_start_unpack: str = "*{{",
|
|
97
|
+
marker_end_unpack: str = "}}",
|
|
92
98
|
implicit_root: bool = True,
|
|
99
|
+
stringer: Callable[[str], str] = str,
|
|
93
100
|
):
|
|
101
|
+
def make_regex(start, end):
|
|
102
|
+
start_esc = _re.escape(start)
|
|
103
|
+
end_esc = _re.escape(end)
|
|
104
|
+
regex_sub = rf"{start_esc}([^{end_esc}]+){end_esc}"
|
|
105
|
+
return _re.compile(regex_sub)
|
|
106
|
+
|
|
94
107
|
self._marker_start = marker_start
|
|
95
108
|
self._marker_end = marker_end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
regex_sub = rf"{start}([^{end}]+){end}"
|
|
99
|
-
self._pattern_template = _re.compile(regex_sub)
|
|
109
|
+
self._pattern_template = make_regex(marker_start, marker_end)
|
|
110
|
+
self._pattern_template_unpack = make_regex(marker_start_unpack, marker_end_unpack)
|
|
100
111
|
self._add_prefix = implicit_root
|
|
112
|
+
self._stringer = stringer
|
|
101
113
|
self._data = None
|
|
102
114
|
self._source = None
|
|
103
115
|
self._recursive = None
|
|
@@ -211,15 +223,20 @@ class TemplateFiller:
|
|
|
211
223
|
if match_whole_str:
|
|
212
224
|
return get_address_value(match_whole_str)
|
|
213
225
|
return self._pattern_template.sub(
|
|
214
|
-
lambda x:
|
|
226
|
+
lambda x: self._stringer(get_address_value(x)),
|
|
215
227
|
templ
|
|
216
228
|
)
|
|
217
229
|
if isinstance(templ, list):
|
|
218
|
-
|
|
219
|
-
|
|
230
|
+
out = []
|
|
231
|
+
for idx, elem in enumerate(templ):
|
|
232
|
+
elem_filled = self._recursive_subst(
|
|
220
233
|
elem, f"{current_path}[{idx}]", always_list
|
|
221
|
-
)
|
|
222
|
-
|
|
234
|
+
)
|
|
235
|
+
if self._pattern_template_unpack.fullmatch(elem):
|
|
236
|
+
out.extend(elem_filled)
|
|
237
|
+
else:
|
|
238
|
+
out.append(elem_filled)
|
|
239
|
+
return out
|
|
223
240
|
if isinstance(templ, dict):
|
|
224
241
|
new_dict = {}
|
|
225
242
|
for key, val in templ.items():
|
|
File without changes
|