20 lines
653 B
Python
Executable File
20 lines
653 B
Python
Executable File
def dump_dict_to_yaml(
|
|
data: dict,
|
|
target_dir: str,
|
|
filename: str = "settings") -> None:
|
|
""" Writes the given dictionary as a yaml to the target directory.
|
|
|
|
Parameters:
|
|
`data (dict)`: dictionary of data.
|
|
`target_dir (str)`: directory where the yaml will be saved.
|
|
`` filename (str)`: name of the file without extension
|
|
"""
|
|
print("\nParameters")
|
|
for pair in data.items():
|
|
print(f"\t{pair}")
|
|
print()
|
|
|
|
path = f"{target_dir}/{filename}.yml"
|
|
print_p(f"Wrote yaml to: {path}")
|
|
with open(path, 'w') as outfile:
|
|
yaml.dump(data, outfile, default_flow_style=False) |