Public Member Functions | |
def | __delattr__ |
def | __init__ |
def | __repr__ |
def | __setattr__ |
def | dumpPython |
def | getParameter |
def | hasParameter |
def | insertContentsInto |
def | isFrozen |
def | isModified |
def | parameterNames_ |
def | parameters_ |
def | setIsFrozen |
Private Member Functions | |
def | __addParameter |
def | __raiseBadSetAttr |
def | __setParameters |
Private Attributes | |
_isFrozen | |
_isModified |
Base class for classes which allow addition of _ParameterTypeBase data
def Mixins::_Parameterizable::__init__ | ( | self, | |
arg, | |||
kargs | |||
) |
Definition at line 110 of file Mixins.py.
00111 : 00112 self.__dict__['_Parameterizable__parameterNames'] = [] 00113 self.__dict__["_isFrozen"] = False 00114 """The named arguments are the 'parameters' which are added as 'python attributes' to the object""" 00115 if len(arg) != 0: 00116 #raise ValueError("unnamed arguments are not allowed. Please use the syntax 'name = value' when assigning arguments.") 00117 for block in arg: 00118 if type(block).__name__ != "PSet": 00119 raise ValueError("Only PSets can be passed as unnamed argument blocks. This is a "+type(block).__name__) 00120 self.__setParameters(block.parameters_()) 00121 self.__setParameters(kargs) 00122 self._isModified = False
def Mixins::_Parameterizable::__addParameter | ( | self, | |
name, | |||
value | |||
) | [private] |
Definition at line 178 of file Mixins.py.
00179 : 00180 if not isinstance(value,_ParameterTypeBase): 00181 self.__raiseBadSetAttr(name) 00182 if name in self.__dict__: 00183 message = "Duplicate insert of member " + name 00184 message += "\nThe original parameters are:\n" 00185 message += self.dumpPython() + '\n' 00186 raise ValueError(message) 00187 self.__dict__[name]=value 00188 self.__parameterNames.append(name) 00189 self._isModified = True
def Mixins::_Parameterizable::__delattr__ | ( | self, | |
name | |||
) |
def Mixins::_Parameterizable::__raiseBadSetAttr | ( | name | ) | [private] |
def Mixins::_Parameterizable::__repr__ | ( | self | ) |
def Mixins::_Parameterizable::__setattr__ | ( | self, | |
name, | |||
value | |||
) |
Definition at line 194 of file Mixins.py.
00195 : 00196 #since labels are not supposed to have underscores at the beginning 00197 # I will assume that if we have such then we are setting an internal variable 00198 if self.isFrozen() and not (name in ["_Labelable__label","_isFrozen"] or name.startswith('_')): 00199 message = "Object already added to a process. It is read only now\n" 00200 message += " %s = %s" %(name, value) 00201 message += "\nThe original parameters are:\n" 00202 message += self.dumpPython() + '\n' 00203 raise ValueError(message) 00204 # underscored names bypass checking for _ParameterTypeBase 00205 if name[0]=='_': 00206 super(_Parameterizable,self).__setattr__(name,value) 00207 elif not name in self.__dict__: 00208 self.__addParameter(name, value) 00209 self._isModified = True 00210 else: 00211 # handle the case where users just replace with a value, a = 12, rather than a = cms.int32(12) 00212 if isinstance(value,_ParameterTypeBase): 00213 self.__dict__[name] = value 00214 else: 00215 self.__dict__[name].setValue(value) 00216 self._isModified = True
def Mixins::_Parameterizable::__setParameters | ( | self, | |
parameters | |||
) | [private] |
def Mixins::_Parameterizable::dumpPython | ( | self, | |
options = PrintOptions() |
|||
) |
Reimplemented in Mixins::_TypedParameterizable.
Definition at line 231 of file Mixins.py.
00232 : 00233 others = [] 00234 usings = [] 00235 for name in self.parameterNames_(): 00236 param = self.__dict__[name] 00237 # we don't want minuses in names 00238 name2 = name.replace('-','_') 00239 options.indent() 00240 #_UsingNodes don't get assigned variables 00241 if name.startswith("using_"): 00242 usings.append(options.indentation()+param.dumpPython(options)) 00243 else: 00244 others.append(options.indentation()+name2+' = '+param.dumpPython(options)) 00245 options.unindent() 00246 # usings need to go first 00247 resultList = usings 00248 resultList.extend(others) return ',\n'.join(resultList)+'\n'
def Mixins::_Parameterizable::getParameter | ( | self, | |
params | |||
) |
_getParameter_ Retrieve the specified parameter from the PSet Provided given the attribute chain returns None if not found
Definition at line 150 of file Mixins.py.
00151 : 00152 """ 00153 _getParameter_ 00154 00155 Retrieve the specified parameter from the PSet Provided 00156 given the attribute chain 00157 00158 returns None if not found 00159 """ 00160 lastParam = self 00161 # Don't accidentally iterate over letters in a string 00162 if type(params).__name__ == 'str': 00163 return getattr(self, params, None) 00164 for param in params: 00165 lastParam = getattr(lastParam, param, None) 00166 print str(lastParam) 00167 if lastParam == None: 00168 return None 00169 return lastParam
def Mixins::_Parameterizable::hasParameter | ( | self, | |
params | |||
) |
_hasParameter_ check that pset provided has the attribute chain specified. Eg, if params is [ 'attr1', 'attr2', 'attr3' ] check for pset.attr1.attr2.attr3 returns True if parameter exists, False if not
Definition at line 136 of file Mixins.py.
00137 : 00138 """ 00139 _hasParameter_ 00140 00141 check that pset provided has the attribute chain 00142 specified. 00143 00144 Eg, if params is [ 'attr1', 'attr2', 'attr3' ] 00145 check for pset.attr1.attr2.attr3 00146 00147 returns True if parameter exists, False if not 00148 """ 00149 return (self.getParameter(params) != None)
def Mixins::_Parameterizable::insertContentsInto | ( | self, | |
parameterSet | |||
) |
def Mixins::_Parameterizable::isFrozen | ( | self | ) |
def Mixins::_Parameterizable::isModified | ( | self | ) |
def Mixins::_Parameterizable::parameterNames_ | ( | self | ) |
def Mixins::_Parameterizable::parameters_ | ( | self | ) |
Returns a dictionary of copies of the user-set parameters
def Mixins::_Parameterizable::setIsFrozen | ( | self | ) |
Mixins::_Parameterizable::_isFrozen [private] |
Mixins::_Parameterizable::_isModified [private] |