Back to index

salome-kernel  6.5.0
Classes | Functions | Variables
KERNEL_PY.kernel.parametric.study_exchange_vars Namespace Reference

Classes

class  Variable
class  ExchangeVariables

Functions

def createSObjectForExchangeVariables
def updateSObjectForExchangeVariables
def _setSObjectForExchangeVariables
def getExchangeVariablesFromSObject
def loadExchangeVariablesFromXmlFile

Variables

string DEFAULT_NAME = "Variables"
string INPUT_VAR_NAMES = "ExchangeVariables.InputVarNames"
string OUTPUT_VAR_NAMES = "ExchangeVariables.OutputVarNames"
string REF_ENTRY = "ExchangeVariables.RefEntry"

Function Documentation

def KERNEL_PY.kernel.parametric.study_exchange_vars._setSObjectForExchangeVariables (   editor,
  sobj,
  exchangeVariables 
) [private]

Definition at line 162 of file study_exchange_vars.py.

00162 
00163 def _setSObjectForExchangeVariables(editor, sobj, exchangeVariables):
00164     attr = editor.builder.FindOrCreateAttribute(sobj, "AttributeParameter")
00165     attr.SetStrArray(INPUT_VAR_NAMES,
00166                      [x.name for x in exchangeVariables.inputVarList])
00167     attr.SetStrArray(OUTPUT_VAR_NAMES,
00168                      [x.name for x in exchangeVariables.outputVarList])
00169     if exchangeVariables.refEntry is not None:
00170         attr.SetString(REF_ENTRY, exchangeVariables.refEntry)

Here is the caller graph for this function:

def KERNEL_PY.kernel.parametric.study_exchange_vars.createSObjectForExchangeVariables (   fatherSobj,
  exchangeVariables,
  name = DEFAULT_NAME,
  icon = None,
  typeId = None 
)
Create a SObject to store an :class:`ExchangeVariables` instance.

:type  fatherSobj: SObject
:param fatherSobj: parent of the SObject to create.

:type  exchangeVariables: :class:`ExchangeVariables`
:param exchangeVariables: :class:`ExchangeVariables` instance to store in
                          Salome study.

:type  name: string
:param name: name of the SObject to create.

:type  icon: string
:param icon: icon of the SObject to create.

:type  typeId: integer
:param typeId: type of the SObject to create.

:return: the newly created SObject.

Definition at line 112 of file study_exchange_vars.py.

00112 
00113                                       icon = None, typeId = None):
00114     """
00115     Create a SObject to store an :class:`ExchangeVariables` instance.
00116 
00117     :type  fatherSobj: SObject
00118     :param fatherSobj: parent of the SObject to create.
00119 
00120     :type  exchangeVariables: :class:`ExchangeVariables`
00121     :param exchangeVariables: :class:`ExchangeVariables` instance to store in
00122                               Salome study.
00123 
00124     :type  name: string
00125     :param name: name of the SObject to create.
00126 
00127     :type  icon: string
00128     :param icon: icon of the SObject to create.
00129 
00130     :type  typeId: integer
00131     :param typeId: type of the SObject to create.
00132 
00133     :return: the newly created SObject.
00134 
00135     """
00136     studyId = fatherSobj.GetStudy()._get_StudyId()
00137     editor = getStudyEditor(studyId)
00138     sobj = editor.createItem(fatherSobj,
00139                              name = name,
00140                              icon = icon,
00141                              typeId = typeId)
00142     _setSObjectForExchangeVariables(editor, sobj, exchangeVariables)

Here is the call graph for this function:

Here is the caller graph for this function:

Get an :class:`ExchangeVariables` instance from a SObject that stores it.

:type  sobj: SObject
:param sobj: the SObject from which to read the :class:`ExchangeVariables`
             instance.

:return: the newly created :class:`ExchangeVariables` instance.

Definition at line 171 of file study_exchange_vars.py.

00171 
00172 def getExchangeVariablesFromSObject(sobj):
00173     """
00174     Get an :class:`ExchangeVariables` instance from a SObject that stores it.
00175 
00176     :type  sobj: SObject
00177     :param sobj: the SObject from which to read the :class:`ExchangeVariables`
00178                  instance.
00179 
00180     :return: the newly created :class:`ExchangeVariables` instance.
00181 
00182     """
00183     (found, attr) = sobj.FindAttribute("AttributeParameter")
00184     if not found:
00185         return None
00186     refEntry = None
00187     if attr.IsSet(REF_ENTRY, 3):
00188         refEntry = attr.GetString(REF_ENTRY)
00189     return ExchangeVariables(
00190             [Variable(name) for name in attr.GetStrArray(INPUT_VAR_NAMES)],
00191             [Variable(name) for name in attr.GetStrArray(OUTPUT_VAR_NAMES)],
00192             refEntry)

Load an :class:`ExchangeVariables` instance from an XML file.

:type  filepath: string
:param filepath: path of the XML file to load.

:return: the newly created :class:`ExchangeVariables` instance.

Definition at line 193 of file study_exchange_vars.py.

00193 
00194 def loadExchangeVariablesFromXmlFile(filepath):
00195     """
00196     Load an :class:`ExchangeVariables` instance from an XML file.
00197 
00198     :type  filepath: string
00199     :param filepath: path of the XML file to load.
00200 
00201     :return: the newly created :class:`ExchangeVariables` instance.
00202 
00203     """
00204     doc = parse(filepath)
00205     top_el = doc.documentElement
00206     # Check version
00207     version = top_el.getAttribute("version")
00208     if version != "6.4":
00209         raise Exception(self.tr("Unsupported version: %s" % version))
00210     input_variables_el = top_el.getElementsByTagName("input_variables")[0]
00211     input_var_list = [Variable(input_var_el.getAttribute("name"))
00212                       for input_var_el
00213                       in input_variables_el.getElementsByTagName("variable")]
00214     output_variables_el = top_el.getElementsByTagName("output_variables")[0]
00215     output_var_list = [Variable(output_var_el.getAttribute("name"))
00216                        for output_var_el
00217                        in output_variables_el.getElementsByTagName("variable")]
00218     return ExchangeVariables(input_var_list, output_var_list)
def KERNEL_PY.kernel.parametric.study_exchange_vars.updateSObjectForExchangeVariables (   sobj,
  exchangeVariables,
  name = DEFAULT_NAME,
  icon = None,
  typeId = None 
)
Update an existing SObject storing an :class:`ExchangeVariables` instance.

:type  sobj: SObject
:param sobj: the SObject to update.

See :func:`createSObjectForExchangeVariables` for the description of the
other parameters.

Definition at line 145 of file study_exchange_vars.py.

00145 
00146                                       icon = None, typeId = None):
00147     """
00148     Update an existing SObject storing an :class:`ExchangeVariables` instance.
00149 
00150     :type  sobj: SObject
00151     :param sobj: the SObject to update.
00152 
00153     See :func:`createSObjectForExchangeVariables` for the description of the
00154     other parameters.
00155 
00156     """
00157     studyId = sobj.GetStudy()._get_StudyId()
00158     editor = getStudyEditor(studyId)
00159     editor.setItem(sobj, name = name, icon = icon, typeId = typeId)
00160     editor.builder.RemoveAttribute(sobj, "AttributeParameter")
00161     _setSObjectForExchangeVariables(editor, sobj, exchangeVariables)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 30 of file study_exchange_vars.py.

string KERNEL_PY.kernel.parametric.study_exchange_vars.INPUT_VAR_NAMES = "ExchangeVariables.InputVarNames"

Definition at line 31 of file study_exchange_vars.py.

string KERNEL_PY.kernel.parametric.study_exchange_vars.OUTPUT_VAR_NAMES = "ExchangeVariables.OutputVarNames"

Definition at line 32 of file study_exchange_vars.py.

string KERNEL_PY.kernel.parametric.study_exchange_vars.REF_ENTRY = "ExchangeVariables.RefEntry"

Definition at line 33 of file study_exchange_vars.py.