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

25 lines
580 B
Python
Raw Normal View History

#!/usr/bin/env python3
import codecs
import yaml
import sys
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.safe_load(f)
all = dict_merge(all, data)
with codecs.open('cs.yml', 'w', encoding='utf-8') as f:
yaml.dump(data, f, allow_unicode=True, sort_keys=True)