Remove trailing whitespace after wrapping lines

In ruamel there's no option to avoid a trailing whitespace after
wrapping lines, so we need to post process the output to remove
that if present.

Change-Id: Iced01614c7dda0d02195a806733c9857306f07fc
Signed-off-by: Riccardo Pittau <elfosardo@gmail.com>
This commit is contained in:
Riccardo Pittau
2025-10-09 16:20:11 +02:00
parent 17eb8df620
commit bb1c2ed11f
+8 -1
View File
@@ -25,7 +25,14 @@ def dumps(obj):
yaml.explicit_start = True
yaml.indent(mapping=2, sequence=4, offset=2)
yaml.dump(obj, stream)
return stream.getvalue()
# Remove trailing whitespace.
# NOTE(rpittau): This can be removed once the bug introduced
# in ruamel 0.18.13 is fixed.
yaml_output = stream.getvalue()
lines = yaml_output.split('\n')
cleaned_yaml_lines = [line.rstrip() for line in lines]
return '\n'.join(cleaned_yaml_lines)
def loads(blob):