Skip to content
Snippets Groups Projects
Commit 331cb864 authored by sguazt's avatar sguazt
Browse files

Core: created an interactive version of 'get_parameter'

parent 18cebfef
No related branches found
No related tags found
No related merge requests found
......@@ -78,20 +78,20 @@ class MetaConfManager(ABC):
def get_parameter(self, section, option, return_type=None, regex=None, default=None):
"""
Return the parameter stored in the module configuration file or
ask the user to provide it
the given default value.
Args:
section (str): name of the section (a name surrounded with square brackets
inside the configuration file)
option (str): name of the parameter
return_type (<return_type>, optional): the return type assigned to user input,
if not specified in the configuration
file
section (str): name of the section (a name surrounded with square
brackets inside the configuration file).
option (str): name of the parameter.
return_type (<return_type>): the type to which convert the parameter
value read from the configuration file and returned from this
function.
regex (str): the regular expression the input must follow, if a user input is
required
required.
Returns:
<return_type>: user input of type <return_type>
<return_type>: the parameter value converted to the given return type.
"""
if self.parser.has_option(section, option):
value = self.parser.get(section, option)
......@@ -100,9 +100,32 @@ class MetaConfManager(ABC):
return True
else:
return return_type(value)
elif default is not None:
return default
else:
return default
def get_parameter_ui(self, section, option, return_type=None, regex=None, default=None):
"""
Return the parameter stored in the module configuration file or
ask the user to provide it if no default value is given.
Args:
section (str): name of the section (a name surrounded with square brackets
inside the configuration file).
option (str): name of the parameter.
return_type (<return_type>, optional): the return type assigned to
user input, if not specified in the configuration file.
regex (str): the regular expression the input must follow, if a user
input is required.
Returns:
<return_type>: user input of type <return_type>.
"""
value = self.get_parameter(section,
option,
return_type=return_type,
regex=regex,
default=default)
if value is None:
return self.ask_for_data(section, option, regex=regex, return_type=return_type)
def get_parameters(self, section):
......
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