Commit 6b9954cf authored by eric pellegrini's avatar eric pellegrini
Browse files

The configurable object is now set as a keyword to avoid crash when

calling build_doc and get_default_parameters class method
parent 66423be2
......@@ -77,7 +77,7 @@ class Configurable(object):
for name,(typ,kwds) in self.settings.items():
try:
self._configuration[name] = REGISTRY["configurator"][typ](self, name, **kwds)
self._configuration[name] = REGISTRY["configurator"][typ](name, configurable=self,**kwds)
# Any kind of error has to be caught
except:
raise ConfigurationError("Invalid type for %r configurator" % name)
......@@ -187,7 +187,7 @@ class Configurable(object):
:param cls: the configurable class for which documentation should be built
:type cls: an instance of MDANSE.Framework.Configurable.Configurable derived class
:return: the documnetation about the configurable class
:return: the documentation about the configurable class
:rtype: str
'''
......
......@@ -47,7 +47,7 @@ class AtomsListConfigurator(IConfigurator):
_default = None
def __init__(self, configurable, name, nAtoms=2, **kwargs):
def __init__(self, name, nAtoms=2, **kwargs):
'''
Initializes the configurator.
......@@ -57,7 +57,7 @@ class AtomsListConfigurator(IConfigurator):
:type nAtoms: int
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._nAtoms = nAtoms
......
......@@ -42,7 +42,7 @@ class ComplexNumberConfigurator(IConfigurator):
_default = 0
def __init__(self, configurable, name, mini=None, maxi=None, choices=None, **kwargs):
def __init__(self, name, mini=None, maxi=None, choices=None,**kwargs):
'''
Initializes the configurator.
......@@ -57,7 +57,7 @@ class ComplexNumberConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._mini = float(mini) if mini is not None else None
......
......@@ -41,7 +41,7 @@ class FloatConfigurator(IConfigurator):
_default = 0
def __init__(self, configurable, name, mini=None, maxi=None, choices=None, **kwargs):
def __init__(self, name, mini=None, maxi=None, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -56,7 +56,7 @@ class FloatConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._mini = float(mini) if mini is not None else None
......
......@@ -48,7 +48,7 @@ class FramesConfigurator(RangeConfigurator):
type = 'frames'
def __init__(self, configurable, name, **kwargs):
def __init__(self, name, **kwargs):
'''
Initializes the configurator.
......@@ -56,7 +56,7 @@ class FramesConfigurator(RangeConfigurator):
:type name: str
'''
RangeConfigurator.__init__(self, configurable, name, sort=True, **kwargs)
RangeConfigurator.__init__(self, name, sort=True, **kwargs)
def configure(self, value):
'''
......
......@@ -62,7 +62,7 @@ class GroupingLevelConfigurator(SingleChoiceConfigurator):
_default = "atom"
def __init__(self, configurable, name, choices=None, **kwargs):
def __init__(self, name, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -77,7 +77,7 @@ class GroupingLevelConfigurator(SingleChoiceConfigurator):
else:
choices = list(set(LEVELS.keys()).intersection(choices))
SingleChoiceConfigurator.__init__(self, configurable, name, choices=choices, **kwargs)
SingleChoiceConfigurator.__init__(self, name, choices=choices, **kwargs)
def configure(self,value):
'''
......
......@@ -97,7 +97,7 @@ class IConfigurator(dict):
_doc_ = "undocumented"
def __init__(self, configurable, name, dependencies=None, default=None, label=None, widget=None):
def __init__(self, name, **kwargs):
'''
Initializes a configurator object.
......@@ -117,15 +117,15 @@ class IConfigurator(dict):
self._name = name
self._configurable = configurable
self._configurable = kwargs.get('configurable',None)
self._dependencies = dependencies if dependencies is not None else {}
self._dependencies = kwargs.get('dependencies',{})
self._default = default if default is not None else self.__class__._default
self._default = kwargs.get('default',self.__class__._default)
self._label = label if label is not None else " ".join(name.split('_')).strip()
self._label = kwargs.get('label'," ".join(name.split('_')).strip())
self._widget = widget if widget is not None else self.type
self._widget = kwargs.get('widget',self.type)
@property
def default(self):
......@@ -192,6 +192,10 @@ class IConfigurator(dict):
:note: this is an abstract method.
'''
def set_configurable(self,configurable):
self._configurable = configurable
def check_dependencies(self, configured):
'''
......
......@@ -44,7 +44,7 @@ class InputFileConfigurator(IConfigurator):
_default = ""
def __init__(self, configurable, name, wildcard="All files|*.*",**kwargs):
def __init__(self, name, wildcard="All files|*.*",**kwargs):
'''
Initializes the configurator object.
......@@ -56,7 +56,7 @@ class InputFileConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._wildcard = wildcard
......
......@@ -41,7 +41,7 @@ class IntegerConfigurator(IConfigurator):
_default = 0
def __init__(self, configurable, name, mini=None, maxi=None, choices=None, **kwargs):
def __init__(self, name, mini=None, maxi=None, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -56,7 +56,7 @@ class IntegerConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._mini = int(mini) if mini is not None else None
......
......@@ -50,7 +50,7 @@ class InterpolationOrderConfigurator(SingleChoiceConfigurator):
_default = "no interpolation"
def __init__(self, configurable, name, orders=None,**kwargs):
def __init__(self, name, orders=None,**kwargs):
'''
Initializes the configurator.
......@@ -61,7 +61,7 @@ class InterpolationOrderConfigurator(SingleChoiceConfigurator):
if orders is None:
orders = ["no interpolation","1st order","2nd order","3rd order","4th order","5th order"]
SingleChoiceConfigurator.__init__(self, configurable, name, choices=orders, **kwargs)
SingleChoiceConfigurator.__init__(self, name, choices=orders, **kwargs)
def configure(self, value):
'''
......
......@@ -60,7 +60,7 @@ class McStasParametersConfigurator(IConfigurator):
'sample_rotation_deg': 45.0,
'detector_height_m': 3.0}
def __init__(self, configurable, name, exclude=None, **kwargs):
def __init__(self, name, exclude=None, **kwargs):
'''
Initializes the configurator.
......@@ -71,7 +71,7 @@ class McStasParametersConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._exclude = exclude if exclude is not None else []
......
......@@ -43,7 +43,7 @@ class MultipleChoicesConfigurator(IConfigurator):
_default = []
def __init__(self, configurable, name, choices=None, nChoices=None, **kwargs):
def __init__(self, name, choices=None, nChoices=None, **kwargs):
'''
Initializes the configurator.
......@@ -55,7 +55,7 @@ class MultipleChoicesConfigurator(IConfigurator):
:type nChoices: int or None
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._choices = choices
......
......@@ -49,7 +49,7 @@ class NetCDFInputFileConfigurator(InputFileConfigurator):
_default = ''
def __init__(self, configurable, name, variables=None, **kwargs):
def __init__(self, name, variables=None, **kwargs):
'''
Initializes the configurator.
......@@ -60,7 +60,7 @@ class NetCDFInputFileConfigurator(InputFileConfigurator):
'''
# The base class constructor.
InputFileConfigurator.__init__(self, configurable, name, **kwargs)
InputFileConfigurator.__init__(self, name, **kwargs)
self._variables = variables if variables is not None else []
......
......@@ -44,7 +44,7 @@ class OutputDirectoryConfigurator(IConfigurator):
_default = os.getcwd()
def __init__(self, configurable, name, new=False, **kwargs):
def __init__(self, name, new=False, **kwargs):
'''
Initializes the configurator.
......@@ -54,7 +54,7 @@ class OutputDirectoryConfigurator(IConfigurator):
:type new: bool
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._new = new
......
......@@ -52,7 +52,7 @@ class OutputFilesConfigurator(IConfigurator):
_default = (os.path.join(tempfile.gettempdir(),"output"), ["netcdf"])
def __init__(self, configurable, name, formats=None, **kwargs):
def __init__(self, name, formats=None, **kwargs):
'''
Initializes the configurator.
......@@ -62,7 +62,7 @@ class OutputFilesConfigurator(IConfigurator):
:type formats: list of str
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._formats = formats if formats is not None else OutputFilesConfigurator._default[2]
......
......@@ -42,7 +42,7 @@ class PythonScriptConfigurator(InputFileConfigurator):
_default = ''
def __init__(self, configurable, name, variables=None, **kwargs):
def __init__(self, name, variables=None, **kwargs):
'''
Initializes the configurator.
......@@ -53,7 +53,7 @@ class PythonScriptConfigurator(InputFileConfigurator):
'''
# The base class constructor.
InputFileConfigurator.__init__(self, configurable, name, **kwargs)
InputFileConfigurator.__init__(self, name, **kwargs)
self._variables = variables if variables is not None else []
......
......@@ -45,7 +45,7 @@ class RangeConfigurator(IConfigurator):
_default = (0,10,1)
def __init__(self, configurable, name, valueType=int, includeLast=False, sort=False, toList=False, mini=None, maxi=None, **kwargs):
def __init__(self, name, valueType=int, includeLast=False, sort=False, toList=False, mini=None, maxi=None, **kwargs):
'''
Initializes the configurator.
......@@ -65,7 +65,7 @@ class RangeConfigurator(IConfigurator):
:type maxi: int, float or None
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._valueType = valueType
......
......@@ -41,7 +41,7 @@ class SingleChoiceConfigurator(IConfigurator):
_default = []
def __init__(self, configurable, name, choices=None, **kwargs):
def __init__(self, name, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -51,7 +51,7 @@ class SingleChoiceConfigurator(IConfigurator):
:type choices: list
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._choices = choices if choices is not None else []
......
......@@ -43,7 +43,7 @@ class StringConfigurator(IConfigurator):
_default = ""
def __init__(self, configurable, name, evalType=None, acceptNullString=True, **kwargs):
def __init__(self, name, evalType=None, acceptNullString=True, **kwargs):
'''
Initializes the configurator.
......@@ -55,7 +55,7 @@ class StringConfigurator(IConfigurator):
:type acceptNullString: bool
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._evalType = evalType
......
......@@ -45,7 +45,7 @@ class VectorConfigurator(IConfigurator):
_default = [1.0,0.0,0.0]
def __init__(self, configurable, name, valueType=int, normalize=False, notNull=False, dimension=3, **kwargs):
def __init__(self, name, valueType=int, normalize=False, notNull=False, dimension=3, **kwargs):
'''
Initializes the configurator.
......@@ -62,7 +62,7 @@ class VectorConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._valueType = valueType
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment