X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPythonAPI%2Fmodel%2Froots.py;h=31316103e34d389ec447cb48c0fe2e69891d9cc2;hb=42394362cfec9b39f7def70c83e99c77a48fdfe5;hp=0cf8ae2740fe8425cbb6d61a533a61e820f7b795;hpb=68e65b42c86cee2d94e26ab00072c9f89df24e6f;p=modules%2Fshaper.git diff --git a/src/PythonAPI/model/roots.py b/src/PythonAPI/model/roots.py index 0cf8ae274..31316103e 100644 --- a/src/PythonAPI/model/roots.py +++ b/src/PythonAPI/model/roots.py @@ -5,60 +5,30 @@ Copyright (C) 2014-20xx CEA/DEN, EDF R&D import ModelAPI -from .tools import get_value, convert_to_underscore - - class Feature(ModelAPI.ModelAPI_Feature): """Base class of user-defined Python features.""" def __init__(self): + """x.__init__(...) initializes x; see x.__class__.__doc__ for signature""" ModelAPI.ModelAPI_Feature.__init__(self) - def addRealInput (self, inputid): + def addRealInput(self, inputid): + """F.addRealInput(str) -- add real attribute""" self.data().addAttribute(inputid, ModelAPI.ModelAPI_AttributeDouble_typeId()) - def getRealInput (self, inputid): + def getRealInput(self, inputid): + """F.getRealInput(str) -- get real value of the attribute""" return self.data().real(inputid).value() - def addResult (self, result): + def getTextInput(self, inputid): + """F.getTextInput(str) -- get text value of the attribute""" + return self.data().real(inputid).text() + + def addResult(self, result): + """F.addResult(ModelAPI_Result) -- add ModelAPI_Result shape as a result""" shape = result.shape() body = self.document().createBody(self.data()) body.store(shape) self.setResult(body) - -class Interface(): - """Base class of high level Python interfaces to features.""" - - def __init__(self, feature): - self._feature = feature - - def __getattr__(self, name): - """Process missing attributes. - - Add get*() methods for access feature attributes. - Redirect missing attributes to the feature. - """ - if name.startswith("get"): - possible_names = [ - "_" + name[3:], - "_" + convert_to_underscore(name[3:]), - ] - for possible_name in possible_names: - if hasattr(self, possible_name): - def getter(): - return get_value(getattr(self, possible_name)) - return getter - - return self._feature.__getattribute__(name) - - def setRealInput(self, inputid, value): - self._feature.data().real(inputid).setValue(value) - - def areInputValid(self): - validators = ModelAPI.ModelAPI_Session.get().validators() - return validators.validate(self._feature) - - def execute(self): - self._feature.execute()