PySerials 0.0.0.dev55__py3-none-any.whl → 0.0.0.dev56__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySerials
3
- Version: 0.0.0.dev55
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
@@ -8,6 +8,6 @@ Requires-Dist: jsonpath-ng<2,>=1.6.1
8
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.dev52
12
- Requires-Dist: ExceptionMan==0.0.0.dev52
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
@@ -6,13 +6,13 @@ pyserials/property_dict.py,sha256=JqihWl3kDPZZqQHEkf5tN20EA5lJjy_37opSb-4u3ac,22
6
6
  pyserials/read.py,sha256=uucYQH1V4GStwRgRZ2eQIXkH4ukB5qz0EA885grwi68,6592
7
7
  pyserials/update.py,sha256=YqdWwcpZajPvBTi6U4F9TJEm-ceiGeBEch5SBsIJYfU,23023
8
8
  pyserials/validate.py,sha256=ti0D_yLzB_HELvf1d5qrarx1Ac-opBMN1Xh5lADRAQU,3664
9
- pyserials/write.py,sha256=svoss-XmC9Rr6lbw90zz7LqGzhM3u9jgI8ZtL_BLJ4s,2705
9
+ pyserials/write.py,sha256=C5wZ24gApzBhayeBzn3ceTIqapNkRU3CdjLr226jPtE,3056
10
10
  pyserials/exception/__init__.py,sha256=ZhbggwJUMlTyBhifAivC8ZQxP1Na6lJAwzZs7_YjOSU,151
11
11
  pyserials/exception/_base.py,sha256=IdaZwBPBYgiUaWnvN0eMXvQQBqLbN1t766034CK7Hlc,853
12
12
  pyserials/exception/read.py,sha256=hd3FoPzn7rS2nuWsPDLW-xt9eYE4uCW1ACN1VpOk0sk,9303
13
13
  pyserials/exception/update.py,sha256=lcZ2awcTQ636LPqEv9NX7m6XUj6JTiZQaSMhHebVzmI,4229
14
14
  pyserials/exception/validate.py,sha256=7UkQEEqCa8HJ20gpTFnLDhT3P5OPLD2oD9fUK2Jcuns,7466
15
- PySerials-0.0.0.dev55.dist-info/METADATA,sha256=LeCA9yFLDDFUPMsBi9EeEr8WXQjrzLGAVjY4cZ7d1M0,419
16
- PySerials-0.0.0.dev55.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
- PySerials-0.0.0.dev55.dist-info/top_level.txt,sha256=SAks7WjSjdkv3i9Hvt4gY_P7VQbhhYJN5mf5dqx1aao,10
18
- PySerials-0.0.0.dev55.dist-info/RECORD,,
15
+ PySerials-0.0.0.dev56.dist-info/METADATA,sha256=IgBTZCgMRbpj5tzS4zmzNo05RNC-zAZn4a9kXPwsDE4,419
16
+ PySerials-0.0.0.dev56.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
+ PySerials-0.0.0.dev56.dist-info/top_level.txt,sha256=SAks7WjSjdkv3i9Hvt4gY_P7VQbhhYJN5mf5dqx1aao,10
18
+ PySerials-0.0.0.dev56.dist-info/RECORD,,
pyserials/write.py CHANGED
@@ -31,12 +31,18 @@ def to_yaml_string(
31
31
  indent_sequence: int = 4,
32
32
  indent_sequence_offset: int = 2,
33
33
  multiline_string_to_block: bool = True,
34
+ remove_top_level_indent: bool = True
34
35
  ) -> str:
35
36
  yaml = _yaml.YAML(typ=["rt", "string"])
36
37
  yaml.indent(mapping=indent_mapping, sequence=indent_sequence, offset=indent_sequence_offset)
37
38
  if multiline_string_to_block:
38
39
  _yaml_scalar_string.walk_tree(data)
39
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)
40
46
  return f"{yaml_syntax}\n" if end_of_file_newline else yaml_syntax
41
47
 
42
48