Skip to content
Snippets Groups Projects
Commit a3962d44 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Rename 'default_nabu_config' to 'default_config'

parent ad8869de
No related branches found
No related tags found
No related merge requests found
...@@ -176,7 +176,7 @@ def _handle_modified_key(key, val, section, default_config, renamed_keys): ...@@ -176,7 +176,7 @@ def _handle_modified_key(key, val, section, default_config, renamed_keys):
return key, None, section # unhandled renamed/deleted key return key, None, section # unhandled renamed/deleted key
def validate_config(config, default_nabu_config, renamed_keys, errors="warn"): def validate_config(config, default_config, renamed_keys, errors="warn"):
""" """
Validate a configuration dictionary against a "default" configuration dict. Validate a configuration dictionary against a "default" configuration dict.
...@@ -204,28 +204,28 @@ def validate_config(config, default_nabu_config, renamed_keys, errors="warn"): ...@@ -204,28 +204,28 @@ def validate_config(config, default_nabu_config, renamed_keys, errors="warn"):
# Ignore the "other" section # Ignore the "other" section
if section.lower() == "other": if section.lower() == "other":
continue continue
if section not in default_nabu_config: if section not in default_config:
error("Unknown section [%s]" % section) error("Unknown section [%s]" % section)
continue continue
res_config[section] = _extract_nabuconfig_section(section, default_nabu_config) res_config[section] = _extract_nabuconfig_section(section, default_config)
res_config[section].update(section_content) res_config[section].update(section_content)
for key, value in res_config[section].items(): for key, value in res_config[section].items():
opt = default_nabu_config[section].get(key, None) opt = default_config[section].get(key, None)
key, opt, section_updated = _handle_modified_key(key, opt, section, default_nabu_config, renamed_keys) key, opt, section_updated = _handle_modified_key(key, opt, section, default_config, renamed_keys)
if key is None: if key is None:
continue # deleted key continue # deleted key
if opt is None: if opt is None:
error("Unknown option '%s' in section [%s]" % (key, section_updated)) error("Unknown option '%s' in section [%s]" % (key, section_updated))
continue continue
validator = default_nabu_config[section_updated][key]["validator"] validator = default_config[section_updated][key]["validator"]
if section_updated not in res_config: # missing section - handled later if section_updated not in res_config: # missing section - handled later
continue continue
res_config[section_updated][key] = validator(section_updated, key, value) res_config[section_updated][key] = validator(section_updated, key, value)
# Handle sections missing in config # Handle sections missing in config
for section in (set(default_nabu_config.keys()) - set(res_config.keys())): for section in (set(default_config.keys()) - set(res_config.keys())):
res_config[section] = _extract_nabuconfig_section(section, default_nabu_config) res_config[section] = _extract_nabuconfig_section(section, default_config)
for key, value in res_config[section].items(): for key, value in res_config[section].items():
validator = default_nabu_config[section][key]["validator"] validator = default_config[section][key]["validator"]
res_config[section][key] = validator(section, key, value) res_config[section][key] = validator(section, key, value)
return res_config return res_config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment