Prevent ruamel from collapsing config YAML

This commit is contained in:
Micah Jerome Ellison 2022-02-26 14:06:37 -08:00
parent 1f652d7c1b
commit 0381639690

View file

@ -51,12 +51,16 @@ def make_yaml_valid_dict(input: list) -> dict:
def save_config(config, alt_config_path=None): def save_config(config, alt_config_path=None):
"""Supply alt_config_path if using an alternate config through --config-file.""" """Supply alt_config_path if using an alternate config through --config-file."""
config["version"] = __version__ config["version"] = __version__
yaml = YAML(typ="safe")
yaml.default_flow_style = False # prevents collapsing of tree structure
with open( with open(
alt_config_path if alt_config_path else get_config_path(), alt_config_path if alt_config_path else get_config_path(),
"w", "w",
encoding=YAML_FILE_ENCODING, encoding=YAML_FILE_ENCODING,
) as f: ) as f:
YAML(typ="safe").dump(config, f) yaml.dump(config, f)
def get_config_path(): def get_config_path():