Back to index

salome-kernel  6.5.0
Public Member Functions | Public Attributes
KERNEL_PY.salome_notebook.NoteBook Class Reference

List of all members.

Public Member Functions

def __init__
def set
def get
def isVariable
def setAs
def setAsReal
def setAsInteger
def setAsBool
def check

Public Attributes

 myStudy

Detailed Description

Definition at line 70 of file salome_notebook.py.


Constructor & Destructor Documentation

def KERNEL_PY.salome_notebook.NoteBook.__init__ (   self,
  Study 
)

Definition at line 72 of file salome_notebook.py.

00072 
00073     def __init__(self, Study):
00074         self.myStudy = Study
    

Member Function Documentation

Definition at line 165 of file salome_notebook.py.

00165 
00166     def check(self):
00167         for variableName in self.myStudy.GetVariableNames():
00168             self.get(variableName)
00169             pass
00170         return
    

Here is the call graph for this function:

def KERNEL_PY.salome_notebook.NoteBook.get (   self,
  variableName 
)
Return value of the variable with name "variableName".

Definition at line 92 of file salome_notebook.py.

00092 
00093     def get(self, variableName):
00094         """
00095         Return value of the variable with name "variableName".
00096         """
00097         aResult = None
00098         if self.myStudy.IsVariable(variableName):
00099             
00100             if self.myStudy.IsReal(variableName):
00101                 aResult = self.myStudy.GetReal(variableName)
00102 
00103             elif self.myStudy.IsInteger(variableName):
00104                 aResult = self.myStudy.GetInteger(variableName)
00105 
00106             elif self.myStudy.IsBoolean(variableName):
00107                 aResult = self.myStudy.GetBoolean(variableName)
00108 
00109             elif self.myStudy.IsString(variableName):
00110                 aResult = self.myStudy.GetString(variableName)
00111                 aResult_orig = aResult
00112                 l = self.myStudy.GetVariableNames()
00113                 l.remove(variableName)
00114                 # --
00115                 # To avoid the smallest strings to be replaced first,
00116                 # the list is sorted by decreasing lengths
00117                 # --
00118                 l.sort(key=str.__len__)
00119                 l.reverse()
00120                 for name in l:
00121                     if aResult.find(name) >= 0:
00122                         val = self.get(name)
00123                         aResult = aResult.replace(name, "%s"%(val))
00124                         pass
00125                     pass
00126                 try:
00127                     aResult = eval(aResult)
00128                 except Exception, e:
00129                     msg = str(e)
00130                     msg += "\n"
00131                     msg += "A problem occurs while parsing "
00132                     msg += "the variable %s "%(variableName.__repr__())
00133                     msg += "with value %s ..."%(aResult_orig.__repr__())
00134                     msg += "\n"
00135                     msg += "Please, check your notebook !"
00136                     raise Exception(msg)
00137                 pass
00138                 
00139         return aResult
    

Here is the call graph for this function:

Here is the caller graph for this function:

def KERNEL_PY.salome_notebook.NoteBook.isVariable (   self,
  variableName 
)
Return true if variable with name "variableName" 
exists in the study, otherwise return false.

Definition at line 140 of file salome_notebook.py.

00140 
00141     def isVariable(self, variableName): 
00142         """
00143         Return true if variable with name "variableName" 
00144         exists in the study, otherwise return false.
00145         """
00146         return self.myStudy.IsVariable(variableName)

def KERNEL_PY.salome_notebook.NoteBook.set (   self,
  variableName,
  variable 
)
Create (or modify) variable with name "variableName" 
and value equal "theValue".

Definition at line 75 of file salome_notebook.py.

00075 
00076     def set(self, variableName, variable):
00077         """
00078         Create (or modify) variable with name "variableName" 
00079         and value equal "theValue".
00080         """
00081         if type(variable) == float:
00082             self.myStudy.SetReal(variableName, variable)
00083             
00084         elif type(variable) == int:
00085             self.myStudy.SetInteger(variableName, variable)
00086             
00087         elif type(variable) == bool:
00088             self.myStudy.SetBoolean(variableName, variable)
00089             
00090         elif type(variable) == str:
00091             self.myStudy.SetString(variableName, variable)
            
def KERNEL_PY.salome_notebook.NoteBook.setAs (   self,
  variableName,
  typ 
)

Definition at line 147 of file salome_notebook.py.

00147 
00148     def setAs(self, variableName, typ):
00149         value = self.get(variableName)
00150         value = float(typ(value))
00151         self.myStudy.SetStringAsDouble(variableName, value)
00152         return
    

Here is the call graph for this function:

Here is the caller graph for this function:

def KERNEL_PY.salome_notebook.NoteBook.setAsBool (   self,
  variableName 
)

Definition at line 161 of file salome_notebook.py.

00161 
00162     def setAsBool(self, variableName):
00163         self.setAs(variableName, bool)
00164         return
    

Here is the call graph for this function:

def KERNEL_PY.salome_notebook.NoteBook.setAsInteger (   self,
  variableName 
)

Definition at line 157 of file salome_notebook.py.

00157 
00158     def setAsInteger(self, variableName):
00159         self.setAs(variableName, int)
00160         return
    

Here is the call graph for this function:

def KERNEL_PY.salome_notebook.NoteBook.setAsReal (   self,
  variableName 
)

Definition at line 153 of file salome_notebook.py.

00153 
00154     def setAsReal(self, variableName):
00155         self.setAs(variableName, float)
00156         return
    

Here is the call graph for this function:


Member Data Documentation

Definition at line 73 of file salome_notebook.py.


The documentation for this class was generated from the following file: