X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPythonAPI%2Fmodel%2Froots.py;h=31316103e34d389ec447cb48c0fe2e69891d9cc2;hb=42394362cfec9b39f7def70c83e99c77a48fdfe5;hp=1fa83ee5715acdf3678cfd57e83543b126fb08e3;hpb=ccba1627ced32120b894d5731f9e960635c87bc1;p=modules%2Fshaper.git diff --git a/src/PythonAPI/model/roots.py b/src/PythonAPI/model/roots.py index 1fa83ee57..31316103e 100644 --- a/src/PythonAPI/model/roots.py +++ b/src/PythonAPI/model/roots.py @@ -5,9 +5,6 @@ Copyright (C) 2014-20xx CEA/DEN, EDF R&D import ModelAPI -from model import tools - - class Feature(ModelAPI.ModelAPI_Feature): """Base class of user-defined Python features.""" @@ -24,6 +21,10 @@ class Feature(ModelAPI.ModelAPI_Feature): """F.getRealInput(str) -- get real value of the attribute""" return self.data().real(inputid).value() + 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() @@ -31,65 +32,3 @@ class Feature(ModelAPI.ModelAPI_Feature): body.store(shape) self.setResult(body) - -class Interface(): - """Base class of high level Python interfaces to features.""" - - def __init__(self, feature): - """x.__init__(...) initializes x; see x.__class__.__doc__ for signature""" - self._feature = feature - self._attribute_white_list = [ - "execute", - "getKind", "results", "firstResult", "lastResult", - ] - - def __getattr__(self, name): - """Process missing attributes. - - Add get*() methods for access feature attributes. - Redirect some missing attributes to the feature. - """ - if name.startswith("get"): - possible_names = [ - "_" + name[3:], - "_" + tools.convert_to_underscore(name[3:]), - ] - for possible_name in possible_names: - if hasattr(self, possible_name): - def getter(): - return getattr(self, possible_name) - return getter - - if name in self._attribute_white_list: - return getattr(self._feature, name) - - raise AttributeError() - - def feature(self): - """Return ModelAPI_Feature.""" - return self._feature - - def _fill_attribute(self, attribute, value): - """Fill ModelAPI_Attribute* with value.""" - tools.fill_attribute(attribute, value) - - def setRealInput(self, inputid, value): - """I.setRealInput(str, float) -- set real value to the attribute""" - self._feature.data().real(inputid).setValue(value) - - def areInputValid(self): - """I.areInputValid() -> True or False validation result""" - validators = ModelAPI.ModelAPI_Session.get().validators() - return validators.validate(self._feature) - - def _execute(self): - """I._execute() -- validate and execute the feature. - - Raises RuntimeError if validation fails. - """ - if self.areInputValid(): - self._feature.execute() - else: - raise RuntimeError("Can not execute %s: %s" % - (self._feature.getKind(), self._feature.error()) - )