Skip to content

Commit

Permalink
Release version 0.0.0.dev56
Browse files Browse the repository at this point in the history
  • Loading branch information
AAriam committed Dec 29, 2024
1 parent daac25d commit 055bb2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespaces = true
# ----------------------------------------- Project Metadata -------------------------------------
#
[project]
version = "0.0.0.dev55"
version = "0.0.0.dev56"
name = "PySerials"
dependencies = [
"jsonschema >= 4.21.0, < 5",
Expand All @@ -26,8 +26,8 @@ dependencies = [
"ruamel.yaml >= 0.18", # https://yaml.readthedocs.io/en/stable/
"ruamel.yaml.string >= 0.1.1, < 1",
"tomlkit >= 0.11.8, < 0.12", # https://tomlkit.readthedocs.io/en/stable/,
"MDit == 0.0.0.dev52",
"ExceptionMan == 0.0.0.dev52",
"MDit == 0.0.0.dev53",
"ExceptionMan == 0.0.0.dev53",
"ProtocolMan == 0.0.0.dev2",
]
requires-python = ">=3.10"
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ jsonpath-ng >= 1.6.1, < 2
ruamel.yaml >= 0.18
ruamel.yaml.string >= 0.1.1, < 1
tomlkit >= 0.11.8, < 0.12
MDit == 0.0.0.dev52
ExceptionMan == 0.0.0.dev52
MDit == 0.0.0.dev53
ExceptionMan == 0.0.0.dev53
ProtocolMan == 0.0.0.dev2
6 changes: 6 additions & 0 deletions src/pyserials/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ def to_yaml_string(
indent_sequence: int = 4,
indent_sequence_offset: int = 2,
multiline_string_to_block: bool = True,
remove_top_level_indent: bool = True
) -> str:
yaml = _yaml.YAML(typ=["rt", "string"])
yaml.indent(mapping=indent_mapping, sequence=indent_sequence, offset=indent_sequence_offset)
if multiline_string_to_block:
_yaml_scalar_string.walk_tree(data)
yaml_syntax = yaml.dumps(data, add_final_eol=False).removesuffix("\n...")
if remove_top_level_indent:
yaml_lines = yaml_syntax.splitlines()
count_leading_spaces = len(yaml_lines[0]) - len(yaml_lines[0].lstrip(" "))
if count_leading_spaces:
yaml_syntax = "\n".join(yaml_line.removeprefix(" " * count_leading_spaces) for yaml_line in yaml_lines)
return f"{yaml_syntax}\n" if end_of_file_newline else yaml_syntax


Expand Down

0 comments on commit 055bb2e

Please sign in to comment.