PySerials 0.0.0.dev48__tar.gz → 0.0.0.dev49__tar.gz
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.dev48 → pyserials-0.0.0.dev49}/PKG-INFO +3 -3
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/pyproject.toml +3 -3
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/PySerials.egg-info/PKG-INFO +3 -3
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/PySerials.egg-info/requires.txt +2 -2
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/exception/update.py +2 -1
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/update.py +21 -2
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/write.py +19 -2
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/README.md +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/setup.cfg +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/PySerials.egg-info/SOURCES.txt +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/PySerials.egg-info/dependency_links.txt +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/PySerials.egg-info/not-zip-safe +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/PySerials.egg-info/top_level.txt +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/__init__.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/compare.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/exception/__init__.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/exception/_base.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/exception/read.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/exception/validate.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/format.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/nested_dict.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/property_dict.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/read.py +0 -0
- {pyserials-0.0.0.dev48 → pyserials-0.0.0.dev49}/src/pyserials/validate.py +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.dev49
|
|
4
4
|
Requires-Python: >=3.10
|
|
5
5
|
Requires-Dist: jsonschema<5,>=4.21.0
|
|
6
6
|
Requires-Dist: referencing>=0.35.1
|
|
@@ -8,6 +8,6 @@ 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.dev46
|
|
12
|
+
Requires-Dist: ExceptionMan==0.0.0.dev46
|
|
13
13
|
Requires-Dist: ProtocolMan==0.0.0.dev2
|
|
@@ -17,7 +17,7 @@ namespaces = true
|
|
|
17
17
|
# ----------------------------------------- Project Metadata -------------------------------------
|
|
18
18
|
#
|
|
19
19
|
[project]
|
|
20
|
-
version = "0.0.0.
|
|
20
|
+
version = "0.0.0.dev49"
|
|
21
21
|
name = "PySerials"
|
|
22
22
|
dependencies = [
|
|
23
23
|
"jsonschema >= 4.21.0, < 5",
|
|
@@ -26,8 +26,8 @@ dependencies = [
|
|
|
26
26
|
"ruamel.yaml >= 0.17.32, < 0.18", # https://yaml.readthedocs.io/en/stable/
|
|
27
27
|
"ruamel.yaml.string >= 0.1.1, < 1",
|
|
28
28
|
"tomlkit >= 0.11.8, < 0.12", # https://tomlkit.readthedocs.io/en/stable/,
|
|
29
|
-
"MDit == 0.0.0.
|
|
30
|
-
"ExceptionMan == 0.0.0.
|
|
29
|
+
"MDit == 0.0.0.dev46",
|
|
30
|
+
"ExceptionMan == 0.0.0.dev46",
|
|
31
31
|
"ProtocolMan == 0.0.0.dev2",
|
|
32
32
|
]
|
|
33
33
|
requires-python = ">=3.10"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PySerials
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev49
|
|
4
4
|
Requires-Python: >=3.10
|
|
5
5
|
Requires-Dist: jsonschema<5,>=4.21.0
|
|
6
6
|
Requires-Dist: referencing>=0.35.1
|
|
@@ -8,6 +8,6 @@ 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.dev46
|
|
12
|
+
Requires-Dist: ExceptionMan==0.0.0.dev46
|
|
13
13
|
Requires-Dist: ProtocolMan==0.0.0.dev2
|
|
@@ -128,7 +128,8 @@ class PySerialsUpdateTemplatedDataError(PySerialsUpdateException):
|
|
|
128
128
|
self.template_start = template_start
|
|
129
129
|
self.template_end = template_end
|
|
130
130
|
parts = description_template.split("{path_invalid}")
|
|
131
|
-
|
|
131
|
+
if len(parts) > 1:
|
|
132
|
+
parts.insert(1, _mdit.element.code_span(self.path_invalid))
|
|
132
133
|
super().__init__(
|
|
133
134
|
path=path.replace("'", ""),
|
|
134
135
|
data=data,
|
|
@@ -152,6 +152,7 @@ class TemplateFiller:
|
|
|
152
152
|
|
|
153
153
|
self._pattern_value: dict[int, _RegexPattern] = {}
|
|
154
154
|
self._data = None
|
|
155
|
+
self._visited_paths = set()
|
|
155
156
|
return
|
|
156
157
|
|
|
157
158
|
def fill(
|
|
@@ -161,6 +162,7 @@ class TemplateFiller:
|
|
|
161
162
|
current_path: str = "",
|
|
162
163
|
):
|
|
163
164
|
self._data = data
|
|
165
|
+
self._visited_paths = set()
|
|
164
166
|
path = (f"$.{current_path}" if self._add_prefix else current_path) if current_path else "$"
|
|
165
167
|
return self._recursive_subst(
|
|
166
168
|
templ=template or data,
|
|
@@ -198,13 +200,15 @@ class TemplateFiller:
|
|
|
198
200
|
local_context = {}
|
|
199
201
|
try:
|
|
200
202
|
exec(code_str_full, global_context, local_context)
|
|
201
|
-
|
|
203
|
+
output = local_context["__inline_code__"]()
|
|
202
204
|
except Exception as e:
|
|
203
205
|
raise_error(
|
|
204
206
|
description_template=f"Code at {{path_invalid}} raised an exception: {e}\n{code_str_full}",
|
|
205
207
|
path_invalid=current_path,
|
|
206
208
|
exception=e,
|
|
207
209
|
)
|
|
210
|
+
self._visited_paths.add(self._normalize_path(current_path))
|
|
211
|
+
return output
|
|
208
212
|
|
|
209
213
|
def get_address_value(match: _re.Match | str, return_all_matches: bool = False, from_code: bool = False):
|
|
210
214
|
raw_path = match if isinstance(match, str) else str(match.group(1))
|
|
@@ -238,6 +242,7 @@ class TemplateFiller:
|
|
|
238
242
|
root_path_expr = root_path_expr.left
|
|
239
243
|
path_expr = self._concat_json_paths(root_path_expr, path_expr)
|
|
240
244
|
value, matched = get_value(path_expr, return_all_matches, from_code)
|
|
245
|
+
self._visited_paths.add(self._normalize_path(current_path))
|
|
241
246
|
if from_code:
|
|
242
247
|
return value, matched
|
|
243
248
|
if matched:
|
|
@@ -337,6 +342,8 @@ class TemplateFiller:
|
|
|
337
342
|
) from exception
|
|
338
343
|
|
|
339
344
|
self._check_endless_loop(templ, current_chain)
|
|
345
|
+
# if self._normalize_path(current_path) in self._visited_paths:
|
|
346
|
+
# return templ
|
|
340
347
|
|
|
341
348
|
if isinstance(templ, str):
|
|
342
349
|
# Handle value blocks
|
|
@@ -393,9 +400,16 @@ class TemplateFiller:
|
|
|
393
400
|
current_chain=current_chain + [new_path],
|
|
394
401
|
)
|
|
395
402
|
if isinstance(elem, str) and self._pattern_unpack.fullmatch(elem):
|
|
396
|
-
|
|
403
|
+
try:
|
|
404
|
+
out.extend(elem_filled)
|
|
405
|
+
except TypeError as e:
|
|
406
|
+
raise_error(
|
|
407
|
+
path_invalid=current_path,
|
|
408
|
+
description_template=str(e)
|
|
409
|
+
)
|
|
397
410
|
else:
|
|
398
411
|
out.append(elem_filled)
|
|
412
|
+
self._visited_paths.add(self._normalize_path(current_path))
|
|
399
413
|
return out
|
|
400
414
|
|
|
401
415
|
if isinstance(templ, dict):
|
|
@@ -422,6 +436,7 @@ class TemplateFiller:
|
|
|
422
436
|
level=0,
|
|
423
437
|
current_chain=current_chain + [new_path],
|
|
424
438
|
)
|
|
439
|
+
self._visited_paths.add(self._normalize_path(current_path))
|
|
425
440
|
return new_dict
|
|
426
441
|
return templ
|
|
427
442
|
|
|
@@ -480,6 +495,10 @@ class TemplateFiller:
|
|
|
480
495
|
_recursive_extract(jsonpath)
|
|
481
496
|
return fields
|
|
482
497
|
|
|
498
|
+
@staticmethod
|
|
499
|
+
def _normalize_path(path: str) -> str:
|
|
500
|
+
return path.replace("'", "")
|
|
501
|
+
|
|
483
502
|
def _concat_json_paths(self, path1, path2):
|
|
484
503
|
if not isinstance(path2, _jsonpath.Child):
|
|
485
504
|
return _jsonpath.Child(path1, path2)
|
|
@@ -2,6 +2,7 @@ from typing import Literal as _Literal
|
|
|
2
2
|
from pathlib import Path as _Path
|
|
3
3
|
import json as _json
|
|
4
4
|
import ruamel.yaml as _yaml
|
|
5
|
+
from ruamel.yaml import scalarstring as _yaml_scalar_string
|
|
5
6
|
import tomlkit as _tomlkit
|
|
6
7
|
|
|
7
8
|
|
|
@@ -22,8 +23,16 @@ def to_string(
|
|
|
22
23
|
def to_yaml_string(
|
|
23
24
|
data: dict | list | str | int | float | bool | _yaml.CommentedMap | _yaml.CommentedSeq,
|
|
24
25
|
end_of_file_newline: bool = True,
|
|
26
|
+
indent_mapping: int = 2,
|
|
27
|
+
indent_sequence: int = 4,
|
|
28
|
+
indent_sequence_offset: int = 2,
|
|
29
|
+
multiline_string_to_block: bool = True,
|
|
25
30
|
) -> str:
|
|
26
|
-
|
|
31
|
+
yaml = _yaml.YAML(typ=["rt", "string"])
|
|
32
|
+
yaml.indent(mapping=indent_mapping, sequence=indent_sequence, offset=indent_sequence_offset)
|
|
33
|
+
if multiline_string_to_block:
|
|
34
|
+
_yaml_scalar_string.walk_tree(data)
|
|
35
|
+
yaml_syntax = yaml.dumps(data, add_final_eol=False).removesuffix("\n...")
|
|
27
36
|
return f"{yaml_syntax}\n" if end_of_file_newline else yaml_syntax
|
|
28
37
|
|
|
29
38
|
|
|
@@ -46,9 +55,17 @@ def to_yaml_file(
|
|
|
46
55
|
data: dict | list | str | int | float | bool | _yaml.CommentedMap | _yaml.CommentedSeq,
|
|
47
56
|
path: str | _Path,
|
|
48
57
|
make_dirs: bool = True,
|
|
58
|
+
indent_mapping: int = 2,
|
|
59
|
+
indent_sequence: int = 4,
|
|
60
|
+
indent_sequence_offset: int = 2,
|
|
61
|
+
multiline_string_to_block: bool = True,
|
|
49
62
|
):
|
|
50
63
|
path = _Path(path).resolve()
|
|
51
64
|
if make_dirs:
|
|
52
65
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
53
|
-
_yaml.YAML()
|
|
66
|
+
yaml = _yaml.YAML()
|
|
67
|
+
yaml.indent(mapping=indent_mapping, sequence=indent_sequence, offset=indent_sequence_offset)
|
|
68
|
+
if multiline_string_to_block:
|
|
69
|
+
_yaml_scalar_string.walk_tree(data)
|
|
70
|
+
yaml.dump(data, path)
|
|
54
71
|
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|