Skip to content

Commit 055bb2e

Browse files
committed
Release version 0.0.0.dev56
1 parent daac25d commit 055bb2e

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespaces = true
1717
# ----------------------------------------- Project Metadata -------------------------------------
1818
#
1919
[project]
20-
version = "0.0.0.dev55"
20+
version = "0.0.0.dev56"
2121
name = "PySerials"
2222
dependencies = [
2323
"jsonschema >= 4.21.0, < 5",
@@ -26,8 +26,8 @@ dependencies = [
2626
"ruamel.yaml >= 0.18", # https://yaml.readthedocs.io/en/stable/
2727
"ruamel.yaml.string >= 0.1.1, < 1",
2828
"tomlkit >= 0.11.8, < 0.12", # https://tomlkit.readthedocs.io/en/stable/,
29-
"MDit == 0.0.0.dev52",
30-
"ExceptionMan == 0.0.0.dev52",
29+
"MDit == 0.0.0.dev53",
30+
"ExceptionMan == 0.0.0.dev53",
3131
"ProtocolMan == 0.0.0.dev2",
3232
]
3333
requires-python = ">=3.10"

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ jsonpath-ng >= 1.6.1, < 2
44
ruamel.yaml >= 0.18
55
ruamel.yaml.string >= 0.1.1, < 1
66
tomlkit >= 0.11.8, < 0.12
7-
MDit == 0.0.0.dev52
8-
ExceptionMan == 0.0.0.dev52
7+
MDit == 0.0.0.dev53
8+
ExceptionMan == 0.0.0.dev53
99
ProtocolMan == 0.0.0.dev2

src/pyserials/write.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ def to_yaml_string(
3131
indent_sequence: int = 4,
3232
indent_sequence_offset: int = 2,
3333
multiline_string_to_block: bool = True,
34+
remove_top_level_indent: bool = True
3435
) -> str:
3536
yaml = _yaml.YAML(typ=["rt", "string"])
3637
yaml.indent(mapping=indent_mapping, sequence=indent_sequence, offset=indent_sequence_offset)
3738
if multiline_string_to_block:
3839
_yaml_scalar_string.walk_tree(data)
3940
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)
4046
return f"{yaml_syntax}\n" if end_of_file_newline else yaml_syntax
4147

4248

0 commit comments

Comments
 (0)