import yaml
from flatten_dict import flatten
from flatten_dict.reducers import make_reducer
key_vars = []
with open("key-vars-test.yaml", "r", encoding='utf-8') as file:
key_vars_dict = yaml.load(file, Loader=yaml.FullLoader)
key_vars_flat_dict = flatten(key_vars_dict, reducer=make_reducer(delimiter='.'))
for key, value in key_vars_flat_dict.items():
key_vars.append(f"{{{{ {key[8:]} }}}} : {value}")
with open("key-vars.yaml", "w", encoding='utf-8') as file:
file.writelines("%s\n" % i for i in key_vars)