5 import SALOME_Session_idl
15 _AP_LISTS_LIST_ = "AP_LISTS_LIST"
16 _AP_ENTRIES_LIST_ = "AP_ENTRIES_LIST"
17 _AP_PROPERTIES_LIST_ = "AP_PROPERTIES_LIST"
18 _AP_DUMP_PYTHON_ = "AP_DUMP_PYTHON"
24 if vp_session is None:
25 vp_session = salome.naming_service.Resolve("/Kernel/Session")
26 vp_session = vp_session._narrow(SALOME.Session)
31 def __init__(self, attributeParameter):
32 """Initializes the instance"""
33 self._ap = attributeParameter
36 def append(self, listName, value):
37 """Appends a value to the named list"""
38 if self._ap is None: return -1
40 if self._ap.IsSet(listName, PT_STRARRAY) == 0:
41 if self._ap.IsSet(_AP_LISTS_LIST_, PT_STRARRAY) == 0: self._ap.SetStrArray(_AP_LISTS_LIST_, v);
42 if listName != _AP_ENTRIES_LIST_ and listName != _AP_PROPERTIES_LIST_:
43 self.append(_AP_LISTS_LIST_, listName)
45 self._ap.SetStrArray(listName, v)
48 v = self._ap.GetStrArray(listName)
50 self._ap.SetStrArray(listName, v)
53 def nbValues(self, listName):
54 """Returns a number of values in the named list"""
55 if self._ap is None: return -1
56 if self._ap.IsSet(listName, PT_STRARRAY) == 0: return 0
57 v = self._ap.GetStrArray(listName)
60 def getValues(self, listName):
61 """Returns a list of values in the named list"""
63 if self._ap is None: return v
64 if self._ap.IsSet(listName, PT_STRARRAY) == 0: return v
65 return self._ap.GetStrArray(listName)
68 """Returns a list of named lists' names"""
70 if self._ap is None: return v
71 if self._ap.IsSet(_AP_LISTS_LIST_, PT_STRARRAY) == 0: return v
72 return self._ap.GetStrArray(_AP_LISTS_LIST_)
74 def setParameter(self, entry, parameterName, value):
75 """Sets a value of the named parameter for the entry"""
76 if self._ap is None: return
78 if self._ap.IsSet(entry, PT_STRARRAY) ==0:
79 self.append(_AP_ENTRIES_LIST_, entry) #Add the entry to the internal list of entries
80 self._ap.SetStrArray(entry, v)
83 v = self._ap.GetStrArray(entry)
84 v.append(parameterName)
86 self._ap.SetStrArray(entry, v)
89 def getParameter(self, entry, parameterName):
90 """Returns a value of the named parameter for the entry"""
91 if self._ap is None: return ""
92 if self._ap.IsSet(entry, PT_STRARRAY) == 0: return ""
93 v = self._ap.GetStrArray(entry)
97 if v[i] == parameterName: return v[i+1]
103 def getAllParameterNames(self, entry):
104 """Returns all parameter names of the given entry"""
107 if self._ap is None: return v
108 if self._ap.IsSet(entry, PT_STRARRAY) == 0: return v
109 v = self._ap.GetStrArray(entry)
119 def getAllParameterValues(self, entry):
120 """Returns all parameter values of the given entry"""
123 if self._ap is None: return v
124 if self._ap.IsSet(entry, PT_STRARRAY) == 0: return v
125 v = self._ap.GetStrArray(entry)
129 values.append(v[i]+1)
135 def getNbParameters(self, entry):
136 """Returns a number of parameters of the entry"""
137 if self._ap is None: return -1
138 if self._ap.IsSet(entry, PT_STRARRAY) == 0: return -1
139 return len(self._ap.GetStrArray(entry))/2
141 def getEntries(self):
142 """Returns all entries"""
144 if self._ap is None: return v
145 if self._ap.IsSet(_AP_ENTRIES_LIST_, PT_STRARRAY) == 0: return v
146 return self._ap.GetStrArray(_AP_ENTRIES_LIST_)
148 def setProperty(self, name, value):
149 """Sets a property value"""
150 if self._ap is None: return
151 if self._ap.IsSet(name, PT_STRING) == 0:
152 self.append(_AP_PROPERTIES_LIST_, name) #Add the property to the internal list of properties
154 self._ap.SetString(name, value)
157 def getProperty(self, name):
158 """Returns a value of the named property"""
159 if self._ap is None: return ""
160 if self._ap.IsSet(name, PT_STRING) == 0: return ""
161 return self._ap.GetString(name)
163 def getProperties(self):
164 """Returns all propetries"""
166 if self._ap is None: return v
167 if self._ap.IsSet(_AP_PROPERTIES_LIST_, PT_STRARRAY) == 0: return v
168 return self._ap.GetStrArray(_AP_PROPERTIES_LIST_)
170 def parseValue(self, value, separator, fromEnd):
171 """Breaks a value string in two parts which is divided by separator."""
174 if fromEnd == 1: pos = value.rfind(separator)
175 else: pos = value.find(separator)
182 part2 = value[pos+1:len(value)]
187 def setDumpPython(self, isDumping):
188 """Enables/Disables the dumping to Python"""
189 if self._ap is None: return
190 _ap.SetBool(_AP_DUMP_PYTHON_, isDumping)
193 def isDumpPython(self):
194 """Returns whether there is the dumping to Python"""
195 if self._ap is None: return 0
196 if self._ap.IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN) == 0: return 0
197 return self._ap.GetBool(_AP_DUMP_PYTHON_)