Skip to content
Snippets Groups Projects
Commit c6382e00 authored by Manuel Günther's avatar Manuel Günther
Browse files

Implemented check that all configuration file variables are consumed (passes...

Implemented check that all configuration file variables are consumed (passes also when overwritten on the command line)
parent 026820d8
No related branches found
No related tags found
1 merge request!65First simple version of writing empty configuration files
Pipeline #
......@@ -176,6 +176,18 @@ def _take_from_config_or_command_line(args, config, keyword, default, required=T
elif required:
raise ValueError("Please specify a %s either on command line (via --%s) or in a configuration file" %(keyword, keyword))
if config is not None and hasattr(config, keyword):
setattr(config, keyword, None)
def _check_config_consumed(config):
if config is not None:
import inspect
for keyword in dir(config):
if not keyword.startswith('_') and not keyword.isupper():
attr = getattr(config,keyword)
if attr is not None and not inspect.isclass(attr) and not inspect.ismodule(attr):
logger.warn("The variable '%s' in a configuration file is not known or not supported; use all uppercase variable names (e.g., '%s') to suppress this warning.", keyword, keyword.upper())
def initialize(parsers, command_line_parameters = None, skips = []):
"""initialize(parsers, command_line_parameters = None, skips = []) -> args
......@@ -279,6 +291,9 @@ def initialize(parsers, command_line_parameters = None, skips = []):
_take_from_config_or_command_line(args, config, keyword,
parser.get_default(keyword), required=False, is_resource=False)
# check that all variables in the config file are consumed by the above options
_check_config_consumed(config)
# evaluate skips
if skips is not None and args.execute_only is not None:
for skip in skips:
......
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