[docs]class Parameter:
"""
Implements a class for storing DORiE parameters.
:param str category: The category of the parameter, indicated in the DUNE infiles \
by square brackets.
:param str key: The name of the parameter, at the left hand side of the equal sign \
in DUNE inifiles.
"""
def __init__(self,category,key):
self.key = key #: Parameter name
self.category = category #: Parameter category
self.definition = None #: Long explanation of the parameter, shown in the documentation
self.suggestion = None #: Suggested (default) value
self.values = None #: Possible values
self.comment = None #: Extra comment showing up in the generated ini files
self.hidden = False #: Do not issue an error if parameter is not found
#: List of all the positions in the code where the parameter was found,
#: encoded in a tuple: (filename, lineno, C++ type)
self._sources = []
self._code_found = False #: Whether the parameter was found in the code at all
def __str__(self):
"""
Allows for nice output of a Parameter when printed.
"""
string = ""
string += "{0}.{1}\n".format(self.category,self.key)
string += "Definition: {0}\n".format(self.definition)
string += "Suggested value: {0}\n".format(self.suggestion)
string += "Allowed values: {0}\n".format(self.values)
string += "Comment: {0}\n".format(self.comment)
string += "Hidden: {}\n".format("yes" if self.hidden else "no")
string += "Found at:\n"
for f, l, t in self._sources:
string += "\t{0}:{1} as {2}\n".format(f,l,t)
return string
def __eq__(self, other):
"""
Two Parameters are considered equal if both their category and key properties
match. This is used to quickly check if a Parameter is already defined.
"""
if isinstance(other,Parameter):
return self.category == other.category and self.key == other.key
else:
return False