|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |

Public Member Functions | |
| def | __init__ |
| def | getInterface |
| def | retrieveInterface |
| def | __call_interface_method__ |
| def | __setattr__ |
| def | __getattr__ |
| def | properties |
| def | name |
Python equivalent to the C++ Property interface
Definition at line 164 of file Bindings.py.
| def GaudiPython::Bindings::iProperty::__init__ | ( | self, | ||
| name, | ||||
ip = None | ||||
| ) |
Reimplemented in GaudiPython::Bindings::iService, GaudiPython::Bindings::iAlgorithm, GaudiPython::Bindings::iAlgTool, GaudiPython::Bindings::iDataSvc, GaudiPython::Bindings::iHistogramSvc, GaudiPython::Bindings::iNTupleSvc, GaudiPython::Bindings::iToolSvc, and GaudiPython::Bindings::iJobOptSvc.
Definition at line 166 of file Bindings.py.
00166 : 00167 if ip : self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip) 00168 else : self.__dict__['_ip'] = None 00169 self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator() 00170 optsvc = Helper.service(self._svcloc,'JobOptionsSvc') 00171 if optsvc : self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(optsvc) 00172 else : self.__dict__['_optsvc'] = None 00173 self.__dict__['_name'] = name def getInterface(self) :
| def GaudiPython::Bindings::iProperty::getInterface | ( | self | ) |
Definition at line 174 of file Bindings.py.
00174 : 00175 if not self._ip : self.retrieveInterface() 00176 return self._ip def retrieveInterface(self) :
| def GaudiPython::Bindings::iProperty::retrieveInterface | ( | self | ) |
Reimplemented in GaudiPython::Bindings::iService, GaudiPython::Bindings::iAlgorithm, and GaudiPython::Bindings::iAlgTool.
Definition at line 177 of file Bindings.py.
00177 : 00178 pass def __call_interface_method__(self,ifname,method,*args):
| def GaudiPython::Bindings::iProperty::__call_interface_method__ | ( | self, | ||
| ifname, | ||||
| method, | ||||
| args | ||||
| ) |
Definition at line 179 of file Bindings.py.
00179 : 00180 if not getattr(self,ifname) : self.retrieveInterface() 00181 return getattr(getattr(self,ifname),method)(*args) def __setattr__(self, name, value):
| def GaudiPython::Bindings::iProperty::__setattr__ | ( | self, | ||
| name, | ||||
| value | ||||
| ) |
The method which is used for setting the property from the given value. - In the case of the valid instance it sets the property through IProperty interface - In the case of placeholder the property is added to JobOptionsCatalogue
Definition at line 182 of file Bindings.py.
00182 : 00183 """ 00184 The method which is used for setting the property from the given value. 00185 - In the case of the valid instance it sets the property through IProperty interface 00186 - In the case of placeholder the property is added to JobOptionsCatalogue 00187 """ 00188 if hasattr( value, 'toStringProperty' ): 00189 # user defined behaviour 00190 value = '%s' % value.toStringProperty() 00191 ip = self.getInterface() 00192 if ip : 00193 if not gbl.Gaudi.Utils.hasProperty ( ip , name ) : 00194 raise AttributeError, 'property %s does not exist' % name 00195 prop = ip.getProperty(name) 00196 if not hasattr ( prop , 'value' ) or not type( value ) == type( prop.value() ) : 00197 if tuple == type( value ) : value = str(value) 00198 elif hasattr ( value , 'toString' ) : value = value.toString() 00199 elif not long == type( value ) : value = '%s' % value 00200 else : value = '%d' % value 00201 if prop.fromString( value ).isFailure() : 00202 raise AttributeError, 'property %s could not be set from %s' % (name,value) 00203 else : 00204 if not prop.setValue( value ) : 00205 raise AttributeError, 'property %s could not be set from %s' % (name,value) 00206 else : 00207 if type(value) == str : value = '"%s"' % value # need double quotes 00208 elif type(value) == tuple : value = str(value) 00209 elif hasattr( value , 'toString' ) : value = value.toString() 00210 elif type(value) == long: value = '%d' % value # prevent pending 'L' 00211 sp = StringProperty( name , str(value)) 00212 self._optsvc.addPropertyToCatalogue( self._name , sp ) def __getattr__(self, name ):
| def GaudiPython::Bindings::iProperty::__getattr__ | ( | self, | ||
| name | ||||
| ) |
The method which returns the value for the given property - In the case of the valid instance it returns the valid property value through IProperty interface - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
Definition at line 213 of file Bindings.py.
00213 : 00214 """ 00215 The method which returns the value for the given property 00216 - In the case of the valid instance it returns the valid property value through IProperty interface 00217 - In the case of placeholder the property value is retrieved from JobOptionsCatalogue 00218 """ 00219 ip = self.getInterface() 00220 if ip : 00221 if not gbl.Gaudi.Utils.hasProperty ( ip , name ) : 00222 raise AttributeError, 'property %s does not exist' % name 00223 prop = ip.getProperty(name) 00224 if StringProperty == type( prop ) : return prop.value() 00225 elif StringPropertyRef == type( prop ) : return prop.value() 00226 try: return eval( prop.toString(), {}, {} ) 00227 except : return prop.value() 00228 else : 00229 props = self._optsvc.getProperties(self._name) 00230 for p in props : 00231 if not p.name() == name : continue 00232 # from JobOptionsSvc we always have only strings 00233 try: return eval( p.value(), {}, {} ) 00234 except: return p.value() 00235 raise AttributeError, 'property %s does not exist' % name def properties(self):
| def GaudiPython::Bindings::iProperty::properties | ( | self | ) |
Definition at line 236 of file Bindings.py.
00236 : 00237 dct = {} 00238 props = None 00239 ip = self.getInterface() 00240 if ip : 00241 props = ip.getProperties() 00242 propsFrom = self._name # "interface" 00243 else: 00244 props = self._optsvc.getProperties( self._name ) 00245 propsFrom = "jobOptionsSvc" 00246 if props: 00247 for p in props : 00248 try: 00249 dct[p.name()] = PropertyEntry(p) 00250 except (ValueError,TypeError),e: 00251 raise ValueError, "gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \ 00252 (e.__class__.__name__, e.args, propsFrom, p.name(), p.value()) 00253 return dct def name(self) :
| def GaudiPython::Bindings::iProperty::name | ( | self | ) |
Reimplemented in GaudiPython::Bindings::iAlgTool.
Definition at line 254 of file Bindings.py.
00254 : 00255 return self._name 00256 00257 #----iService class--------------------------------------------------------------------- class iService(iProperty) :