PySerials 0.0.0.dev54__tar.gz → 0.0.0.dev56__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.dev54 → pyserials-0.0.0.dev56}/PKG-INFO +4 -4
  2. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/pyproject.toml +4 -4
  3. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/PySerials.egg-info/PKG-INFO +4 -4
  4. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/PySerials.egg-info/requires.txt +3 -3
  5. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/write.py +13 -2
  6. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/README.md +0 -0
  7. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/setup.cfg +0 -0
  8. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/PySerials.egg-info/SOURCES.txt +0 -0
  9. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/PySerials.egg-info/dependency_links.txt +0 -0
  10. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/PySerials.egg-info/not-zip-safe +0 -0
  11. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/PySerials.egg-info/top_level.txt +0 -0
  12. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/__init__.py +0 -0
  13. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/compare.py +0 -0
  14. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/exception/__init__.py +0 -0
  15. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/exception/_base.py +0 -0
  16. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/exception/read.py +0 -0
  17. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/exception/update.py +0 -0
  18. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/exception/validate.py +0 -0
  19. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/format.py +0 -0
  20. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/nested_dict.py +0 -0
  21. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/property_dict.py +0 -0
  22. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/read.py +0 -0
  23. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/update.py +0 -0
  24. {pyserials-0.0.0.dev54 → pyserials-0.0.0.dev56}/src/pyserials/validate.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySerials
3
- Version: 0.0.0.dev54
3
+ Version: 0.0.0.dev56
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: jsonschema<5,>=4.21.0
6
6
  Requires-Dist: referencing>=0.35.1
7
7
  Requires-Dist: jsonpath-ng<2,>=1.6.1
8
- Requires-Dist: ruamel.yaml<0.18,>=0.17.32
8
+ Requires-Dist: ruamel.yaml>=0.18
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.dev51
12
- Requires-Dist: ExceptionMan==0.0.0.dev51
11
+ Requires-Dist: MDit==0.0.0.dev53
12
+ Requires-Dist: ExceptionMan==0.0.0.dev53
13
13
  Requires-Dist: ProtocolMan==0.0.0.dev2
@@ -17,17 +17,17 @@ namespaces = true
17
17
  # ----------------------------------------- Project Metadata -------------------------------------
18
18
  #
19
19
  [project]
20
- version = "0.0.0.dev54"
20
+ version = "0.0.0.dev56"
21
21
  name = "PySerials"
22
22
  dependencies = [
23
23
  "jsonschema >= 4.21.0, < 5",
24
24
  "referencing >= 0.35.1",
25
25
  "jsonpath-ng >= 1.6.1, < 2",
26
- "ruamel.yaml >= 0.17.32, < 0.18", # https://yaml.readthedocs.io/en/stable/
26
+ "ruamel.yaml >= 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.dev51",
30
- "ExceptionMan == 0.0.0.dev51",
29
+ "MDit == 0.0.0.dev53",
30
+ "ExceptionMan == 0.0.0.dev53",
31
31
  "ProtocolMan == 0.0.0.dev2",
32
32
  ]
33
33
  requires-python = ">=3.10"
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySerials
3
- Version: 0.0.0.dev54
3
+ Version: 0.0.0.dev56
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: jsonschema<5,>=4.21.0
6
6
  Requires-Dist: referencing>=0.35.1
7
7
  Requires-Dist: jsonpath-ng<2,>=1.6.1
8
- Requires-Dist: ruamel.yaml<0.18,>=0.17.32
8
+ Requires-Dist: ruamel.yaml>=0.18
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.dev51
12
- Requires-Dist: ExceptionMan==0.0.0.dev51
11
+ Requires-Dist: MDit==0.0.0.dev53
12
+ Requires-Dist: ExceptionMan==0.0.0.dev53
13
13
  Requires-Dist: ProtocolMan==0.0.0.dev2
@@ -1,9 +1,9 @@
1
1
  jsonschema<5,>=4.21.0
2
2
  referencing>=0.35.1
3
3
  jsonpath-ng<2,>=1.6.1
4
- ruamel.yaml<0.18,>=0.17.32
4
+ ruamel.yaml>=0.18
5
5
  ruamel.yaml.string<1,>=0.1.1
6
6
  tomlkit<0.12,>=0.11.8
7
- MDit==0.0.0.dev51
8
- ExceptionMan==0.0.0.dev51
7
+ MDit==0.0.0.dev53
8
+ ExceptionMan==0.0.0.dev53
9
9
  ProtocolMan==0.0.0.dev2
@@ -1,10 +1,14 @@
1
- from typing import Literal as _Literal
1
+ from __future__ import annotations as _annotations
2
+ from typing import Literal as _Literal, TYPE_CHECKING as _TYPE_CHECKING
2
3
  from pathlib import Path as _Path
3
4
  import json as _json
4
5
  import ruamel.yaml as _yaml
5
6
  from ruamel.yaml import scalarstring as _yaml_scalar_string
6
7
  import tomlkit as _tomlkit
7
8
 
9
+ if _TYPE_CHECKING:
10
+ from typing import Callable, Any
11
+
8
12
 
9
13
  def to_string(
10
14
  data: dict | list | str | int | float | bool | _yaml.CommentedMap | _yaml.CommentedSeq,
@@ -27,12 +31,18 @@ def to_yaml_string(
27
31
  indent_sequence: int = 4,
28
32
  indent_sequence_offset: int = 2,
29
33
  multiline_string_to_block: bool = True,
34
+ remove_top_level_indent: bool = True
30
35
  ) -> str:
31
36
  yaml = _yaml.YAML(typ=["rt", "string"])
32
37
  yaml.indent(mapping=indent_mapping, sequence=indent_sequence, offset=indent_sequence_offset)
33
38
  if multiline_string_to_block:
34
39
  _yaml_scalar_string.walk_tree(data)
35
40
  yaml_syntax = yaml.dumps(data, add_final_eol=False).removesuffix("\n...")
41
+ if remove_top_level_indent:
42
+ yaml_lines = yaml_syntax.splitlines()
43
+ count_leading_spaces = len(yaml_lines[0]) - len(yaml_lines[0].lstrip(" "))
44
+ if count_leading_spaces:
45
+ yaml_syntax = "\n".join(yaml_line.removeprefix(" " * count_leading_spaces) for yaml_line in yaml_lines)
36
46
  return f"{yaml_syntax}\n" if end_of_file_newline else yaml_syntax
37
47
 
38
48
 
@@ -47,8 +57,9 @@ def to_json_string(
47
57
  data: dict | list | str | int | float | bool | _yaml.CommentedMap | _yaml.CommentedSeq,
48
58
  sort_keys: bool = False,
49
59
  indent: int | None = None,
60
+ default: Callable[[Any], Any] | None = None,
50
61
  ) -> str:
51
- return _json.dumps(data, indent=indent, sort_keys=sort_keys)
62
+ return _json.dumps(data, indent=indent, sort_keys=sort_keys, default=default)
52
63
 
53
64
 
54
65
  def to_yaml_file(