feat: use YAML | block style for multi-line strings on add download

This commit is contained in:
sebthom
2024-11-21 23:11:36 +01:00
parent 735e564c76
commit 5086721082

View File

@@ -246,6 +246,10 @@ def save_dict(filepath:str, content:dict[str, Any]) -> None:
else:
yaml = YAML()
yaml.indent(mapping = 2, sequence = 4, offset = 2)
yaml.representer.add_representer(str, # use YAML | block style for multi-line strings
lambda dumper, data:
dumper.represent_scalar('tag:yaml.org,2002:str', data, style = '|' if '\n' in data else None)
)
yaml.allow_duplicate_keys = False
yaml.explicit_start = False
yaml.dump(content, file)