config: merge with default config for updated config
@@ -13,12 +13,13 @@ def load_config_file():
Load the configuration file
"""
fpath = Path(XDG_CONFIG_HOME, 'ocrd.yml')
+ obj = DEFAULT_CONFIG
if not fpath.exists():
with open(str(fpath), 'w', encoding='utf-8') as f_out:
f_out.write("# Generated by OCR-D/core %s on %s\n" % (VERSION, datetime.now()))
- f_out.write(safe_dump(DEFAULT_CONFIG))
+ f_out.write(safe_dump(obj))
with open(str(fpath), 'r', encoding='utf-8') as f_in:
- obj = safe_load(f_in.read())
+ obj = {**obj, **safe_load(f_in.read())}
report = OcrdConfigValidator.validate(obj)
if not report.is_valid:
raise ValueError("The configuration is invalid: %s" % report.errors)
