PySerials 0.0.0.dev50__tar.gz → 0.0.0.dev52__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.
Files changed (24) hide show
  1. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/PKG-INFO +3 -3
  2. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/pyproject.toml +3 -3
  3. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/PySerials.egg-info/PKG-INFO +3 -3
  4. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/PySerials.egg-info/requires.txt +2 -2
  5. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/update.py +52 -43
  6. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/README.md +0 -0
  7. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/setup.cfg +0 -0
  8. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/PySerials.egg-info/SOURCES.txt +0 -0
  9. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/PySerials.egg-info/dependency_links.txt +0 -0
  10. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/PySerials.egg-info/not-zip-safe +0 -0
  11. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/PySerials.egg-info/top_level.txt +0 -0
  12. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/__init__.py +0 -0
  13. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/compare.py +0 -0
  14. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/exception/__init__.py +0 -0
  15. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/exception/_base.py +0 -0
  16. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/exception/read.py +0 -0
  17. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/exception/update.py +0 -0
  18. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/exception/validate.py +0 -0
  19. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/format.py +0 -0
  20. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/nested_dict.py +0 -0
  21. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/property_dict.py +0 -0
  22. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/read.py +0 -0
  23. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/validate.py +0 -0
  24. {pyserials-0.0.0.dev50 → pyserials-0.0.0.dev52}/src/pyserials/write.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySerials
3
- Version: 0.0.0.dev50
3
+ Version: 0.0.0.dev52
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.dev47
12
- Requires-Dist: ExceptionMan==0.0.0.dev47
11
+ Requires-Dist: MDit==0.0.0.dev49
12
+ Requires-Dist: ExceptionMan==0.0.0.dev49
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.dev50"
20
+ version = "0.0.0.dev52"
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.dev47",
30
- "ExceptionMan == 0.0.0.dev47",
29
+ "MDit == 0.0.0.dev49",
30
+ "ExceptionMan == 0.0.0.dev49",
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.dev50
3
+ Version: 0.0.0.dev52
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.dev47
12
- Requires-Dist: ExceptionMan==0.0.0.dev47
11
+ Requires-Dist: MDit==0.0.0.dev49
12
+ Requires-Dist: ExceptionMan==0.0.0.dev49
13
13
  Requires-Dist: ProtocolMan==0.0.0.dev2
@@ -4,6 +4,6 @@ jsonpath-ng<2,>=1.6.1
4
4
  ruamel.yaml<0.18,>=0.17.32
5
5
  ruamel.yaml.string<1,>=0.1.1
6
6
  tomlkit<0.12,>=0.11.8
7
- MDit==0.0.0.dev47
8
- ExceptionMan==0.0.0.dev47
7
+ MDit==0.0.0.dev49
8
+ ExceptionMan==0.0.0.dev49
9
9
  ProtocolMan==0.0.0.dev2
@@ -172,7 +172,7 @@ class TemplateFiller:
172
172
  current_chain=(path,),
173
173
  )
174
174
 
175
- def _recursive_subst(self, templ, current_path: str, relative_path_anchor: str, level: int, current_chain: tuple[str, ...]):
175
+ def _recursive_subst(self, templ, current_path: str, relative_path_anchor: str, level: int, current_chain: tuple[str, ...], is_key: bool = False):
176
176
 
177
177
  def get_code_value(match: _re.Match | str):
178
178
 
@@ -207,7 +207,6 @@ class TemplateFiller:
207
207
  path_invalid=current_path,
208
208
  exception=e,
209
209
  )
210
- self._visited_paths[current_path] = (output, True)
211
210
  return output
212
211
 
213
212
  def get_address_value(match: _re.Match | str, return_all_matches: bool = False, from_code: bool = False):
@@ -224,9 +223,7 @@ class TemplateFiller:
224
223
  )
225
224
  if num_periods:
226
225
  if relative_path_anchor != current_path:
227
- path_fields = self._extract_fields(current_path)
228
- has_template_key = any(field in self._template_keys for field in path_fields)
229
- anchor_path = relative_path_anchor if has_template_key else current_path
226
+ anchor_path = relative_path_anchor if is_relative_template else current_path
230
227
  else:
231
228
  anchor_path = current_path
232
229
  root_path_expr = anchor_path
@@ -241,8 +238,13 @@ class TemplateFiller:
241
238
  )
242
239
  root_path_expr = root_path_expr.left
243
240
  path_expr = self._concat_json_paths(root_path_expr, path_expr)
244
- value, matched = self._visited_paths.get(path_expr) or get_value(path_expr, return_all_matches, from_code)
245
- self._visited_paths[path_expr] = (value, matched)
241
+ cached_result = self._visited_paths.get(path_expr)
242
+ if cached_result:
243
+ value, matched = cached_result
244
+ else:
245
+ value, matched = get_value(path_expr, return_all_matches, from_code)
246
+ if not self._is_relative_template(path_expr):
247
+ self._visited_paths[path_expr] = (value, matched)
246
248
  if from_code:
247
249
  return value, matched
248
250
  if matched:
@@ -345,49 +347,49 @@ class TemplateFiller:
345
347
  return self._visited_paths[current_path][0]
346
348
 
347
349
  self._check_endless_loop(templ, current_chain)
350
+ is_relative_template = self._is_relative_template(current_path)
348
351
 
349
352
  if isinstance(templ, str):
350
353
  # Handle value blocks
351
354
  pattern_value = self._get_value_regex_pattern(level=level)
352
- match_value = pattern_value.fullmatch(templ)
353
- if match_value:
354
- return get_address_value(fill_nested_values(match_value))
355
+ if match_value := pattern_value.fullmatch(templ):
356
+ out = get_address_value(fill_nested_values(match_value))
355
357
  # Handle list blocks
356
- match_list = self._pattern_list.fullmatch(templ)
357
- if match_list:
358
- return get_address_value(fill_nested_values(match_list), return_all_matches=True)
358
+ elif match_list := self._pattern_list.fullmatch(templ):
359
+ out = get_address_value(fill_nested_values(match_list), return_all_matches=True)
359
360
  # Handle code blocks
360
- match_code = self._pattern_code.fullmatch(templ)
361
- if match_code:
362
- return get_code_value(match_code)
361
+ elif match_code := self._pattern_code.fullmatch(templ):
362
+ out = get_code_value(match_code)
363
363
  # Handle unpack blocks
364
- match_unpack = self._pattern_unpack.fullmatch(templ)
365
- if match_unpack:
364
+ elif match_unpack := self._pattern_unpack.fullmatch(templ):
366
365
  unpack_value = match_unpack.group(1)
367
- submatch_code = self._pattern_code.fullmatch(unpack_value)
368
- if submatch_code:
369
- return get_code_value(submatch_code)
370
- unpack_value = fill_nested_values(unpack_value)
371
- submatch_list = self._pattern_list.fullmatch(unpack_value)
372
- if submatch_list:
373
- return get_address_value(submatch_list, return_all_matches=True)
374
- return get_address_value(unpack_value)
366
+ if submatch_code := self._pattern_code.fullmatch(unpack_value):
367
+ out = get_code_value(submatch_code)
368
+ else:
369
+ unpack_value = fill_nested_values(unpack_value)
370
+ if submatch_list := self._pattern_list.fullmatch(unpack_value):
371
+ out = get_address_value(submatch_list, return_all_matches=True)
372
+ else:
373
+ out = get_address_value(unpack_value)
375
374
  # Handle strings
376
- code_blocks_filled = self._pattern_code.sub(
377
- lambda x: self._stringer(get_code_value(x)),
378
- templ
379
- )
380
- nested_values_filled = fill_nested_values(code_blocks_filled)
381
- unpacked_filled = self._pattern_unpack.sub(string_filler_unpack, nested_values_filled)
382
- lists_filled = self._pattern_list.sub(
383
- lambda x: self._stringer(get_address_value(x)),
384
- unpacked_filled
385
- )
386
- templ_values_filled = pattern_value.sub(
387
- lambda x: self._stringer(get_address_value(x)),
388
- lists_filled
389
- )
390
- return templ_values_filled
375
+ else:
376
+ code_blocks_filled = self._pattern_code.sub(
377
+ lambda x: self._stringer(get_code_value(x)),
378
+ templ
379
+ )
380
+ nested_values_filled = fill_nested_values(code_blocks_filled)
381
+ unpacked_filled = self._pattern_unpack.sub(string_filler_unpack, nested_values_filled)
382
+ lists_filled = self._pattern_list.sub(
383
+ lambda x: self._stringer(get_address_value(x)),
384
+ unpacked_filled
385
+ )
386
+ out = pattern_value.sub(
387
+ lambda x: self._stringer(get_address_value(x)),
388
+ lists_filled
389
+ )
390
+ if not is_relative_template and not is_key:
391
+ self._visited_paths[current_path] = (out, True)
392
+ return out
391
393
 
392
394
  if isinstance(templ, list):
393
395
  out = []
@@ -410,7 +412,8 @@ class TemplateFiller:
410
412
  )
411
413
  else:
412
414
  out.append(elem_filled)
413
- self._visited_paths[current_path] = (out, True)
415
+ if not is_relative_template:
416
+ self._visited_paths[current_path] = (out, True)
414
417
  return out
415
418
 
416
419
  if isinstance(templ, dict):
@@ -422,6 +425,7 @@ class TemplateFiller:
422
425
  relative_path_anchor=relative_path_anchor,
423
426
  level=0,
424
427
  current_chain=current_chain,
428
+ is_key=True,
425
429
  )
426
430
  if isinstance(key, str) and self._pattern_unpack.fullmatch(key):
427
431
  new_dict.update(key_filled)
@@ -437,7 +441,8 @@ class TemplateFiller:
437
441
  level=0,
438
442
  current_chain=current_chain + (new_path,),
439
443
  )
440
- self._visited_paths[current_path] = (new_dict, True)
444
+ if not is_relative_template:
445
+ self._visited_paths[current_path] = (new_dict, True)
441
446
  return new_dict
442
447
  return templ
443
448
 
@@ -471,6 +476,10 @@ class TemplateFiller:
471
476
  self._pattern_value[level] = pattern
472
477
  return pattern
473
478
 
479
+ def _is_relative_template(self, jsonpath):
480
+ path_fields = self._extract_fields(jsonpath)
481
+ return any(field in self._template_keys for field in path_fields)
482
+
474
483
  @staticmethod
475
484
  def _remove_leading_periods(s: str) -> (str, int):
476
485
  match = _re.match(r"^(\.*)(.*)", s)