Spotter-VM/extra/helpers/decidim-lang-merge.py

27 lines
573 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
import codecs
import ruamel.yaml
import sys
yaml = ruamel.yaml.YAML()
def dict_merge(src, dst):
for key, value in src.items():
if isinstance(value, dict):
node = dst.setdefault(key, {})
dict_merge(value, node)
else:
dst[key] = value
return dst
all = {}
for file in sys.argv[1:]:
print(file)
with codecs.open(file, encoding='utf-8') as f:
data = yaml.load(f)
all = dict_merge(all, data)
with codecs.open('cs.yml', 'w', encoding='utf-8') as f:
yaml.dump(data, f)