Skip to content
Snippets Groups Projects
Commit b15ed354 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[utils] fixed the function to get parameters: priority given to command line

parent 053fb30c
Branches
No related tags found
No related merge requests found
Pipeline #
......@@ -33,12 +33,28 @@ def get_parameter(args, configuration, keyword, default):
"""
# get the keyword in a "docopt" friendly format
args_kw = '--' + keyword.replace('_', '-')
# get the type of this argument
_type = type(default)
arg = _type(args[args_kw])
# get the default value
arg_default = default
# get the argument in the configuration file
if hasattr(configuration, keyword):
arg = getattr(configuration, keyword)
if _type(args[args_kw]) is not default and not hasattr(configuration, keyword):
arg = _type(args[args_kw])
return arg
arg_config = getattr(configuration, keyword)
# get the argument from the command-line
arg_command = _type(args[args_kw])
# if the argument was not specified in the config file
if not hasattr(configuration, keyword):
return arg_command
else:
if (arg_command == arg_default):
return arg_config
else:
return arg_command
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment