Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-31 22:34:53

0001 from __future__ import absolute_import
0002 from .Mixins import PrintOptions, _SimpleParameterTypeBase, _ParameterTypeBase, _Parameterizable, _ConfigureComponent, _Labelable, _TypedParameterizable, _Unlabelable, _modifyParametersFromDict
0003 from .Mixins import _ValidatingParameterListBase, specialImportRegistry
0004 from .Mixins import saveOrigin
0005 from .ExceptionHandling import format_typename, format_outerframe
0006 from past.builtins import long
0007 import codecs
0008 import copy
0009 import math
0010 import builtins
0011 
0012 _builtin_bool = bool
0013 
0014 class _Untracked(object):
0015     """Class type for 'untracked' to allow nice syntax"""
0016     __name__ = "untracked"
0017     @staticmethod
0018     def __call__(param):
0019         """used to set a 'param' parameter to be 'untracked'"""
0020         param.setIsTracked(False)
0021         return param
0022     def __getattr__(self,name:str):
0023         """A factory which allows syntax untracked.name(value) to construct an
0024         instance of 'name' class which is set to be untracked"""
0025         if name == "__bases__": raise AttributeError  # isclass uses __bases__ to recognize class objects
0026         class Factory(object):
0027             def __init__(self,name):
0028                 self.name = name
0029             def __call__(self,*value,**params):
0030                 param = globals()[self.name](*value,**params)
0031                 return _Untracked.__call__(param)
0032         return Factory(name)
0033 
0034 untracked = _Untracked()
0035 
0036 
0037 class _ProxyParameter(_ParameterTypeBase):
0038     """Base class for Parameters which are proxies for other Parameter types"""
0039     def __init__(self,type):
0040         super(_ProxyParameter,self).__init__()
0041         self.__dict__["_ProxyParameter__type"] = type
0042         self.__dict__["_ProxyParameter__value"] = None
0043         if hasattr(self.__type,"_default") and self.__type._default is not None:
0044             self.setValue(self.__type._default)
0045     def setValue(self, value):
0046         v = self.__type(value)
0047         if not _ParameterTypeBase.isTracked(self):
0048             v = untracked(v)
0049         self.__dict__["_ProxyParameter__value"] = v
0050     def _checkAndReturnValueWithType(self, valueWithType):
0051         if isinstance(valueWithType, type(self)):
0052             return valueWithType
0053         if isinstance(self.__type, type):
0054             if isinstance(valueWithType, self.__type):
0055                 self.__dict__["_ProxyParameter__value"] = valueWithType
0056                 return self
0057             else:
0058                 raise TypeError("type {bad} does not match {expected}".format(bad=str(type(valueWithType)), expected = str(self.__type)))
0059         v = self.__type._setValueWithType(valueWithType)
0060         if not _ParameterTypeBase.isTracked(self):
0061             v = untracked(v)
0062         self.__dict__["_ProxyParameter__value"] = v
0063         return self
0064     def __getattr__(self, name:str):
0065         v =self.__dict__.get('_ProxyParameter__value', None)
0066         if name == '_ProxyParameter__value':
0067             return v
0068         if (not name.startswith('_')) and v is not None:
0069             return getattr(v, name)
0070         else:
0071             return object.__getattribute__ (self, name)
0072     def __setattr__(self,name:str, value):
0073         v = self.__dict__.get('_ProxyParameter__value',None)
0074         if v is not None:
0075             return setattr(v,name,value)
0076         else:
0077             if not name.startswith('_'):
0078                  raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, name))
0079             return object.__setattr__(self, name, value)
0080     #support container like behavior
0081     def __iter__(self):
0082         v =self.__dict__.get('_ProxyParameter__value', None)
0083         if v is not None:
0084             return v.__iter__()
0085         else:
0086             raise TypeError("'_ProxyParameter' object is not iterable")
0087     def __setitem__(self, key, value):
0088         v =self.__dict__.get('_ProxyParameter__value', None)
0089         if v is not None:
0090             return v.__setitem__(key,value)
0091         else:
0092             raise TypeError("'_ProxyParameter' object does not support item assignment")
0093     def __getitem__(self, key):
0094         v =self.__dict__.get('_ProxyParameter__value', None)
0095         if v is not None:
0096             return v.__getitem__(key)
0097         else:
0098             raise TypeError("'_ProxyParameter' object is not subscriptable")
0099     def __bool__(self):
0100         v = self.__dict__.get('_ProxyParameter__value',None)
0101         return _builtin_bool(v)
0102     def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
0103         v =self.__dict__.get('_ProxyParameter__value',None)
0104         if v is not None:
0105             return v.dumpPython(options)
0106         specialImportRegistry.registerUse(self)
0107         v = "cms."+self._dumpPythonName()
0108         if not _ParameterTypeBase.isTracked(self):
0109             v+=".untracked"
0110         if hasattr(self.__type, "__name__"):
0111             return v+'.'+self.__type.__name__
0112         return v+'.'+self.__type.dumpPython(options)
0113     def validate_(self,value) -> bool:
0114         return isinstance(value,self.__type)
0115     def convert_(self,value):
0116         v = self.__type(value)
0117         if not _ParameterTypeBase.isTracked(self):
0118             v = untracked(v)
0119         return v
0120     def isCompatibleCMSType(self,aType) -> bool:
0121         v = self.__dict__.get('_ProxyParameter__value',None)
0122         if v is not None:
0123             return v.isCompatibleCMSType(aType)
0124         return self.__type == aType
0125 
0126 class _RequiredParameter(_ProxyParameter):
0127     @staticmethod
0128     def _dumpPythonName() -> str:
0129         return 'required'
0130     def insertInto(self, parameterSet, myname:str):
0131         v = self.__dict__.get('_ProxyParameter__value', None)
0132         if v is None:
0133             raise RuntimeError("Required parameter "+myname+" was not set")
0134         v.insertInto(parameterSet,myname)
0135 
0136 class _OptionalParameter(_ProxyParameter):
0137     @staticmethod
0138     def _dumpPythonName() -> str:
0139         return 'optional'
0140     def insertInto(self, parameterSet, myname:str):
0141         v = self.__dict__.get('_ProxyParameter__value', None)
0142         if v is not None:
0143             v.insertInto(parameterSet,myname)
0144     def value(self):
0145         v = self.__dict__.get('_ProxyParameter__value', None)
0146         if v is not None:
0147             return v.value()
0148         return None
0149 
0150 class _ObsoleteParameter(_OptionalParameter):
0151     @staticmethod
0152     def _dumpPythonName() -> str:
0153         return 'obsolete'
0154 
0155 class _AllowedParameterTypes(object):
0156     def __init__(self, *args, default=None):
0157         self.__dict__['_AllowedParameterTypes__types'] = args
0158         self.__dict__['_default'] = None
0159         self.__dict__['__name__'] = self.dumpPython()
0160         if default is not None:
0161             self.__dict__['_default'] = self._setValueWithType(default)
0162     def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
0163         specialImportRegistry.registerUse(self)
0164         return "allowed("+','.join( ("cms."+t.__name__ if not isinstance(t, _PSetTemplate) else "cms."+t.dumpPython() for t in self.__types))+')'
0165     def __call__(self,value):
0166         chosenType = None
0167         for t in self.__types:
0168             if not isinstance(t, _PSetTemplate) and isinstance(value, t):
0169                 return value
0170             if t._isValid(value):
0171                 if chosenType is not None:
0172                     raise RuntimeError("Ambiguous type conversion for 'allowed' parameter")
0173                 chosenType = t
0174         if chosenType is None:
0175             raise RuntimeError("Cannot convert "+str(value)+" to 'allowed' type")
0176         return chosenType(value)
0177     def _setValueWithType(self, valueWithType):
0178         for t in self.__types:
0179             if isinstance(t, _PSetTemplate):
0180                 if isinstance(valueWithType, PSet):
0181                     return valueWithType
0182             elif isinstance(valueWithType, t):
0183                 return valueWithType
0184         raise TypeError("type {bad} is not one of 'allowed' types {types}".format(bad=str(type(valueWithType)), types = ",".join( (str(t) for t in self.__types))) )
0185             
0186 
0187 
0188 class _PSetTemplate(object):
0189     def __init__(self, *args, **kargs):
0190         self._pset = PSet(*args,**kargs)
0191     def __call__(self, value):
0192         self.__dict__
0193         return self._pset.clone(**value)
0194     def _isValid(self, value) -> bool:
0195         return isinstance(value,dict) or isinstance(value, PSet)
0196     def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
0197         return "PSetTemplate(\n"+_Parameterizable.dumpPython(self._pset, options)+options.indentation()+")"
0198     def _setValueWithType(self, valueWithType):
0199         if not isinstance(valueWithType, PSet):
0200             raise TypeError("type {bad} is not a PSet".format(bas=str(type(valueWithType))))
0201         return valueWithType
0202 
0203 PSetTemplate = _PSetTemplate
0204 
0205 class _ProxyParameterFactory(object):
0206     """Class type for ProxyParameter types to allow nice syntax"""
0207     def __init__(self, type, isUntracked:bool = False):
0208         self.__isUntracked = isUntracked
0209         self.__type = type
0210     def __getattr__(self,name:str):
0211         if name[0] == '_':
0212             return object.__getattribute__(self,name)
0213         if name == 'untracked':
0214             return _ProxyParameterFactory(self.__type,isUntracked=True)
0215         if name == 'allowed':
0216             class _AllowedWrapper(object):
0217                 def __init__(self, untracked, type):
0218                     self.untracked = untracked
0219                     self.type = type
0220                 def __call__(self, *args, **kargs):
0221                     if self.untracked:
0222                         return untracked(self.type(_AllowedParameterTypes(*args, **kargs)))
0223                     return self.type(_AllowedParameterTypes(*args, **kargs))
0224             
0225             return _AllowedWrapper(self.__isUntracked, self.__type)
0226         if name == 'PSetTemplate':
0227             class _PSetTemplateWrapper(object):
0228                 def __init__(self, untracked, type):
0229                     self.untracked = untracked
0230                     self.type = type
0231                 def __call__(self,*args,**kargs):
0232                     if self.untracked:
0233                         return untracked(self.type(_PSetTemplate(*args,**kargs)))
0234                     return self.type(_PSetTemplate(*args,**kargs))
0235             return _PSetTemplateWrapper(self.__isUntracked, self.__type)
0236 
0237         type = globals()[name]
0238         if not issubclass(type, _ParameterTypeBase):
0239             raise AttributeError
0240         if self.__isUntracked:
0241                 return untracked(self.__type(type))
0242         return self.__type(type)
0243 
0244 required = _ProxyParameterFactory(_RequiredParameter)
0245 optional = _ProxyParameterFactory(_OptionalParameter)
0246 obsolete = _ProxyParameterFactory(_ObsoleteParameter)
0247 
0248 class int32(_SimpleParameterTypeBase):
0249     @staticmethod
0250     def _isValid(value) -> bool:
0251         return isinstance(value,int)
0252     @staticmethod
0253     def _valueFromString(value:str):
0254         """only used for cfg-parsing"""
0255         if len(value) >1 and '0x' == value[:2]:
0256             return int32(int(value,16))
0257         return int32(int(value))
0258     def insertInto(self, parameterSet, myname:str):
0259         parameterSet.addInt32(self.isTracked(), myname, self.value())
0260     def __nonzero__(self) -> bool:
0261         return self.value()!=0
0262     def __bool__(self) -> bool:
0263         return self.__nonzero__()
0264 
0265 
0266 class uint32(_SimpleParameterTypeBase):
0267     @staticmethod
0268     def _isValid(value) -> bool:
0269         return ((isinstance(value,int) and value >= 0) or
0270                 (isinstance(value,long) and value >= 0) and value <= 0xFFFFFFFF)
0271     @staticmethod
0272     def _valueFromString(value:str):
0273         """only used for cfg-parsing"""
0274         if len(value) >1 and '0x' == value[:2]:
0275             return uint32(long(value,16))
0276         return uint32(long(value))
0277     def insertInto(self, parameterSet, myname):
0278         parameterSet.addUInt32(self.isTracked(), myname, self.value())
0279     def __nonzero__(self) -> bool:
0280         return self.value()!=0
0281     def __bool__(self) -> bool:
0282         return self.__nonzero__()
0283 
0284 
0285 
0286 class int64(_SimpleParameterTypeBase):
0287     @staticmethod
0288     def _isValid(value) -> bool:
0289         return isinstance(value,int) or (
0290             isinstance(value,long) and
0291             (-0x7FFFFFFFFFFFFFFF < value <= 0x7FFFFFFFFFFFFFFF) )
0292     @staticmethod
0293     def _valueFromString(value:str):
0294         """only used for cfg-parsing"""
0295         if len(value) >1 and '0x' == value[:2]:
0296             return uint32(long(value,16))
0297         return int64(long(value))
0298     def insertInto(self, parameterSet, myname:str):
0299         parameterSet.addInt64(self.isTracked(), myname, self.value())
0300     def __nonzero__(self) -> bool:
0301         return self.value()!=0
0302 
0303 
0304 
0305 class uint64(_SimpleParameterTypeBase):
0306     @staticmethod
0307     def _isValid(value) -> bool:
0308         return ((isinstance(value,int) and value >= 0) or
0309                 (isinstance(value,long) and value >= 0) and value <= 0xFFFFFFFFFFFFFFFF)
0310     @staticmethod
0311     def _valueFromString(value:str):
0312         """only used for cfg-parsing"""
0313         if len(value) >1 and '0x' == value[:2]:
0314             return uint32(long(value,16))
0315         return uint64(long(value))
0316     def insertInto(self, parameterSet, myname:str):
0317         parameterSet.addUInt64(self.isTracked(), myname, self.value())
0318     def __nonzero__(self) -> bool:
0319         return self.value()!=0
0320 
0321 
0322 
0323 class double(_SimpleParameterTypeBase):
0324     @staticmethod
0325     def _isValid(value) -> bool:
0326         return isinstance(value, (int, long, float))
0327     @staticmethod
0328     def _valueFromString(value:str):
0329         """only used for cfg-parsing"""
0330         return double(float(value))
0331     def insertInto(self, parameterSet, myname:str):
0332         parameterSet.addDouble(self.isTracked(), myname, float(self.value()))
0333     def __nonzero__(self) -> bool:
0334         return self.value()!=0.
0335     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
0336         return double._pythonValue(self._value)
0337     @staticmethod
0338     def _pythonValue(value) -> str:
0339         if math.isinf(value):
0340             if value > 0:
0341                 return "float('inf')"
0342             else:
0343                 return "-float('inf')"
0344         if math.isnan(value):
0345             return "float('nan')"
0346         return str(value)
0347 
0348 
0349 
0350 class bool(_SimpleParameterTypeBase):
0351     @staticmethod
0352     def _isValid(value) -> builtins.bool:
0353         return (isinstance(value,type(False)) or isinstance(value,type(True)))
0354     @staticmethod
0355     def _valueFromString(value:str):
0356         """only used for cfg-parsing"""
0357         if value.lower() in ('true', 't', 'on', 'yes', '1'):
0358             return bool(True)
0359         if value.lower() in ('false','f','off','no', '0'):
0360             return bool(False)
0361         try:
0362             return bool(builtins.bool(eval(value)))
0363         except:
0364             pass
0365         raise RuntimeError('can not make bool from string '+value)
0366     def insertInto(self, parameterSet, myname:str):
0367         parameterSet.addBool(self.isTracked(), myname, self.value())
0368     def __nonzero__(self) -> builtins.bool:
0369         return self.value()
0370     def __bool__(self) -> builtins.bool:
0371         return self.__nonzero__()
0372 
0373 
0374 class string(_SimpleParameterTypeBase):
0375     def __init__(self,value):
0376         super(string,self).__init__(value)
0377     @staticmethod
0378     def _isValid(value) -> builtins.bool:
0379         return isinstance(value,type(''))
0380     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
0381         return self.formatValueForConfig(self.value())
0382     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0383         return self.configValue(options)
0384     @staticmethod
0385     def formatValueForConfig(value) -> str:
0386         l = len(value)
0387         import sys
0388         if sys.version_info >= (3, 0): #python2 and python3 are different due to byptes vs strings
0389             import codecs
0390             t=codecs.escape_encode(value.encode('utf-8'))
0391             value = t[0].decode('utf-8')
0392         else: #be conservative and don't change the python2 version
0393             value = value.encode("string-escape")
0394         newL = len(value)
0395         if l != newL:
0396             #get rid of the hex encoding
0397             value=value.replace('\\x0','\\')
0398         if "'" in value:
0399             return '"'+value+'"'
0400         return "'"+value+"'"
0401     @staticmethod
0402     def _valueFromString(value:str):
0403         """only used for cfg-parsing"""
0404         return string(value)
0405     def insertInto(self, parameterSet, myname:str):
0406         value = self.value()
0407         #  doesn't seem to handle \0 correctly
0408         #if value == '\0':
0409         #    value = ''
0410         parameterSet.addString(self.isTracked(), myname, value)
0411     def __nonzero__(self) -> builtins.bool:
0412         return len(self.value()) !=0
0413     def __bool__(self) -> builtins.bool:
0414         return self.__nonzero__()
0415 
0416 
0417 class EventID(_ParameterTypeBase):
0418     def __init__(self, run, *args):
0419         super(EventID,self).__init__()
0420         if isinstance(run, str):
0421             v = self._valueFromString(run)
0422             self.__run = v.__run
0423             self.__luminosityBlock = v.__luminosityBlock
0424             self.__event = v.__event
0425         else:
0426             self.__run = run
0427             if len(args) == 1:
0428                 self.__luminosityBlock = 0
0429                 self.__event = args[0]
0430             elif len(args) == 2:
0431                 self.__luminosityBlock = args[0]
0432                 self.__event = args[1]
0433             else:
0434                 raise RuntimeError('EventID ctor must have 2 or 3 arguments')
0435     def setValue(self, value):
0436         if isinstance(value, str):
0437             v = self._valueFromString(value)
0438             self.__run = v.__run
0439             self.__luminosityBlock = v.__luminosityBlock
0440             self.__event = v.__event
0441         else:
0442             try:
0443                 iter(value)
0444                 self.__run = value[0]
0445                 if len(value) == 2:
0446                     self.__luminosityBlock = 0
0447                     self.__event = value[1]
0448                 elif len(value) == 3:
0449                     self.__luminosityBlock = value[1]
0450                     self.__event = value[2]
0451                 else:
0452                     raise RuntimeError('EventID setValue takes container of 2 or 3 elements')
0453             except TypeError:
0454                 #value is not iterable
0455                 raise RuntimeError('EventID setValue takes container of 2 or 3 elements')
0456     def run(self) -> int:
0457         return self.__run
0458     def luminosityBlock(self) -> int:
0459         return self.__luminosityBlock
0460     def event(self) -> int:
0461         return self.__event
0462     @staticmethod
0463     def _isValid(value) -> builtins.bool:
0464         return isinstance(value, str) or isinstance(value, EventID) or len(value) == 2 or len(value) == 3
0465     @staticmethod
0466     def _valueFromString(value:str):
0467         parts = value.split(":")
0468         run = parts[0]
0469         try:
0470             lumi = parts[1]
0471             event = parts[2]
0472         except IndexError:
0473             lumi = 0
0474             event = parts[1]             
0475         return EventID(int(run), int(lumi), int(event))
0476     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0477         return str(self.__run)+ ', '+str(self.__luminosityBlock)+ ', '+str(self.__event)
0478     def cppID(self, parameterSet):
0479         return parameterSet.newEventID(self.run(), self.luminosityBlock(), self.event())
0480     def insertInto(self, parameterSet, myname:str):
0481         parameterSet.addEventID(self.isTracked(), myname, self.cppID(parameterSet))
0482     def value(self) -> str:
0483         return str(self.__run)+':'+str(self.__luminosityBlock)+":"+str(self.__event)
0484 
0485 class LuminosityBlockID(_ParameterTypeBase):
0486     def __init__(self, run, block=None):
0487         super(LuminosityBlockID,self).__init__()
0488         if isinstance(run, str):
0489             v = self._valueFromString(run)
0490             self.__run = v.__run
0491             self.__block = v.__block
0492         else:
0493             self.__run = run
0494             self.__block = block
0495     def setValue(self, value):
0496         if isinstance(value, str):
0497             v = self._valueFromString(value)
0498             self.__run = v.__run
0499             self.__block = v.__block
0500         else:
0501             self.__run = value[0]
0502             self.__block = value[1]
0503     def run(self) -> int:
0504         return self.__run
0505     def luminosityBlock(self) -> int:
0506         return self.__block
0507     @staticmethod
0508     def _isValid(value) -> builtins.bool:
0509         return isinstance(value,str) or isinstance(value, LuminosityBlockID) or len(value) == 2
0510     @staticmethod
0511     def _valueFromString(value:str):
0512         """only used for cfg-parsing"""
0513         parts = value.split(":")
0514         return LuminosityBlockID(int(parts[0]), int(parts[1]))
0515     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0516         return str(self.__run)+ ', '+str(self.__block)
0517     def cppID(self, parameterSet):
0518         return parameterSet.newLuminosityBlockID(self.run(), self.luminosityBlock())
0519     def insertInto(self, parameterSet, myname:str):
0520         parameterSet.addLuminosityBlockID(self.isTracked(), myname, self.cppID(parameterSet))
0521     def value(self) -> str:
0522         return str(self.__run)+":"+str(self.__block)
0523 
0524 
0525 class LuminosityBlockRange(_ParameterTypeBase):
0526     def __init__(self, start, startSub=None, end=None, endSub=None):
0527         super(LuminosityBlockRange,self).__init__()
0528         if isinstance(start, str):
0529             parsed = self._valueFromString(start)
0530             self.__start    = parsed.__start
0531             self.__startSub = parsed.__startSub
0532             self.__end      = parsed.__end
0533             self.__endSub   = parsed.__endSub
0534         else:
0535             if startSub is not None and end is None:
0536                 self._valueFromContainer((start, startSub))
0537             else:
0538                 self._valueFromContainer(( start, startSub, end, endSub))
0539         if self.__end < self.__start:
0540             raise RuntimeError('LuminosityBlockRange '+str(self.__start)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endSub)+' out of order')
0541         # 0 luminosity block number is a special case that means no limit
0542         if self.__end == self.__start and (self.__endSub != 0 and self.__endSub < self.__startSub):
0543             raise RuntimeError('LuminosityBlockRange '+str(self.__start)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endSub)+' out of order')
0544     def setValue(self,value):
0545         if isinstance(value, str):
0546             parsed = self._valueFromString(value)
0547             self.__start    = parsed.__start
0548             self.__startSub = parsed.__startSub
0549             self.__end      = parsed.__end
0550             self.__endSub   = parsed.__endSub
0551         else:
0552             self._valueFromContainer(value)
0553         if self.__end < self.__start:
0554             raise RuntimeError('LuminosityBlockRange '+str(self.__start)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endSub)+' out of order')
0555         # 0 luminosity block number is a special case that means no limit
0556         if self.__end == self.__start and (self.__endSub != 0 and self.__endSub < self.__startSub):
0557             raise RuntimeError('LuminosityBlockRange '+str(self.__start)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endSub)+' out of order')
0558 
0559     def start(self) -> int:
0560         return self.__start
0561     def startSub(self) -> int:
0562         return self.__startSub
0563     def end(self) -> int:
0564         return self.__end
0565     def endSub(self) -> int:
0566         return self.__endSub
0567     @staticmethod
0568     def _isValid(value) -> builtins.bool:
0569         if isinstance(value, str):
0570             return True
0571         if isinstance(value, LuminosityBlockRange):
0572             return True
0573         try:
0574             if len(value) == 2:
0575                     return len(value[0])==2 and len(value[1])==2
0576             return len(value) == 4
0577         except:
0578             return False
0579         return False
0580     def _valueFromContainer(self, value):
0581         if len(value) == 2:
0582             if len(value[0]) != 2 or len(value[1]) != 2:
0583                 raise RuntimeError('LuminosityBlockRange set by a container must then contain elements which are len == 2')
0584             self.__start = value[0][0]
0585             self.__startSub = value[0][1]
0586             self.__end = value[1][0]
0587             self.__endSub = value[1][1]
0588         else:
0589             self.__start    = value[0]
0590             self.__startSub = value[1]
0591             self.__end      = value[2]
0592             self.__endSub   = value[3]
0593     @staticmethod
0594     def _valueFromString(value:str):
0595         """only used for cfg-parsing"""
0596         value = value.replace(' ','')
0597         parts = value.split("-")
0598         startParts = parts[0].split(":")
0599         try:
0600             endParts = parts[1].split(":")
0601         except IndexError:
0602             endParts = parts[0].split(":") # If just "1:2" turn into "1:2-1:2"
0603 
0604         if startParts[1].lower() == "0":
0605             startParts[1] = "1"
0606         elif startParts[1].lower() == "max":
0607             startParts[1] = "0"
0608         elif startParts[1].lower() == "min":
0609             startParts[1] = "1"
0610         if endParts[1].lower() == "max":
0611             endParts[1] = "0"
0612         elif endParts[1].lower() == "min":
0613             endParts[1] = "1"
0614         return LuminosityBlockRange(int(startParts[0]), int(startParts[1]),
0615                         int(endParts[0]), int(endParts[1]))
0616     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0617         return str(self.__start) + ', ' + str(self.__startSub) + ', ' \
0618              + str(self.__end)   + ', ' + str(self.__endSub)
0619     def cppID(self, parameterSet):
0620         return parameterSet.newLuminosityBlockRange(self.start(), self.startSub(),self.end(), self.endSub())
0621     def insertInto(self, parameterSet, myname:str):
0622         parameterSet.addLuminosityBlockRange(self.isTracked(), myname, self.cppID(parameterSet))
0623     def value(self) -> str:
0624         return str(self.__start)+":"+str(self.__startSub)+"-"+str(self.__end)+":"+str(self.__endSub)
0625 
0626 class EventRange(_ParameterTypeBase):
0627     def __init__(self, start, *args):
0628         super(EventRange,self).__init__()
0629         if isinstance(start, str):
0630             parsed = self._valueFromString(start)
0631             self.__start     = parsed.__start
0632             self.__startLumi = parsed.__startLumi
0633             self.__startSub  = parsed.__startSub
0634             self.__end       = parsed.__end
0635             self.__endLumi   = parsed.__endLumi
0636             self.__endSub    = parsed.__endSub
0637         else:
0638             if len(args) == 0:
0639                 self._valueFromContainer(start)
0640             else:
0641                 v = [start]
0642                 v.extend(args)
0643                 self._valueFromContainer(v)
0644         if self.__end < self.__start or (self.__end == self.__start and self.__endLumi < self.__startLumi):
0645             raise RuntimeError('EventRange '+str(self.__start)+':'+str(self.__startLumi)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endLumi)+':'+str(self.__endSub)+' out of order')
0646         # 0 event number is a special case that means no limit
0647         if self.__end == self.__start and self.__endLumi == self.__startLumi and (self.__endSub != 0 and self.__endSub < self.__startSub):
0648             raise RuntimeError('EventRange '+str(self.__start)+':'+str(self.__startLumi)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endLumi)+':'+str(self.__endSub)+' out of order')
0649     def setValue(self, value):
0650         if isinstance(value, str):
0651             parsed = self._valueFromString(value)
0652             self.__start     = parsed.__start
0653             self.__startLumi = parsed.__startLumi
0654             self.__startSub  = parsed.__startSub
0655             self.__end       = parsed.__end
0656             self.__endLumi   = parsed.__endLumi
0657             self.__endSub    = parsed.__endSub
0658         else:
0659             self._valueFromContainer(value)
0660         if self.__end < self.__start or (self.__end == self.__start and self.__endLumi < self.__startLumi):
0661             raise RuntimeError('EventRange '+str(self.__start)+':'+str(self.__startLumi)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endLumi)+':'+str(self.__endSub)+' out of order')
0662         # 0 event number is a special case that means no limit
0663         if self.__end == self.__start and self.__endLumi == self.__startLumi and (self.__endSub != 0 and self.__endSub < self.__startSub):
0664             raise RuntimeError('EventRange '+str(self.__start)+':'+str(self.__startLumi)+':'+str(self.__startSub)+'-'+str(self.__end)+':'+str(self.__endLumi)+':'+str(self.__endSub)+' out of order')
0665 
0666     def start(self) -> int:
0667         return self.__start
0668     def startLumi(self) -> int:
0669         return self.__startLumi
0670     def startSub(self) -> int:
0671         return self.__startSub
0672     def end(self) -> int:
0673         return self.__end
0674     def endLumi(self) -> int:
0675         return self.__endLumi
0676     def endSub(self) -> int:
0677         return self.__endSub
0678     @staticmethod
0679     def _isValid(value) -> builtins.bool:
0680         return True
0681     def _valueFromContainer(self, value):
0682         length = len(value)
0683         if length == 2:
0684             if len(value[0]) != 3 or len(value[1]) != 3:
0685                 raise RuntimeError('EventRange set with 2 arguments require the arguments to be a container with 3 elements')
0686             else:
0687                 self.__start = value[0][0]
0688                 self.__startLumi = value[0][1]
0689                 self.__startSub  = value[0][2]
0690                 self.__end       = value[1][0]
0691                 self.__endLumi   = value[1][1]
0692                 self.__endSub    = value[1][2]
0693         elif length == 4:
0694             self.__start     = value[0]
0695             self.__startLumi = 0
0696             self.__startSub  = value[1]
0697             self.__end       = value[2]
0698             self.__endLumi   = 0
0699             self.__endSub    = value[3]
0700         elif len(value) == 6:
0701             self.__start     = value[0]
0702             self.__startLumi = value[1]
0703             self.__startSub  = value[2]
0704             self.__end       = value[3]
0705             self.__endLumi   = value[4]
0706             self.__endSub    = value[5]
0707         else:
0708             raise RuntimeError('EventRange setValue must be set using 2, 4, or 6 arguments')
0709 
0710     @staticmethod
0711     def _valueFromString(value:str):
0712         """only used for cfg-parsing"""
0713         value = value.replace(' ','')
0714         parts = value.split("-")
0715         startParts = parts[0].split(":")
0716         try:
0717             endParts = parts[1].split(":")
0718         except IndexError:
0719             endParts = parts[0].split(":") # If just "1:2" turn into "1:2-1:2"
0720 
0721         brun = startParts[0]
0722         erun = endParts[0]
0723         s = len(startParts)
0724         e = len(endParts)
0725         if s != e or s < 2 or s > 3:
0726             raise RuntimeError('EventRange ctor must have 4 or 6 arguments')
0727         i = s - 1
0728         if startParts[i].lower() == "0":
0729             startParts[i] = "1"
0730         elif startParts[i].lower() == "max":
0731             startParts[i] = "0"
0732         elif startParts[i].lower() == "min":
0733             startParts[i] = "1"
0734         if endParts[i].lower() == "max":
0735             endParts[i] = "0"
0736         elif endParts[i].lower() == "min":
0737             endParts[i] = "1"
0738         if s == 3:
0739             blumi = startParts[1]
0740             elumi = endParts[1]
0741             bevent = startParts[2]
0742             eevent = endParts[2]
0743         elif s == 2:
0744             blumi = 0
0745             elumi = 0
0746             bevent = startParts[1]
0747             eevent = endParts[1]             
0748         else:
0749             raise RuntimeError('EventRange ctor must have 4 or 6 arguments')
0750         # note int will return a long if the value is too large to fit in
0751         # a smaller type
0752         return EventRange(int(brun), int(blumi), int(bevent),
0753                           int(erun), int(elumi), int(eevent))
0754 
0755     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0756         return str(self.__start) + ', ' + str(self.__startLumi) + ', ' + str(self.__startSub) + ', ' \
0757                + str(self.__end)  + ', ' + str(self.__endLumi) + ', ' + str(self.__endSub)
0758     def cppID(self, parameterSet):
0759         return parameterSet.newEventRange(self.start(), self.startLumi(), self.startSub(), self.end(), self.endLumi(), self.endSub())
0760     def insertInto(self, parameterSet, myname:str):
0761         parameterSet.addEventRange(self.isTracked(), myname, self.cppID(parameterSet))
0762     def value(self) -> str:
0763         return str(self.__start) + ":" + str(self.__startLumi) + ":" + str(self.__startSub) + "-" + \
0764                str(self.__end) + ":" + str(self.__endLumi) + ":" + str(self.__endSub)
0765 
0766 class InputTag(_ParameterTypeBase):
0767     def __init__(self,moduleLabel:str,productInstanceLabel:str='',processName:str=''):
0768         super(InputTag,self).__init__()
0769         self._setValues(moduleLabel, productInstanceLabel, processName)
0770     def getModuleLabel(self) -> str:
0771         return self.__moduleLabel
0772     def setModuleLabel(self,label:str):
0773         if self.__moduleLabel != label:
0774             self.__moduleLabel = label
0775             self._isModified=True
0776     moduleLabel = property(getModuleLabel,setModuleLabel,"module label for the product")
0777     def getProductInstanceLabel(self) -> str:
0778         return self.__productInstance
0779     def setProductInstanceLabel(self,label:str):
0780         if self.__productInstance != label:
0781             self.__productInstance = label
0782             self._isModified=True
0783     productInstanceLabel = property(getProductInstanceLabel,setProductInstanceLabel,"product instance label for the product")
0784     def getProcessName(self) -> str:
0785         return self.__processName
0786     def setProcessName(self,label:str):
0787         if self.__processName != label:
0788             self.__processName = label
0789             self._isModified=True
0790     processName = property(getProcessName,setProcessName,"process name for the product")
0791     @staticmethod
0792     def skipCurrentProcess() -> str:
0793         """When used as the process name this value will make the framework skip the current process
0794             when looking backwards in time for the data product.
0795         """
0796         return "@skipCurrentProcess"
0797     @staticmethod
0798     def currentProcess() -> str:
0799         """When used as the process name this value will make the framework use the current process
0800             as the process when looking for the data product.
0801         """
0802         return "@currentProcess"
0803     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
0804         result = self.__moduleLabel
0805         if self.__productInstance != "" or self.__processName != "":
0806             result += ':' + self.__productInstance
0807         if self.__processName != "":
0808             result += ':' + self.__processName
0809         if result == "":
0810             result = '\"\"'
0811         return result;
0812     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0813         cfgValue = self.configValue(options)
0814         # empty strings already have quotes
0815         if cfgValue == '\"\"':
0816             return cfgValue
0817         colonedValue = "\""+cfgValue+"\""
0818         # change label:instance:process to "label","instance","process"
0819         return colonedValue.replace(":","\",\"")
0820     @staticmethod
0821     def _isValid(value) -> builtins.bool:
0822         return True
0823     def __eq__(self,other) -> builtins.bool:
0824         return ((self.__moduleLabel,self.__productInstance,self.__processName) ==
0825                 (other.moduleLabel,other.productInstanceLabel,other.processName))
0826     def __ne__(self,other) -> builtins.bool:
0827         return ((self.__moduleLabel,self.__productInstance,self.__processName) !=
0828                 (other.moduleLabel,other.productInstanceLabel,other.processName))
0829     def __lt__(self,other) -> builtins.bool:
0830         return ((self.__moduleLabel,self.__productInstance,self.__processName) <
0831                 (other.moduleLabel,other.productInstanceLabel,other.processName))
0832     def __gt__(self,other) -> builtins.bool:
0833         return ((self.__moduleLabel,self.__productInstance,self.__processName) >
0834                 (other.moduleLabel,other.productInstanceLabel,other.processName))
0835     def __le__(self,other) -> builtins.bool:
0836         return ((self.__moduleLabel,self.__productInstance,self.__processName) <=
0837                 (other.moduleLabel,other.productInstanceLabel,other.processName))
0838     def __ge__(self,other) -> builtins.bool:
0839         return ((self.__moduleLabel,self.__productInstance,self.__processName) >=
0840                 (other.moduleLabel,other.productInstanceLabel,other.processName))
0841 
0842 
0843     def value(self) -> str:
0844         "Return the string rep"
0845         return self.configValue()
0846     @staticmethod
0847     def formatValueForConfig(value):
0848         return value.configValue()
0849     @staticmethod
0850     def _valueFromString(string:str):
0851         parts = string.split(":")
0852         return InputTag(*parts)
0853     @staticmethod
0854     def _stringFromArgument(arg):
0855         if isinstance(arg, InputTag):
0856             return arg
0857         elif isinstance(arg, str):
0858             if arg.count(":") > 2:
0859                 raise RuntimeError("InputTag may have at most 3 elements")
0860             return arg
0861         else:
0862             if len(arg) > 3:
0863                 raise RuntimeError("InputTag may have at most 3 elements")
0864             return ":".join(arg)
0865     def setValue(self,v):
0866         self._setValues(v)
0867         self._isModified=True
0868     def _setValues(self,moduleLabel,productInstanceLabel:str='',processName:str=''):
0869         self.__moduleLabel = InputTag._stringFromArgument(moduleLabel)
0870         self.__productInstance = productInstanceLabel
0871         self.__processName=processName
0872         if -1 != self.__moduleLabel.find(":"):
0873             toks = self.__moduleLabel.split(":")
0874             if len(toks) > 3:
0875                 raise RuntimeError("InputTag may have at most 3 elements")
0876             self.__moduleLabel = toks[0]
0877             if len(toks) > 1:
0878                 self.__productInstance = toks[1]
0879             if len(toks) > 2:
0880                 self.__processName=toks[2]
0881     # convert to the wrapper class for C++ InputTags
0882     def cppTag(self, parameterSet):
0883         return parameterSet.newInputTag(self.getModuleLabel(),
0884                                         self.getProductInstanceLabel(),
0885                                         self.getProcessName())
0886     def insertInto(self, parameterSet, myname:str):
0887         parameterSet.addInputTag(self.isTracked(), myname, self.cppTag(parameterSet))
0888 
0889 class ESInputTag(_ParameterTypeBase):
0890     def __init__(self,module='',data= None):
0891         super(ESInputTag,self).__init__()
0892         self._setValues(module, data)
0893     def getModuleLabel(self) -> str:
0894         return self.__moduleLabel
0895     def setModuleLabel(self,label:str):
0896         if self.__moduleLabel != label:
0897             self.__moduleLabel = label
0898             self._isModified=True
0899     moduleLabel = property(getModuleLabel,setModuleLabel,"module label for the product")
0900     def getDataLabel(self):
0901         return self.__data
0902     def setDataLabel(self,label:str):
0903         if self.__data != label:
0904             self.__data = label
0905             self._isModified=True
0906     dataLabel = property(getDataLabel,setDataLabel,"data label for the product")
0907     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
0908         result = self.__moduleLabel + ':' + self.__data
0909         if result == "":
0910             result = '\"\"'
0911         return result;
0912     def pythonValue(self, options:PrintOptions=PrintOptions()) -> str:
0913         cfgValue = self.configValue(options)
0914         # empty strings already have quotes
0915         if cfgValue == '\"\"':
0916             return cfgValue
0917         colonedValue = "\""+cfgValue+"\""
0918         # change label:instance:process to "label","instance","process"
0919         return colonedValue.replace(":","\",\"")
0920     @staticmethod
0921     def _isValid(value) -> builtins.bool:
0922         return True
0923     def __eq__(self,other) -> builtins.bool:
0924         return ((self.__moduleLabel,self.__data) == (other.__moduleLabel,other.__data))
0925     def __ne__(self,other) -> builtins.bool:
0926         return ((self.__moduleLabel,self.__data) != (other.__moduleLabel,other.__data))
0927     def __lt__(self,other) -> builtins.bool:
0928         return ((self.__moduleLabel,self.__data) < (other.__moduleLabel,other.__data))
0929     def __gt__(self,other) -> builtins.bool:
0930         return ((self.__moduleLabel,self.__data) > (other.__moduleLabel,other.__data))
0931     def __le__(self,other) -> builtins.bool:
0932         return ((self.__moduleLabel,self.__data) <= (other.__moduleLabel,other.__data))
0933     def __ge__(self,other) -> builtins.bool:
0934         return ((self.__moduleLabel,self.__data) >= (other.__moduleLabel,other.__data))
0935     def value(self):
0936         "Return the string rep"
0937         return self.configValue()
0938     @staticmethod
0939     def formatValueForConfig(value):
0940         return value.configValue()
0941     @staticmethod
0942     def _valueFromString(string:str):
0943         parts = string.split(":")
0944         return ESInputTag(*parts)
0945     @staticmethod
0946     def _stringFromArgument(arg, dataLabel=None):
0947         if isinstance(arg, ESInputTag):
0948             return arg
0949         elif isinstance(arg, str):
0950             if arg:
0951                 cnt = arg.count(":")
0952                 if dataLabel is None and cnt == 0:
0953                     raise RuntimeError("ESInputTag passed one string '"+str(arg)+"' which does not contain a ':'. Please add ':' to explicitly separate the module (1st) and data (2nd) label or use two strings.")
0954                 elif arg.count(":") >= 2:
0955                     raise RuntimeError("an ESInputTag was passed the value'"+arg+"' which contains more than one ':'")
0956             return arg
0957         else:
0958             if len(arg) > 2 or len(arg) == 1:
0959                 raise RuntimeError("ESInputTag must have either 2 or 0 elements")
0960             if len(arg) == 2:
0961                 return ":".join(arg)
0962             return ":"
0963     def setValue(self,v):
0964         self._setValues(v)
0965         self._isModified=True
0966     def _setValues(self,moduleLabel='',dataLabel=None):
0967         self.__moduleLabel = ESInputTag._stringFromArgument(moduleLabel, dataLabel)
0968         self.__data = dataLabel
0969         if dataLabel is None:
0970             if self.__moduleLabel:
0971                 toks = self.__moduleLabel.split(":")
0972                 self.__moduleLabel = toks[0]
0973                 if len(toks) > 1:
0974                     self.__data = toks[1]
0975             else:
0976                 self.__data = ''
0977             
0978 
0979     # convert to the wrapper class for C++ ESInputTags
0980     def cppTag(self, parameterSet):
0981         return parameterSet.newESInputTag(self.getModuleLabel(),
0982                                         self.getDataLabel())
0983     def insertInto(self, parameterSet, myname:str):
0984         parameterSet.addESInputTag(self.isTracked(), myname, self.cppTag(parameterSet))
0985 
0986 class FileInPath(_SimpleParameterTypeBase):
0987     def __init__(self,value:str=""):
0988         super(FileInPath,self).__init__(value)
0989     @staticmethod
0990     def _isValid(value) -> builtins.bool:
0991         return True
0992     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
0993         return string.formatValueForConfig(self.value())
0994     @staticmethod
0995     def formatValueForConfig(value):
0996         return string.formatValueForConfig(value)
0997     @staticmethod
0998     def _valueFromString(value:str):
0999         return FileInPath(value)
1000     def insertInto(self, parameterSet, myname:str):
1001         parameterSet.addNewFileInPath( self.isTracked(), myname, self.value() )
1002 
1003 class SecSource(_ParameterTypeBase,_TypedParameterizable,_ConfigureComponent,_Labelable):
1004     def __init__(self,type_,*arg,**args):
1005         _ParameterTypeBase.__init__(self)
1006         _TypedParameterizable.__init__(self,type_,*arg,**args)
1007     def value(self):
1008         return self
1009     @staticmethod
1010     def _isValid(value) -> builtins.bool:
1011         return True
1012     def configTypeName(self)-> str:
1013         return "secsource"
1014     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
1015         return self.dumpConfig(options)
1016     def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
1017         return _TypedParameterizable.dumpPython(self, options)
1018     def copy(self):
1019         # TODO is the one in TypedParameterizable better?
1020         return copy.copy(self)
1021     def _place(self,name:str,proc):
1022         proc._placePSet(name,self)
1023     def __str__(self) -> str:
1024         return object.__str__(self)
1025 
1026 class PSet(_ParameterTypeBase,_Parameterizable,_ConfigureComponent,_Labelable):
1027     def __init__(self,*arg,**args):
1028         #need to call the inits separately
1029         _ParameterTypeBase.__init__(self)
1030         _Parameterizable.__init__(self,*arg,**args)
1031     def value(self):
1032         return self
1033     def isRef_(self) -> builtins.bool:
1034         """Returns true if this PSet is actually a reference to a different PSet
1035             """
1036         return hasattr(self,"refToPSet_")
1037     @staticmethod
1038     def _isValid(value) -> builtins.bool:
1039         return isinstance(value,PSet) or isinstance(value,dict)
1040     def setValue(self,value):
1041         if isinstance(value,dict):
1042             for k,v in value.items():
1043                 setattr(self,k,v)
1044 
1045     def configValue(self, options:PrintOptions=PrintOptions()) -> str:
1046         config = '{ \n'
1047         for name in self.parameterNames_():
1048             param = getattr(self,name)
1049             options.indent()
1050             config+=options.indentation()+param.configTypeName()+' '+name+' = '+param.configValue(options)+'\n'
1051             options.unindent()
1052         config += options.indentation()+'}\n'
1053         return config
1054     def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
1055         return self.pythonTypeName()+"(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+")"
1056     # XXX FIXME handle refToPSet
1057     def directDependencies(self):
1058         return []
1059     def clone(self, **params):
1060         myparams = self.parameters_()
1061         if "allowAnyLabel_" in params:
1062             raise AttributeError("Not allowed to change `allowAnyLabel_` value in call to clone")
1063         _modifyParametersFromDict(myparams, params, self._Parameterizable__raiseBadSetAttr)
1064         if self._Parameterizable__validator is not None:
1065             myparams["allowAnyLabel_"] = self._Parameterizable__validator
1066         returnValue = PSet(**myparams)
1067         returnValue.setIsTracked(self.isTracked())
1068         returnValue._isModified = False
1069         returnValue._isFrozen = False
1070         return returnValue
1071     def copy(self):
1072         return copy.copy(self)
1073     def _place(self,name:str,proc):
1074         proc._placePSet(name,self)
1075     def __str__(self) -> str:
1076         return object.__str__(self)
1077     def insertInto(self, parameterSet, myname:str):
1078         newpset = parameterSet.newPSet()
1079         self.insertContentsInto(newpset)
1080         parameterSet.addPSet(self.isTracked(), myname, newpset)
1081     def insertContentsInto(self, parameterSet):
1082         if self.isRef_():
1083             ref = parameterSet.getTopPSet_(self.refToPSet_.value())
1084             ref.insertContentsInto(parameterSet)
1085         else:
1086             super(PSet, self).insertContentsInto(parameterSet)
1087 
1088 
1089 class vint32(_ValidatingParameterListBase):
1090     def __init__(self,*arg,**args):
1091         super(vint32,self).__init__(*arg,**args)
1092 
1093     @classmethod
1094     def _itemIsValid(cls,item) -> builtins.bool:
1095         return int32._isValid(item)
1096     @staticmethod
1097     def _valueFromString(value:str):
1098         return vint32(*_ValidatingParameterListBase._itemsFromStrings(value,int32._valueFromString))
1099     def insertInto(self, parameterSet, myname:str):
1100         parameterSet.addVInt32(self.isTracked(), myname, self.value())
1101 
1102 
1103 
1104 class vuint32(_ValidatingParameterListBase):
1105     def __init__(self,*arg,**args):
1106         super(vuint32,self).__init__(*arg,**args)
1107     @classmethod
1108     def _itemIsValid(cls,item) -> builtins.bool:
1109         return uint32._isValid(item)
1110     @staticmethod
1111     def _valueFromString(value:str):
1112         return vuint32(*_ValidatingParameterListBase._itemsFromStrings(value,uint32._valueFromString))
1113     def insertInto(self, parameterSet, myname:str):
1114         parameterSet.addVUInt32(self.isTracked(), myname, self.value())
1115 
1116 
1117 
1118 class vint64(_ValidatingParameterListBase):
1119     def __init__(self,*arg,**args):
1120         super(vint64,self).__init__(*arg,**args)
1121     @classmethod
1122     def _itemIsValid(cls,item) -> builtins.bool:
1123         return int64._isValid(item)
1124     @staticmethod
1125     def _valueFromString(value:str):
1126         return vint64(*_ValidatingParameterListBase._itemsFromStrings(value,int64._valueFromString))
1127     def insertInto(self, parameterSet, myname):
1128         parameterSet.addVInt64(self.isTracked(), myname, self.value())
1129 
1130 
1131 
1132 class vuint64(_ValidatingParameterListBase):
1133     def __init__(self,*arg,**args):
1134         super(vuint64,self).__init__(*arg,**args)
1135     @classmethod
1136     def _itemIsValid(cls,item) -> builtins.bool:
1137         return uint64._isValid(item)
1138     @staticmethod
1139     def _valueFromString(value:str):
1140         return vuint64(*_ValidatingParameterListBase._itemsFromStrings(value,vuint64._valueFromString))
1141     def insertInto(self, parameterSet, myname:str):
1142         parameterSet.addVUInt64(self.isTracked(), myname, self.value())
1143 
1144 
1145 
1146 class vdouble(_ValidatingParameterListBase):
1147     def __init__(self,*arg,**args):
1148         super(vdouble,self).__init__(*arg,**args)
1149     @classmethod
1150     def _itemIsValid(cls,item) -> builtins.bool:
1151         return double._isValid(item)
1152     @staticmethod
1153     def _valueFromString(value:str):
1154         return vdouble(*_ValidatingParameterListBase._itemsFromStrings(value,double._valueFromString))
1155     def insertInto(self, parameterSet, myname:str):
1156         parameterSet.addVDouble(self.isTracked(), myname, self.value())
1157     def pythonValueForItem(self,item, options) -> str:
1158         return double._pythonValue(item)
1159 
1160 
1161 
1162 
1163 class vbool(_ValidatingParameterListBase):
1164     def __init__(self,*arg,**args):
1165         super(vbool,self).__init__(*arg,**args)
1166     @classmethod
1167     def _itemIsValid(cls,item) -> builtins.bool:
1168         return bool._isValid(item)
1169     @staticmethod
1170     def _valueFromString(value:str):
1171         return vbool(*_ValidatingParameterListBase._itemsFromStrings(value,bool._valueFromString))
1172     def insertInto(self, parameterSet, myname:str):
1173         parameterSet.addVBool(self.isTracked(), myname, self.value())
1174 
1175 
1176 
1177 class vstring(_ValidatingParameterListBase):
1178     def __init__(self,*arg,**args):
1179         super(vstring,self).__init__(*arg,**args)
1180         self._nPerLine = 1
1181     @classmethod
1182     def _itemIsValid(cls,item) -> builtins.bool:
1183         return string._isValid(item)
1184     def configValueForItem(self,item,options) -> str:
1185         return string.formatValueForConfig(item)
1186     @staticmethod
1187     def _valueFromString(value:str):
1188         return vstring(*_ValidatingParameterListBase._itemsFromStrings(value,string._valueFromString))
1189     def insertInto(self, parameterSet, myname:str):
1190         parameterSet.addVString(self.isTracked(), myname, self.value())
1191 
1192 class VLuminosityBlockID(_ValidatingParameterListBase):
1193     def __init__(self,*arg,**args):
1194         super(VLuminosityBlockID,self).__init__(*arg,**args)
1195     @classmethod
1196     def _itemIsValid(cls,item):
1197         return LuminosityBlockID._isValid(item)
1198     def configValueForItem(self,item,options:PrintOptions) -> str:
1199         return LuminosityBlockID.formatValueForConfig(item)
1200     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1201         if isinstance(item,str):
1202             return '"'+item+'"'
1203         elif isinstance(item, _Parameterizable):
1204             return item.dumpPython(options)
1205         return str(item)
1206     @staticmethod
1207     def _valueFromString(value:str):
1208         return VLuminosityBlockID(*_ValidatingParameterListBase._itemsFromStrings(value,LuminosityBlockID._valueFromString))
1209     def insertInto(self, parameterSet, myname:str):
1210         cppIDs = list()
1211         for i in self:
1212             item = i
1213             if isinstance(item, str):
1214                 item = LuminosityBlockID._valueFromString(item)
1215             cppIDs.append(item.cppID(parameterSet))
1216         parameterSet.addVLuminosityBlockID(self.isTracked(), myname, cppIDs)
1217 
1218 
1219 class VInputTag(_ValidatingParameterListBase):
1220     def __init__(self,*arg,**args):
1221         if len(arg) == 1 and not isinstance(arg[0], str):
1222             try:
1223                 arg = iter(arg[0])
1224             except TypeError:
1225                 pass
1226         super(VInputTag,self).__init__((InputTag._stringFromArgument(x) for x in arg),**args)
1227     @classmethod
1228     def _itemIsValid(cls,item) -> builtins.bool:
1229         return InputTag._isValid(item)
1230     def configValueForItem(self,item,options:PrintOptions) -> str:
1231         # we tolerate strings as members
1232         if isinstance(item, str):
1233             return '"'+item+'"'
1234         else:
1235             return InputTag.formatValueForConfig(item)
1236     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1237         # we tolerate strings as members
1238         if isinstance(item, str):
1239             return '"'+item+'"'
1240         else:
1241             return item.dumpPython(options)
1242     @staticmethod
1243     def _valueFromString(value:str):
1244         return VInputTag(*_ValidatingParameterListBase._itemsFromStrings(value,InputTag._valueFromString))
1245     def _itemFromArgument(self, x):
1246         return InputTag._stringFromArgument(x)
1247     def insertInto(self, parameterSet, myname:str):
1248         cppTags = list()
1249         for i in self:
1250             item = i
1251             if isinstance(item, str):
1252                 item = InputTag(i)
1253             cppTags.append(item.cppTag(parameterSet))
1254         parameterSet.addVInputTag(self.isTracked(), myname, cppTags)
1255 
1256 class VESInputTag(_ValidatingParameterListBase):
1257     def __init__(self,*arg,**args):
1258         if len(arg) == 1 and not isinstance(arg[0], str):
1259             try:
1260                 arg = iter(arg[0])
1261             except TypeError:
1262                 pass
1263         super(VESInputTag,self).__init__((ESInputTag._stringFromArgument(x) for x in arg),**args)
1264     @classmethod
1265     def _itemIsValid(cls,item) -> builtins.bool:
1266         return ESInputTag._isValid(item)
1267     def configValueForItem(self,item,options:PrintOptions) -> str:
1268         # we tolerate strings as members
1269         if isinstance(item, str):
1270             return '"'+item+'"'
1271         else:
1272             return ESInputTag.formatValueForConfig(item)
1273     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1274         # we tolerate strings as members
1275         if isinstance(item, str):
1276             return '"'+item+'"'
1277         else:
1278             return item.dumpPython(options)
1279     @staticmethod
1280     def _valueFromString(value:str):
1281         return VESInputTag(*_ValidatingParameterListBase._itemsFromStrings(value,ESInputTag._valueFromString))
1282     def _itemFromArgument(self, x) -> str:
1283         return ESInputTag._stringFromArgument(x)
1284     def insertInto(self, parameterSet, myname:str):
1285         cppTags = list()
1286         for i in self:
1287             item = i
1288             if isinstance(item, str):
1289                 item = ESInputTag(i)
1290             cppTags.append(item.cppTag(parameterSet))
1291         parameterSet.addVESInputTag(self.isTracked(), myname, cppTags)
1292 
1293 class VEventID(_ValidatingParameterListBase):
1294     def __init__(self,*arg,**args):
1295         super(VEventID,self).__init__(*arg,**args)
1296     @classmethod
1297     def _itemIsValid(cls,item):
1298         return EventID._isValid(item)
1299     def configValueForItem(self,item,options:PrintOptions) -> str:
1300         return EventID.formatValueForConfig(item)
1301     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1302         # we tolerate strings as members
1303         if isinstance(item, str):
1304             return '"'+item+'"'
1305         else:
1306             return item.dumpPython(options)
1307     @staticmethod
1308     def _valueFromString(value:str):
1309         return VEventID(*_ValidatingParameterListBase._itemsFromStrings(value,EventID._valueFromString))
1310     def insertInto(self, parameterSet, myname:str):
1311         cppIDs = list()
1312         for i in self:
1313             item = i
1314             if isinstance(item, str):
1315                 item = EventID._valueFromString(item)
1316             cppIDs.append(item.cppID(parameterSet))
1317         parameterSet.addVEventID(self.isTracked(), myname, cppIDs)
1318 
1319 
1320 class VLuminosityBlockRange(_ValidatingParameterListBase):
1321     def __init__(self,*arg,**args):
1322         super(VLuminosityBlockRange,self).__init__(*arg,**args)
1323     @classmethod
1324     def _itemIsValid(cls,item) -> builtins.bool:
1325         return LuminosityBlockRange._isValid(item)
1326     def configValueForItem(self,item,options:PrintOptions) -> str:
1327         return LuminosityBlockRange.formatValueForConfig(item)
1328     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1329         if isinstance(item, str):
1330             return '"'+item+'"'
1331         elif isinstance(item, _Parameterizable):
1332             return item.dumpPython(options)
1333         return str(item)
1334     @staticmethod
1335     def _valueFromString(value:str):
1336         return VLuminosityBlockRange(*_ValidatingParameterListBase._itemsFromStrings(value,LuminosityBlockRange._valueFromString))
1337     def insertInto(self, parameterSet, myname:str):
1338         cppIDs = list()
1339         for i in self:
1340             item = i
1341             if isinstance(item, str):
1342                 item = LuminosityBlockRange._valueFromString(item)
1343             cppIDs.append(item.cppID(parameterSet))
1344         parameterSet.addVLuminosityBlockRange(self.isTracked(), myname, cppIDs)
1345 
1346 
1347 class VEventRange(_ValidatingParameterListBase):
1348     def __init__(self,*arg,**args):
1349         super(VEventRange,self).__init__(*arg,**args)
1350     @classmethod
1351     def _itemIsValid(cls,item) -> builtins.bool:
1352         return EventRange._isValid(item)
1353     def configValueForItem(self,item,options:PrintOptions) -> str:
1354         return EventRange.formatValueForConfig(item)
1355     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1356         if isinstance(item, str):
1357             return '"'+item+'"'
1358         elif isinstance(item, _Parameterizable):
1359             return item.dumpPython(options)
1360         return str(item)
1361     @staticmethod
1362     def _valueFromString(value:str):
1363         return VEventRange(*_ValidatingParameterListBase._itemsFromStrings(value,EventRange._valueFromString))
1364     def insertInto(self, parameterSet, myname:str):
1365         cppIDs = list()
1366         for i in self:
1367             item = i
1368             if isinstance(item, str):
1369                 item = EventRange._valueFromString(item)
1370             cppIDs.append(item.cppID(parameterSet))
1371         parameterSet.addVEventRange(self.isTracked(), myname, cppIDs)
1372 
1373 
1374 class VPSet(_ValidatingParameterListBase,_ConfigureComponent,_Labelable):
1375     def __init__(self,*arg,**args):
1376         super(VPSet,self).__init__(*arg,**args)
1377         self._nPerLine = 1
1378     @classmethod
1379     def _itemIsValid(cls,item) -> builtins.bool:
1380         return isinstance(item, PSet) and PSet._isValid(item)
1381     def configValueForItem(self,item, options:PrintOptions) -> str:
1382         return PSet.configValue(item, options)
1383     def pythonValueForItem(self,item, options:PrintOptions) -> str:
1384         return PSet.dumpPython(item,options)
1385     def copy(self):
1386         return copy.copy(self)
1387     def _place(self,name:str,proc):
1388         proc._placeVPSet(name,self)
1389     def insertInto(self, parameterSet, myname:str):
1390         # translate the PSet members into C++ parameterSets
1391         parametersets = list()
1392         for pset in self:
1393             newparameterset = parameterSet.newPSet()
1394             pset.insertContentsInto(newparameterset)
1395             parametersets.append(newparameterset)
1396         parameterSet.addVPSet(self.isTracked(), myname, parametersets)
1397     # XXX FIXME handle refToPSet
1398     def directDependencies(self):
1399         return []
1400     def __repr__(self) -> str:
1401         return self.dumpPython()
1402 
1403 def makeCppPSet(module,cppPSetMaker):
1404     """Extracts all PSets from the module and makes C++ equivalent
1405     """
1406     # if this isn't a dictionary, treat it as an object which holds PSets
1407     if not isinstance(module,dict):
1408         module = dict( ( (x,getattr(module,x)) for x in dir(module)) )  
1409 
1410     for x,p in module.items():
1411         if isinstance(p,PSet):
1412             p.insertInto(cppPSetMaker,x)
1413     return cppPSetMaker
1414 
1415 class _ConvertToPSet(object):
1416     def __init__(self):
1417         self.pset = PSet()
1418     def addInt32(self,tracked:bool,label:str,value):
1419         v = int32(value)
1420         v.setIsTracked(tracked)
1421         setattr(self.pset,label,v)
1422     def addUInt32(self,tracked:bool,label:str,value):
1423         v = uint32(value)
1424         v.setIsTracked(tracked)
1425         setattr(self.pset,label,v)
1426     def addInt64(self,tracked:bool,label:str,value):
1427         v = int64(value)
1428         v.setIsTracked(tracked)
1429         setattr(self.pset,label,v)
1430     def addUInt64(self,tracked:bool,label:str,value):
1431         v = uint64(value)
1432         v.setIsTracked(tracked)
1433         setattr(self.pset,label,v)
1434     def addBool(self,tracked:bool,label:str,value):
1435         v = bool(value)
1436         v.setIsTracked(tracked)
1437         setattr(self.pset,label,v)
1438     def addDouble(self,tracked:bool,label:str,value):
1439         v = double(value)
1440         v.setIsTracked(tracked)
1441         setattr(self.pset,label,v)
1442     def addString(self,tracked:bool,label:str,value):
1443         v = string(value)
1444         v.setIsTracked(tracked)
1445         setattr(self.pset,label,v)
1446     def addInputTag(self,tracked:bool,label:str,value):
1447         v = copy.deepcopy(value)
1448         v.setIsTracked(tracked)
1449         setattr(self.pset,label,v)
1450     def addESInputTag(self,tracked:bool,label:str,value):
1451         v = copy.deepcopy(value)
1452         v.setIsTracked(tracked)
1453         setattr(self.pset,label,v)
1454     def addEventID(self,tracked:bool,label:str,value):
1455         v = copy.deepcopy(value)
1456         v.setIsTracked(tracked)
1457         setattr(self.pset,label,v)
1458     def addEventRange(self,tracked:bool,label:str,value):
1459         v = copy.deepcopy(value)
1460         v.setIsTracked(tracked)
1461         setattr(self.pset,label,v)
1462     def addLuminosityBlockID(self,tracked:bool,label:str,value):
1463         v = copy.deepcopy(value)
1464         v.setIsTracked(tracked)
1465         setattr(self.pset,label,v)
1466     def addLuminosityBlockRange(self,tracked:bool,label:str,value):
1467         v = copy.deepcopy(value)
1468         v.setIsTracked(tracked)
1469         setattr(self.pset,label,v)
1470     def addVInt32(self,tracked:bool,label:str,value):
1471         v = vint32(value)
1472         v.setIsTracked(tracked)
1473         setattr(self.pset,label,v)
1474     def addVUInt32(self,tracked:bool,label:str,value):
1475         v = vuint32(value)
1476         v.setIsTracked(tracked)
1477         setattr(self.pset,label,v)
1478     def addVInt64(self,tracked:bool,label:str,value):
1479         v = vint64(value)
1480         v.setIsTracked(tracked)
1481         setattr(self.pset,label,v)
1482     def addVUInt64(self,tracked:bool,label:str,value):
1483         v = vuint64(value)
1484         v.setIsTracked(tracked)
1485         setattr(self.pset,label,v)
1486     def addVBool(self,tracked:bool,label:str,value):
1487         v = vbool(value)
1488         v.setIsTracked(tracked)
1489         setattr(self.pset,label,v)
1490     def addVDouble(self,tracked:bool,label:str,value):
1491         v = vdouble(value)
1492         v.setIsTracked(tracked)
1493         setattr(self.pset,label,v)
1494     def addVString(self,tracked:bool,label:str,value):
1495         v = vstring(value)
1496         v.setIsTracked(tracked)
1497         setattr(self.pset,label,v)
1498     def addVInputTag(self,tracked:bool,label:str,value):
1499         v = VInputTag(value)
1500         v.setIsTracked(tracked)
1501         setattr(self.pset,label,v)
1502     def addVESInputTag(self,tracked:bool,label:str,value):
1503         v = VESInputTag(value)
1504         v.setIsTracked(tracked)
1505         setattr(self.pset,label,v)
1506     def addVEventID(self,tracked:bool,label:str,value):
1507         v = VEventID(value)
1508         v.setIsTracked(tracked)
1509         setattr(self.pset,label,v)
1510     def addVEventRange(self,tracked:bool,label:str,value):
1511         v = VEventRange(value)
1512         v.setIsTracked(tracked)
1513         setattr(self.pset,label,v)
1514     def addVLuminosityBlockID(self,tracked:bool,label:str,value):
1515         v = VLuminosityBlockID(value)
1516         v.setIsTracked(tracked)
1517         setattr(self.pset,label,v)
1518     def addVLuminosityBlockRange(self,tracked:bool,label:str,value):
1519         v = VLuminosityBlockRange(value)
1520         v.setIsTracked(tracked)
1521         setattr(self.pset,label,v)
1522     def addNewFileInPath(self,tracked:bool,label:str,value):
1523         v = FileInPath(value)
1524         v.setIsTracked(tracked)
1525         setattr(self.pset,label,v)
1526     def newInputTag(self, label, instance, process):
1527         return InputTag(label,instance,process)
1528     def newESInputTag(self,moduleLabel,dataLabel):
1529         return ESInputTag(moduleLabel,dataLabel)
1530     def newEventID(self,r,l,e):
1531         return EventID(r,l,e)
1532     def newLuminosityBlockID(self,r,l):
1533         return LuminosityBlockID(r,l)
1534     def newEventRange(self,r,l,e,r2,l2,e2):
1535         return EventRange(r,l,e,r2,l2,e2)
1536     def newLuminosityBlockRange(self,r,l,r2,l2):
1537         return LuminosityBlockRange(r,l,r2,l2)
1538     def newPSet(self):
1539         return _ConvertToPSet()
1540     def addPSet(self,tracked,label,value):
1541         #value is of type _ConvertToPSet so we need
1542         # to extract the internally held PSet
1543         value.pset.setIsTracked(tracked)
1544         setattr(self.pset,label,value.pset)
1545     def addVPSet(self,tracked,label,value):
1546         #for each item in value gets its pset and create a new list
1547         v = VPSet()
1548         v.extend([x.pset for x in value])
1549         v.setIsTracked(tracked)
1550         setattr(self.pset,label,v)
1551 
1552 def convertToPSet(name:str,module):
1553     convert = _ConvertToPSet()
1554     module.insertInto(convert,name)
1555     return getattr(convert.pset,name)
1556 
1557 def convertToVPSet( **kw ):
1558     returnValue = VPSet()
1559     for name,module in kw.items():
1560         returnValue.append(convertToPSet(name,module))
1561     return returnValue
1562 
1563 
1564 class EDAlias(_ConfigureComponent,_Labelable,_Parameterizable):
1565     def __init__(self,*arg,**kargs):
1566         super(EDAlias,self).__init__(**kargs)
1567 
1568     @staticmethod
1569     def allProducts():
1570         """A helper to specify that all products of a module are to be aliased for. Example usage:
1571         process.someAlias = cms.EDAlias(
1572             aliasForModuleLabel = cms.EDAlias.allProducts()
1573         )
1574         """
1575         return VPSet(PSet(type = string('*')))
1576 
1577     def clone(self, *args, **params):
1578         returnValue = EDAlias.__new__(type(self))
1579         myparams = self.parameters_()
1580         if len(myparams) == 0 and len(params) and len(args):
1581             args.append(None)
1582 
1583         _modifyParametersFromDict(myparams, params, self._Parameterizable__raiseBadSetAttr)
1584 
1585         returnValue.__init__(*args, **myparams)
1586         saveOrigin(returnValue, 1)
1587         return returnValue
1588 
1589     def _place(self,name:str,proc):
1590         proc._placeAlias(name,self)
1591 
1592     def nameInProcessDesc_(self, myname:str):
1593         return myname;
1594 
1595     def appendToProcessDescList_(self, lst, myname:str):
1596         lst.append(self.nameInProcessDesc_(myname))
1597 
1598     def insertInto(self, parameterSet, myname:str):
1599         newpset = parameterSet.newPSet()
1600         newpset.addString(True, "@module_label", myname)
1601         newpset.addString(True, "@module_type", type(self).__name__)
1602         newpset.addString(True, "@module_edm_type", type(self).__name__)
1603         for name in self.parameterNames_():
1604             param = getattr(self,name)
1605             param.insertInto(newpset, name)
1606         parameterSet.addPSet(True, self.nameInProcessDesc_(myname), newpset)
1607 
1608     def dumpPython(self, options:PrintOptions=PrintOptions()) -> str:
1609         specialImportRegistry.registerUse(self)
1610         resultList = ['cms.EDAlias(']
1611         separator = ""
1612         for name in self.parameterNames_():
1613             resultList[-1] = resultList[-1] + separator
1614             separator=","
1615             param = self.__dict__[name]
1616             options.indent()
1617             resultList.append(options.indentation()+name+' = '+param.dumpPython(options))
1618             options.unindent()
1619         return '\n'.join(resultList) + '\n' + options.indentation() + ')'
1620 
1621     # an EDAlias only references other modules by label, so it does not need their definition
1622     def directDependencies(self):
1623         return []
1624 
1625 if __name__ == "__main__":
1626 
1627     import unittest
1628     class PSetTester(object):
1629         def addEventID(self,*pargs,**kargs):
1630             pass
1631         def newEventID(self,*pargs,**kargs):
1632             pass
1633         def addVEventID(self,*pargs,**kargs):
1634             pass
1635         def newLuminosityBlockID(self,*pargs,**kargs):
1636             pass
1637         def addLuminosityBlockID(self,*pargs,**kargs):
1638             pass
1639         def addVLuminosityBlockID(self,*pargs,**kargs):
1640             pass
1641         def addEventRange(self,*pargs,**kargs):
1642             pass
1643         def newEventRange(self,*pargs,**kargs):
1644             pass
1645         def addVEventRange(self,*pargs,**kargs):
1646             pass
1647         def newVEventRange(self,*pargs,**kargs):
1648             pass
1649         def addLuminosityBlockRange(self,*pargs,**kargs):
1650             pass
1651         def newLuminosityBlockRange(self,*pargs,**kargs):
1652             pass
1653         def addVLuminosityBlockRange(self,*pargs,**kargs):
1654             pass
1655         def newVLuminosityBlockRange(self,*pargs,**kargs):
1656             pass
1657     class testTypes(unittest.TestCase):
1658         def testint32(self):
1659             i = int32(1)
1660             self.assertEqual(i.value(),1)
1661             self.assertTrue(i)
1662             self.assertRaises(ValueError,int32,"i")
1663             i = int32._valueFromString("0xA")
1664             self.assertEqual(i.value(),10)
1665             self.assertTrue(not int32(0))
1666 
1667         def testuint32(self):
1668             i = uint32(1)
1669             self.assertEqual(i.value(),1)
1670             self.assertTrue(i)
1671             i = uint32(0)
1672             self.assertEqual(i.value(),0)
1673             self.assertTrue(not i)
1674             self.assertRaises(ValueError,uint32,"i")
1675             self.assertRaises(ValueError,uint32,-1)
1676             i = uint32._valueFromString("0xA")
1677             self.assertEqual(i.value(),10)
1678 
1679         def testdouble(self):
1680             d = double(1)
1681             self.assertEqual(d.value(),1)
1682             self.assertEqual(d.pythonValue(),'1')
1683             d = double(float('Inf'))
1684             self.assertEqual(d,float('Inf'))
1685             self.assertEqual(d.pythonValue(),"float('inf')")
1686             d = double(-float('Inf'))
1687             self.assertEqual(d,-float('Inf'))
1688             self.assertEqual(d.pythonValue(),"-float('inf')")
1689             d = double(float('Nan'))
1690             self.assertTrue(math.isnan(d.value()))
1691             self.assertEqual(d.pythonValue(),"float('nan')")
1692         def testvdouble(self):
1693             d = vdouble(1)
1694             self.assertEqual(d.value(),[1])
1695             self.assertEqual(d.dumpPython(),'cms.vdouble(1)')
1696             d = vdouble(float('inf'))
1697             self.assertEqual(d,[float('inf')])
1698             self.assertEqual(d.dumpPython(),"cms.vdouble(float('inf'))")
1699             d = vdouble(-float('Inf'))
1700             self.assertEqual(d,[-float('inf')])
1701             self.assertEqual(d.dumpPython(),"cms.vdouble(-float('inf'))")
1702             d = vdouble(float('nan'))
1703             self.assertTrue(math.isnan(d[0]))
1704             self.assertEqual(d.dumpPython(),"cms.vdouble(float('nan'))")
1705         def testvint32(self):
1706             v = vint32()
1707             self.assertEqual(len(v),0)
1708             self.assertTrue(not v)
1709             v.append(1)
1710             self.assertEqual(len(v),1)
1711             self.assertEqual(v[0],1)
1712             self.assertTrue(v)
1713             v.append(2)
1714             v.insert(1,3)
1715             self.assertEqual(v[1],3)
1716             v[1]=4
1717             self.assertEqual(v[1],4)
1718             v[1:1]=[5]
1719             self.assertEqual(len(v),4)
1720             self.assertEqual([1,5,4,2],list(v))
1721             self.assertEqual(repr(v), "cms.vint32(1, 5, 4, 2)")
1722             self.assertRaises(TypeError,v.append,('blah'))
1723         def testbool(self):
1724             b = bool(True)
1725             self.assertEqual(b.value(),True)
1726             self.assertTrue(b)
1727             b = bool(False)
1728             self.assertEqual(b.value(),False)
1729             self.assertTrue(not b)
1730             b = bool._valueFromString("2")
1731             self.assertEqual(b.value(),True)
1732             self.assertEqual(repr(b), "cms.bool(True)")
1733             self.assertRaises(ValueError, lambda: bool("False"))
1734         def testString(self):
1735             s=string('this is a test')
1736             self.assertEqual(s.value(),'this is a test')
1737             self.assertEqual(repr(s), "cms.string(\'this is a test\')")
1738             self.assertTrue(s)
1739             s=string('\0')
1740             self.assertEqual(s.value(),'\0')
1741             self.assertEqual(s.configValue(),"'\\0'")
1742             s2=string('')
1743             self.assertEqual(s2.value(),'')
1744             self.assertTrue(not s2)
1745         def testvstring(self):
1746             a = vstring("", "Barack", "John", "Sarah", "Joe")
1747             self.assertEqual(len(a), 5)
1748             self.assertEqual(a[0], "")
1749             self.assertEqual(a[3], "Sarah")
1750             self.assertEqual(a.dumpPython(), "cms.vstring(\n    '',\n    'Barack',\n    'John',\n    'Sarah',\n    'Joe'\n)")
1751             ps = PSet(v = vstring('a', 'b'))
1752             ps.v = ['loose']
1753         def testUntracked(self):
1754             p=untracked(int32(1))
1755             self.assertRaises(TypeError,untracked,(1),{})
1756             self.assertFalse(p.isTracked())
1757             p=untracked.int32(1)
1758             self.assertEqual(repr(p), "cms.untracked.int32(1)")
1759             self.assertRaises(TypeError,untracked,(1),{})
1760             self.assertFalse(p.isTracked())
1761             p=untracked.vint32(1,5,3)
1762             self.assertRaises(TypeError,untracked,(1,5,3),{})
1763             self.assertFalse(p.isTracked())
1764             p = untracked.PSet(b=int32(1))
1765             self.assertFalse(p.isTracked())
1766             self.assertEqual(p.b.value(),1)
1767         def testInputTag(self):
1768             it = InputTag._valueFromString("label::proc")
1769             self.assertEqual(it.getModuleLabel(), "label")
1770             self.assertEqual(it.getProductInstanceLabel(), "")
1771             self.assertEqual(it.getProcessName(), "proc")
1772             # tolerate, at least for translation phase
1773             #self.assertRaises(RuntimeError, InputTag,'foo:bar')
1774             it=InputTag('label',processName='proc')
1775             self.assertEqual(it.getModuleLabel(), "label")
1776             self.assertEqual(it.getProductInstanceLabel(), "")
1777             self.assertEqual(it.getProcessName(), "proc")
1778             self.assertEqual(repr(it), "cms.InputTag(\"label\",\"\",\"proc\")")
1779             vit = VInputTag(InputTag("label1"), InputTag("label2"))
1780             self.assertEqual(repr(vit), "cms.VInputTag(cms.InputTag(\"label1\"), cms.InputTag(\"label2\"))")
1781             vit = VInputTag("label1", "label2:label3")
1782             self.assertEqual(repr(vit), "cms.VInputTag(\"label1\", \"label2:label3\")")
1783             vit = VInputTag("label1", "label2", "label3")
1784             self.assertEqual(repr(vit), "cms.VInputTag(\"label1\", \"label2\", \"label3\")")
1785             vit = VInputTag(["label1", "label2", "label3"])
1786             self.assertEqual(repr(vit), "cms.VInputTag(\"label1\", \"label2\", \"label3\")")
1787             it=InputTag('label',processName=InputTag.skipCurrentProcess())
1788             self.assertEqual(it.getModuleLabel(), "label")
1789             self.assertEqual(it.getProductInstanceLabel(), "")
1790             self.assertEqual(it.getProcessName(), "@skipCurrentProcess")
1791             it=InputTag('label','x',InputTag.skipCurrentProcess())
1792             self.assertEqual(it.getModuleLabel(), "label")
1793             self.assertEqual(it.getProductInstanceLabel(), "x")
1794             self.assertEqual(it.getProcessName(), "@skipCurrentProcess")
1795             it = InputTag("label:in:@skipCurrentProcess")
1796             self.assertEqual(it.getModuleLabel(), "label")
1797             self.assertEqual(it.getProductInstanceLabel(), "in")
1798             self.assertEqual(it.getProcessName(), "@skipCurrentProcess")
1799             with self.assertRaises(RuntimeError):
1800                 it = InputTag("label:too:many:elements")
1801             with self.assertRaises(RuntimeError):
1802                 vit = VInputTag("label:too:many:elements")
1803 
1804             pset = PSet(it = InputTag("something"))
1805             # "assignment" from string
1806             pset.it = "label"
1807             self.assertEqual(pset.it.getModuleLabel(), "label")
1808             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1809             self.assertEqual(pset.it.getProcessName(), "")
1810             pset.it = "label:in"
1811             self.assertEqual(pset.it.getModuleLabel(), "label")
1812             self.assertEqual(pset.it.getProductInstanceLabel(), "in")
1813             self.assertEqual(pset.it.getProcessName(), "")
1814             pset.it = "label:in:proc"
1815             self.assertEqual(pset.it.getModuleLabel(), "label")
1816             self.assertEqual(pset.it.getProductInstanceLabel(), "in")
1817             self.assertEqual(pset.it.getProcessName(), "proc")
1818             pset.it = "label::proc"
1819             self.assertEqual(pset.it.getModuleLabel(), "label")
1820             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1821             self.assertEqual(pset.it.getProcessName(), "proc")
1822             with self.assertRaises(RuntimeError):
1823                 pset.it = "label:too:many:elements"
1824             # "assignment" from tuple of strings
1825             pset.it = ()
1826             self.assertEqual(pset.it.getModuleLabel(), "")
1827             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1828             self.assertEqual(pset.it.getProcessName(), "")
1829             pset.it = ("label",)
1830             self.assertEqual(pset.it.getModuleLabel(), "label")
1831             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1832             self.assertEqual(pset.it.getProcessName(), "")
1833             pset.it = ("label", "in")
1834             self.assertEqual(pset.it.getModuleLabel(), "label")
1835             self.assertEqual(pset.it.getProductInstanceLabel(), "in")
1836             self.assertEqual(pset.it.getProcessName(), "")
1837             pset.it = ("label", "in", "proc")
1838             self.assertEqual(pset.it.getModuleLabel(), "label")
1839             self.assertEqual(pset.it.getProductInstanceLabel(), "in")
1840             self.assertEqual(pset.it.getProcessName(), "proc")
1841             pset.it = ("label", "", "proc")
1842             self.assertEqual(pset.it.getModuleLabel(), "label")
1843             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1844             self.assertEqual(pset.it.getProcessName(), "proc")
1845             with self.assertRaises(RuntimeError):
1846                 pset.it = ("label", "too", "many", "elements")
1847             # "assignment" from list of strings
1848             pset.it = []
1849             self.assertEqual(pset.it.getModuleLabel(), "")
1850             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1851             self.assertEqual(pset.it.getProcessName(), "")
1852             pset.it = ["label"]
1853             self.assertEqual(pset.it.getModuleLabel(), "label")
1854             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1855             self.assertEqual(pset.it.getProcessName(), "")
1856             pset.it = ["label", "in"]
1857             self.assertEqual(pset.it.getModuleLabel(), "label")
1858             self.assertEqual(pset.it.getProductInstanceLabel(), "in")
1859             self.assertEqual(pset.it.getProcessName(), "")
1860             pset.it = ["label", "in", "proc"]
1861             self.assertEqual(pset.it.getModuleLabel(), "label")
1862             self.assertEqual(pset.it.getProductInstanceLabel(), "in")
1863             self.assertEqual(pset.it.getProcessName(), "proc")
1864             pset.it = ["label", "", "proc"]
1865             self.assertEqual(pset.it.getModuleLabel(), "label")
1866             self.assertEqual(pset.it.getProductInstanceLabel(), "")
1867             self.assertEqual(pset.it.getProcessName(), "proc")
1868             with self.assertRaises(RuntimeError):
1869                 pset.it = ["label", "too", "many", "elements"]
1870 
1871             vit = VInputTag(("a2",), ("b2", "i"), ("c2", "i", "p"))
1872             self.assertEqual(repr(vit), "cms.VInputTag(\"a2\", \"b2:i\", \"c2:i:p\")")
1873 
1874             pset = PSet(vit = VInputTag())
1875             pset.vit = ["a", "b:i", "c:i:p"]
1876             self.assertEqual(repr(pset.vit), "cms.VInputTag(\"a\", \"b:i\", \"c:i:p\")")
1877             pset.vit = [("a2",), ("b2", "i"), ("c2", "i", "p")]
1878             self.assertEqual(repr(pset.vit), "cms.VInputTag(\"a2\", \"b2:i\", \"c2:i:p\")")
1879             pset.vit = [["a3"], ["b3", "i"], ["c3", "i", "p"]]
1880             self.assertEqual(repr(pset.vit), "cms.VInputTag(\"a3\", \"b3:i\", \"c3:i:p\")")
1881             with self.assertRaises(RuntimeError):
1882                 pset.vit = [("label", "too", "many", "elements")]
1883         def testInputTagModified(self):
1884             a=InputTag("a")
1885             self.assertEqual(a.isModified(),False)
1886             a.setModuleLabel("a")
1887             self.assertEqual(a.isModified(),False)
1888             a.setModuleLabel("b")
1889             self.assertEqual(a.isModified(),True)
1890             a.resetModified()
1891             a.setProductInstanceLabel("b")
1892             self.assertEqual(a.isModified(),True)
1893             a.resetModified()
1894             a.setProcessName("b")
1895             self.assertEqual(a.isModified(),True)
1896             a.resetModified()
1897             a.setValue("b")
1898             self.assertEqual(a.isModified(),True)
1899         def testESInputTag(self):
1900             it = ESInputTag._valueFromString("label:data")
1901             self.assertEqual(it.getModuleLabel(), "label")
1902             self.assertEqual(it.getDataLabel(), "data")
1903             # tolerate, at least for translation phase
1904             #self.assertRaises(RuntimeError, InputTag,'foo:bar')
1905             it=ESInputTag(data='data')
1906             self.assertEqual(it.getModuleLabel(), "")
1907             self.assertEqual(it.getDataLabel(), "data")
1908             self.assertEqual(repr(it), "cms.ESInputTag(\"\",\"data\")")
1909             vit = VESInputTag(ESInputTag("label1:"), ESInputTag("label2:"))
1910             self.assertEqual(repr(vit), 'cms.VESInputTag(cms.ESInputTag("label1",""), cms.ESInputTag("label2",""))')
1911             vit = VESInputTag("label1:", "label2:label3")
1912             self.assertEqual(repr(vit), "cms.VESInputTag(\"label1:\", \"label2:label3\")")
1913             vit = VESInputTag(["label1:", "label2:label3"])
1914             self.assertEqual(repr(vit), "cms.VESInputTag(\"label1:\", \"label2:label3\")")
1915 
1916             with self.assertRaises(RuntimeError):
1917                 it = ESInputTag("label:too:many:elements")
1918             with self.assertRaises(RuntimeError):
1919                 vit = VESInputTag("label:too:many:elements")
1920 
1921             pset = PSet(it = ESInputTag("something:"))
1922             # "assignment" from string
1923             pset.it = ""
1924             self.assertEqual(pset.it.getModuleLabel(), "")
1925             self.assertEqual(pset.it.getDataLabel(), "")
1926             pset.it = "label:"
1927             self.assertEqual(pset.it.getModuleLabel(), "label")
1928             self.assertEqual(pset.it.getDataLabel(), "")
1929             pset.it = "label:data"
1930             self.assertEqual(pset.it.getModuleLabel(), "label")
1931             self.assertEqual(pset.it.getDataLabel(), "data")
1932             pset.it = ":data"
1933             self.assertEqual(pset.it.getModuleLabel(), "")
1934             self.assertEqual(pset.it.getDataLabel(), "data")
1935             with self.assertRaises(RuntimeError):
1936                 pset.it = "too:many:elements"
1937             with self.assertRaises(RuntimeError):
1938                 pset.it = "too_few_elements"
1939             # "assignment" from tuple of strings
1940             pset.it = ()
1941             self.assertEqual(pset.it.getModuleLabel(), "")
1942             self.assertEqual(pset.it.getDataLabel(), "")
1943             pset.it = ("label", "")
1944             self.assertEqual(pset.it.getModuleLabel(), "label")
1945             self.assertEqual(pset.it.getDataLabel(), "")
1946             pset.it = ("label", "data")
1947             self.assertEqual(pset.it.getModuleLabel(), "label")
1948             self.assertEqual(pset.it.getDataLabel(), "data")
1949             pset.it = ("", "data")
1950             self.assertEqual(pset.it.getModuleLabel(), "")
1951             self.assertEqual(pset.it.getDataLabel(), "data")
1952             with self.assertRaises(RuntimeError):
1953                 pset.it = ("too", "many", "elements")
1954             with self.assertRaises(RuntimeError):
1955                 pset.it = ("too_few_elements",)
1956             # "assignment" from list of strings
1957             pset.it = []
1958             self.assertEqual(pset.it.getModuleLabel(), "")
1959             self.assertEqual(pset.it.getDataLabel(), "")
1960             pset.it = ["label", ""]
1961             self.assertEqual(pset.it.getModuleLabel(), "label")
1962             self.assertEqual(pset.it.getDataLabel(), "")
1963             pset.it = ["label", "data"]
1964             self.assertEqual(pset.it.getModuleLabel(), "label")
1965             self.assertEqual(pset.it.getDataLabel(), "data")
1966             pset.it = ["", "data"]
1967             self.assertEqual(pset.it.getModuleLabel(), "")
1968             self.assertEqual(pset.it.getDataLabel(), "data")
1969             with self.assertRaises(RuntimeError):
1970                 pset.it = ["too", "many", "elements"]
1971             with self.assertRaises(RuntimeError):
1972                 pset.it = ["too_few_elements"]
1973 
1974             vit = VESInputTag(("a2", ""), ("b2", "d"), ("", "c"))
1975             self.assertEqual(repr(vit), "cms.VESInputTag(\"a2:\", \"b2:d\", \":c\")")
1976 
1977             pset = PSet(vit = VESInputTag())
1978             pset.vit = ["a:", "b:d", ":c"]
1979             self.assertEqual(repr(pset.vit), "cms.VESInputTag(\"a:\", \"b:d\", \":c\")")
1980             pset.vit = [("a2", ""), ("b2", "d2"), ("", "c2")]
1981             self.assertEqual(repr(pset.vit), "cms.VESInputTag(\"a2:\", \"b2:d2\", \":c2\")")
1982             pset.vit = [["a3", ""], ["b3", "d3"], ["", "c3"]]
1983             self.assertEqual(repr(pset.vit), "cms.VESInputTag(\"a3:\", \"b3:d3\", \":c3\")")
1984             with self.assertRaises(RuntimeError):
1985                 pset.vit = [("too", "many", "elements")]
1986             with self.assertRaises(RuntimeError):
1987                 pset.vit = ["too_few_elements"]
1988             with self.assertRaises(RuntimeError):
1989                 pset.vit = [("too_few_elements")]
1990 
1991         def testPSet(self):
1992             p1 = PSet(anInt = int32(1), a = PSet(b = int32(1)))
1993             self.assertRaises(ValueError, PSet, "foo")
1994             self.assertRaises(TypeError, PSet, foo = "bar")
1995             self.assertEqual(repr(p1), "cms.PSet(\n    a = cms.PSet(\n        b = cms.int32(1)\n    ),\n    anInt = cms.int32(1)\n)")
1996             vp1 = VPSet(PSet(i = int32(2)))
1997             #self.assertEqual(vp1.configValue(), "
1998             self.assertEqual(repr(vp1), "cms.VPSet(cms.PSet(\n    i = cms.int32(2)\n))")
1999             self.assertTrue(p1.hasParameter(['a', 'b']))
2000             self.assertFalse(p1.hasParameter(['a', 'c']))
2001             self.assertEqual(p1.getParameter(['a', 'b']).value(), 1)
2002             # test clones and trackedness
2003             p3 = untracked.PSet(i = int32(1), ui=untracked.int32(2), a = PSet(b = untracked.int32(1)), b = untracked.PSet(b = int32(1)))
2004             p4 = p3.clone()
2005             self.assertFalse(p4.isTracked())
2006             self.assertTrue(p4.i.isTracked())
2007             self.assertFalse(p4.ui.isTracked())
2008             self.assertTrue(p4.a.isTracked())
2009             self.assertFalse(p4.b.isTracked())
2010             self.assertFalse(p4.a.b.isTracked())
2011             self.assertTrue(p4.b.b.isTracked())
2012             p4 = p3.clone( i = None, b = dict(b = 5))
2013             self.assertEqual(p3.i.value(), 1)
2014             self.assertEqual(hasattr(p4,"i"), False)
2015             self.assertEqual(p3.b.b.value(), 1)
2016             self.assertEqual(p4.b.b.value(), 5)
2017             self.assertEqual(p4.a.b.value(), 1)
2018             self.assertEqual(p4.ui.value(), 2)
2019             # couple of cases of "weird" arguments
2020             self.assertRaises(TypeError, p4.clone, dict(b = None))
2021             self.assertRaises(TypeError, p4.clone, [])
2022             self.assertRaises(TypeError, p4.clone, 42)
2023             p5 = PSet(p = PSet(anInt = int32(1), aString=string("foo") ) )
2024             p5.p=dict(aString = "bar")
2025             self.assertEqual(p5.p.aString.value(), "bar")
2026             self.assertEqual(p5.p.anInt.value(), 1)
2027             p5.p = dict(aDouble = double(3.14))
2028             self.assertEqual(p5.p.aString.value(), "bar")
2029             self.assertEqual(p5.p.anInt.value(), 1)
2030             self.assertEqual(p5.p.aDouble, 3.14)
2031             self.assertRaises(TypeError, p5.p , dict(bar = 3) )
2032         def testRequired(self):
2033             p1 = PSet(anInt = required.int32)
2034             self.assertTrue(hasattr(p1,"anInt"))
2035             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    anInt = cms.required.int32\n)')
2036             p1.anInt = 3
2037             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    anInt = cms.int32(3)\n)')
2038             self.assertEqual(p1.anInt.value(), 3)
2039             p1 = PSet(anInt = required.int32)
2040             p1.anInt.setValue(3)
2041             self.assertEqual(p1.anInt.value(), 3)
2042             p1.anInt = 4
2043             self.assertEqual(p1.anInt.value(), 4)
2044             p1 = PSet(anInt = required.untracked.int32)
2045             p1.anInt = 5
2046             self.assertEqual(p1.anInt.value(), 5)
2047             self.assertFalse(p1.anInt.isTracked())
2048             p1 = PSet(anInt = required.untracked.int32)
2049             self.assertEqual(p1.dumpPython(), 'cms.PSet(\n    anInt = cms.required.untracked.int32\n)')
2050             p1.anInt = 6
2051             self.assertEqual(p1.dumpPython(), 'cms.PSet(\n    anInt = cms.untracked.int32(6)\n)')
2052             self.assertTrue(p1.anInt.isCompatibleCMSType(int32))
2053             self.assertFalse(p1.anInt.isCompatibleCMSType(uint32))
2054             p1 = PSet(allowAnyLabel_ = required.int32)
2055             self.assertFalse(p1.hasParameter(['allowAnyLabel_']))
2056             p1.foo = 3
2057             self.assertEqual(p1.foo.value(),3)
2058             self.assertRaises(ValueError,setattr,p1, 'bar', 'bad')
2059             self.assertTrue(p1.foo.isTracked())
2060             p1 = PSet(allowAnyLabel_ = required.untracked.int32)
2061             self.assertFalse(p1.hasParameter(['allowAnyLabel_']))
2062             p1.foo = 3
2063             self.assertEqual(p1.foo.value(),3)
2064             self.assertFalse(p1.foo.isTracked())
2065             self.assertRaises(ValueError,setattr,p1, 'bar', 'bad')
2066             #PSetTemplate use
2067             p1 = PSet(aPSet = required.PSetTemplate())
2068             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.required.PSetTemplate(\n\n    )\n)')
2069             p1.aPSet = dict()
2070             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.PSet(\n\n    )\n)')
2071             p1 = PSet(aPSet=required.PSetTemplate(a=required.int32))
2072             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.required.PSetTemplate(\n        a = cms.required.int32\n    )\n)')
2073             p1.aPSet = dict(a=5)
2074             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.PSet(\n        a = cms.int32(5)\n    )\n)')
2075             self.assertEqual(p1.aPSet.a.value(), 5)
2076             p1 = PSet(aPSet=required.PSetTemplate(a=required.int32))
2077             p1.aPSet = PSet(a=int32(5))
2078             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.PSet(\n        a = cms.int32(5)\n    )\n)')
2079             self.assertEqual(p1.aPSet.a.value(), 5)
2080             p1 = PSet(aPSet=required.untracked.PSetTemplate(a=required.int32))
2081             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.required.untracked.PSetTemplate(\n        a = cms.required.int32\n    )\n)')
2082             p1.aPSet = dict(a=5)
2083             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.untracked.PSet(\n        a = cms.int32(5)\n    )\n)')
2084             self.assertEqual(p1.aPSet.a.value(), 5)
2085             p1 = PSet(allowAnyLabel_=required.PSetTemplate(a=required.int32))
2086             p1Clone = p1.clone()
2087             self.assertEqual(p1.dumpPython(), 'cms.PSet(\n    allowAnyLabel_=cms.required.PSetTemplate(\n        a = cms.required.int32\n    )\n)')
2088             self.assertEqual(p1Clone.dumpPython(), 'cms.PSet(\n    allowAnyLabel_=cms.required.PSetTemplate(\n        a = cms.required.int32\n    )\n)')
2089             with self.assertRaises(AttributeError):
2090                 p1.clone(allowAnyLabel_=optional.double)
2091             p1.foo = dict(a=5)
2092             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    foo = cms.PSet(\n        a = cms.int32(5)\n    ),\n    allowAnyLabel_=cms.required.PSetTemplate(\n        a = cms.required.int32\n    )\n)')
2093             self.assertEqual(p1.foo.a.value(), 5)
2094             p1 = PSet(anInt = required.int32)
2095             self.assertRaises(TypeError, setattr, p1,'anInt', uint32(2))
2096 
2097         def testOptional(self):
2098             p1 = PSet(anInt = optional.int32)
2099             self.assertTrue(hasattr(p1,"anInt"))
2100             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    anInt = cms.optional.int32\n)')
2101             p1.anInt = 3
2102             self.assertEqual(p1.anInt.value(), 3)
2103             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    anInt = cms.int32(3)\n)')
2104             p1 = PSet(anInt = optional.int32)
2105             p1.anInt.setValue(3)
2106             self.assertEqual(p1.anInt.value(), 3)
2107             p1.anInt = 4
2108             self.assertEqual(p1.anInt.value(), 4)
2109             p1 = PSet(anInt = optional.untracked.int32)
2110             p1.anInt = 5
2111             self.assertEqual(p1.anInt.value(), 5)
2112             self.assertFalse(p1.anInt.isTracked())
2113             p1 = PSet(anInt = optional.untracked.int32)
2114             self.assertEqual(p1.dumpPython(), 'cms.PSet(\n    anInt = cms.optional.untracked.int32\n)')
2115             p1.anInt = 6
2116             self.assertEqual(p1.dumpPython(), 'cms.PSet(\n    anInt = cms.untracked.int32(6)\n)')
2117             self.assertTrue(p1.anInt.isCompatibleCMSType(int32))
2118             self.assertFalse(p1.anInt.isCompatibleCMSType(uint32))
2119             p1 = PSet(f = required.vint32)
2120             self.assertFalse(p1.f)
2121             p1.f = []
2122             self.assertFalse(p1.f)
2123             p1.f.append(3)
2124             self.assertTrue(p1.f)
2125             #PSetTemplate use
2126             p1 = PSet(aPSet = optional.PSetTemplate())
2127             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.optional.PSetTemplate(\n\n    )\n)')
2128             p1.aPSet = dict()
2129             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.PSet(\n\n    )\n)')
2130             p1 = PSet(aPSet=optional.PSetTemplate(a=optional.int32))
2131             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.optional.PSetTemplate(\n        a = cms.optional.int32\n    )\n)')
2132             p1.aPSet = dict(a=5)
2133             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.PSet(\n        a = cms.int32(5)\n    )\n)')
2134             self.assertEqual(p1.aPSet.a.value(), 5)
2135             p1 = PSet(aPSet=optional.untracked.PSetTemplate(a=optional.int32))
2136             p1Clone = p1.clone()
2137             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.optional.untracked.PSetTemplate(\n        a = cms.optional.int32\n    )\n)')
2138             self.assertEqual(p1Clone.dumpPython(),'cms.PSet(\n    aPSet = cms.optional.untracked.PSetTemplate(\n        a = cms.optional.int32\n    )\n)')
2139             p1.aPSet = dict(a=5)
2140             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aPSet = cms.untracked.PSet(\n        a = cms.int32(5)\n    )\n)')
2141             self.assertEqual(p1.aPSet.a.value(), 5)
2142             p1 = PSet(allowAnyLabel_=optional.PSetTemplate(a=optional.int32))
2143             self.assertEqual(p1.dumpPython(), 'cms.PSet(\n    allowAnyLabel_=cms.optional.PSetTemplate(\n        a = cms.optional.int32\n    )\n)')
2144             p1.foo = dict(a=5)
2145             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    foo = cms.PSet(\n        a = cms.int32(5)\n    ),\n    allowAnyLabel_=cms.optional.PSetTemplate(\n        a = cms.optional.int32\n    )\n)')
2146             self.assertEqual(p1.foo.a.value(), 5)
2147             #check wrong type failure
2148             p1 = PSet(anInt = optional.int32)
2149             self.assertRaises(TypeError, lambda : setattr(p1,'anInt', uint32(2)))
2150 
2151 
2152         def testAllowed(self):
2153             p1 = PSet(aValue = required.allowed(int32, string))
2154             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.required.allowed(cms.int32,cms.string)\n)')
2155             p1.aValue = 1
2156             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.int32(1)\n)')
2157             self.assertTrue(p1.aValue.isCompatibleCMSType(int32))
2158             self.assertFalse(p1.aValue.isCompatibleCMSType(uint32))
2159             self.assertRaises(RuntimeError, lambda: setattr(p1,'aValue',1.3))
2160             p1 = PSet(aValue = required.allowed(int32, string))
2161             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.required.allowed(cms.int32,cms.string)\n)')
2162             p1.aValue = "foo"
2163             self.assertEqual(p1.dumpPython(),"cms.PSet(\n    aValue = cms.string('foo')\n)")
2164             self.assertTrue(p1.aValue.isCompatibleCMSType(string))
2165             self.assertFalse(p1.aValue.isCompatibleCMSType(uint32))
2166             p1 = PSet(aValue = required.allowed(int32, string))
2167             #assign wrong type
2168             self.assertRaises(TypeError, lambda: setattr(p1, 'aValue', double(3.1)))
2169 
2170             p1 = PSet(aValue = required.allowed(int32, string, default=int32(3)))
2171             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.int32(3)\n)')
2172             p1.aValue = "foo"
2173             self.assertEqual(p1.dumpPython(),"cms.PSet(\n    aValue = cms.string('foo')\n)")
2174             
2175             p1 = PSet(aValue = required.untracked.allowed(int32, string, default=int32(3)))
2176             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.untracked.int32(3)\n)')
2177 
2178             p1 = PSet(aValue = required.untracked.allowed(int32, string))
2179             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.required.untracked.allowed(cms.int32,cms.string)\n)')
2180             p1.aValue = 1
2181             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.untracked.int32(1)\n)')
2182             self.assertRaises(RuntimeError, lambda: setattr(p1,'aValue',1.3))
2183             p1 = PSet(aValue = required.untracked.allowed(int32, string))
2184             self.assertEqual(p1.dumpPython(),'cms.PSet(\n    aValue = cms.required.untracked.allowed(cms.int32,cms.string)\n)')
2185             p1.aValue = "foo"
2186             self.assertEqual(p1.dumpPython(),"cms.PSet(\n    aValue = cms.untracked.string('foo')\n)")
2187 
2188             p2 = PSet(aValue=optional.allowed(int32,PSet))
2189             self.assertEqual(p2.dumpPython(),'cms.PSet(\n    aValue = cms.optional.allowed(cms.int32,cms.PSet)\n)')
2190             p2.aValue = 2
2191             self.assertEqual(p2.aValue.value(),2)
2192             p2 = PSet(aValue=optional.allowed(int32,PSet))
2193             p2.aValue = PSet(i = int32(3))
2194             self.assertEqual(p2.aValue.i.value(),3)
2195             p2 = PSet(aValue=optional.allowed(int32,PSet))
2196             p2.aValue = dict(i = int32(3))
2197             self.assertEqual(p2.aValue.i.value(),3)
2198 
2199             p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
2200             self.assertEqual(p2.dumpPython(),'cms.PSet(\n    aValue = cms.optional.allowed(cms.int32,cms.PSetTemplate(\n    b = cms.optional.int32\n))\n)')
2201             p2.aValue = 2
2202             self.assertEqual(p2.aValue.value(),2)
2203             p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
2204             p2.aValue = PSet(b = int32(3))
2205             self.assertEqual(p2.aValue.b.value(),3)
2206             p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
2207             p2.aValue = dict(b = 3)
2208             self.assertEqual(p2.aValue.b.value(),3)
2209             self.assertEqual(p2.dumpPython(), 'cms.PSet(\n    aValue = cms.PSet(\n        b = cms.int32(3)\n    )\n)')
2210             p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
2211             self.assertRaises(TypeError, lambda: setattr(p2, "aValue", dict(i = 1)) )
2212             p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
2213             self.assertRaises(TypeError, lambda: setattr(p2, "aValue", double(3.14)) )
2214             self.assertRaises(ValueError, lambda: setattr(p2, "aValue", dict(b=3.14)) )
2215             p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
2216             p2.aValue = PSet(b=double(3.14))
2217             self.assertEqual(p2.aValue.b.value(),3.14)
2218 
2219 
2220 
2221             p2 = PSet(aValue=optional.untracked.allowed(int32,PSet))
2222             self.assertEqual(p2.dumpPython(),'cms.PSet(\n    aValue = cms.optional.untracked.allowed(cms.int32,cms.PSet)\n)')
2223             p2.aValue = 2
2224             self.assertEqual(p2.aValue.value(),2)
2225             p2 = PSet(aValue=optional.untracked.allowed(int32,PSet))
2226             p2.aValue = PSet(i = int32(3))
2227             self.assertEqual(p2.aValue.i.value(),3)
2228             p2 = PSet(aValue=optional.untracked.allowed(int32,PSet))
2229             p2.aValue = dict(i = int32(3))
2230             self.assertEqual(p2.aValue.i.value(),3)
2231 
2232             p3 = PSet(aValue=required.allowed(int32,uint32))
2233             p3.aValue = -42
2234             self.assertEqual(p3.aValue.value(), -42)
2235             p3 = PSet(aValue=required.allowed(int32,uint32))
2236             self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))
2237 
2238             p3 = PSet(aValue=required.untracked.allowed(int32,uint32))
2239             p3.aValue = -42
2240             self.assertEqual(p3.aValue.value(), -42)
2241             p3 = PSet(aValue=required.untracked.allowed(int32,uint32))
2242             self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))
2243 
2244             p3 = PSet(aValue=optional.allowed(int32,uint32))
2245             p3.aValue = -42
2246             self.assertEqual(p3.aValue.value(), -42)
2247             p3 = PSet(aValue=optional.allowed(int32,uint32))
2248             self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))
2249 
2250             p3 = PSet(aValue=optional.untracked.allowed(int32,uint32))
2251             p3.aValue = -42
2252             self.assertEqual(p3.aValue.value(), -42)
2253             p3 = PSet(aValue=optional.untracked.allowed(int32,uint32))
2254             self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))
2255 
2256             p1 = PSet(aValue = required.allowed(int32, string))
2257             self.assertRaises(TypeError, lambda : setattr(p1,'aValue', uint32(2)))
2258 
2259             p1 = PSet(aValue = required.allowed(InputTag, VInputTag, default=InputTag("blah")))
2260             p1.aValue.setValue("foo")
2261             self.assertEqual(p1.aValue.value(), "foo")
2262 
2263             
2264         def testVPSet(self):
2265             p1 = VPSet(PSet(anInt = int32(1)), PSet(anInt=int32(2)))
2266             self.assertEqual(len(p1),2)
2267             self.assertEqual(p1[0].anInt.value(), 1)
2268             self.assertEqual(p1[1].anInt.value(), 2)
2269             self.assertRaises(TypeError, lambda : VPSet(3))
2270             self.assertRaises(TypeError, lambda : VPSet(int32(3)))
2271             self.assertRaises(SyntaxError, lambda : VPSet(foo=PSet()))
2272         def testEDAlias(self):
2273             aliasfoo2 = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
2274             self.assertTrue(hasattr(aliasfoo2,"foo2"))
2275             del aliasfoo2.foo2
2276             self.assertTrue(not hasattr(aliasfoo2,"foo2"))
2277             self.assertTrue("foo2" not in aliasfoo2.parameterNames_())
2278 
2279             aliasfoo2 = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
2280             aliasfoo3 = aliasfoo2.clone(
2281                 foo2 = {0: dict(type = "Foo4")},
2282                 foo3 = VPSet(PSet(type = string("Foo3")))
2283             )
2284             self.assertTrue(hasattr(aliasfoo3, "foo2"))
2285             self.assertTrue(hasattr(aliasfoo3, "foo3"))
2286             self.assertEqual(aliasfoo3.foo2[0].type, "Foo4")
2287             self.assertEqual(aliasfoo3.foo3[0].type, "Foo3")
2288 
2289             aliasfoo4 = aliasfoo3.clone(foo2 = None)
2290             self.assertFalse(hasattr(aliasfoo4, "foo2"))
2291             self.assertTrue(hasattr(aliasfoo4, "foo3"))
2292             self.assertEqual(aliasfoo4.foo3[0].type, "Foo3")
2293 
2294             aliasfoo5 = EDAlias(foo5 = EDAlias.allProducts())
2295             self.assertEqual(len(aliasfoo5.foo5), 1)
2296             self.assertEqual(aliasfoo5.foo5[0].type.value(), "*")
2297             self.assertFalse(hasattr(aliasfoo5.foo5[0], "fromProductInstance"))
2298             self.assertFalse(hasattr(aliasfoo5.foo5[0], "toProductInstance"))
2299 
2300             aliasfoo6 = aliasfoo5.clone(foo5 = None, foo6 = EDAlias.allProducts())
2301             self.assertFalse(hasattr(aliasfoo6, "foo5"))
2302             self.assertTrue(hasattr(aliasfoo6, "foo6"))
2303             self.assertEqual(len(aliasfoo6.foo6), 1)
2304             self.assertEqual(aliasfoo6.foo6[0].type.value(), "*")
2305 
2306             aliasfoo7 = EDAlias(foo5 = EDAlias.allProducts(), foo6 = EDAlias.allProducts())
2307             self.assertEqual(len(aliasfoo7.foo5), 1)
2308             self.assertEqual(len(aliasfoo7.foo6), 1)
2309 
2310         def testFileInPath(self):
2311             f = FileInPath("FWCore/ParameterSet/python/Types.py")
2312             self.assertEqual(f.configValue(), "'FWCore/ParameterSet/python/Types.py'")
2313             f = FileInPath()
2314             self.assertEqual(f.configValue(), "''")
2315 
2316         def testSecSource(self):
2317             s1 = SecSource("EmbeddedRootSource", fileNames = vstring("foo.root"))
2318             self.assertEqual(s1.type_(), "EmbeddedRootSource")
2319             self.assertEqual(s1.configValue(),
2320 """EmbeddedRootSource { """+"""
2321     vstring fileNames = {
2322         'foo.root'
2323     }
2324 
2325 }
2326 """)
2327             s1=SecSource("EmbeddedRootSource",type=int32(1))
2328             self.assertEqual(s1.type.value(),1)
2329         def testEventID(self):
2330             eid = EventID(2, 0, 3)
2331             self.assertEqual( repr(eid), "cms.EventID(2, 0, 3)" )
2332             pset = PSetTester()
2333             eid.insertInto(pset,'foo')
2334             eid2 = EventID._valueFromString('3:4')
2335             eid2.insertInto(pset,'foo2')
2336             eid = EventID(0,0,0)
2337             eid.setValue("2:0:3")
2338             self.assertEqual( repr(eid), "cms.EventID(2, 0, 3)" )
2339             eid.setValue( (4,1))
2340             self.assertEqual( repr(eid), "cms.EventID(4, 0, 1)" )
2341             eid.setValue( (5,1,2))
2342             self.assertEqual( repr(eid), "cms.EventID(5, 1, 2)" )
2343             self.assertEqual(eid.value(), "5:1:2")
2344             other = EventID(1,1,1)
2345             other.setValue(eid.value())
2346             self.assertEqual(other.value(), "5:1:2")
2347         def testVEventID(self):
2348             veid = VEventID(EventID(2, 0, 3))
2349             veid2 = VEventID("1:2", "3:4")
2350             self.assertEqual( repr(veid[0]), "cms.EventID(2, 0, 3)" )
2351             self.assertEqual( repr(veid2[0]), "'1:2'" )
2352             self.assertEqual( veid2.dumpPython(), 'cms.VEventID("1:2", "3:4")')
2353             pset = PSetTester()
2354             veid.insertInto(pset,'foo')
2355 
2356         def testLuminosityBlockID(self):
2357             lid = LuminosityBlockID(2, 3)
2358             self.assertEqual( repr(lid), "cms.LuminosityBlockID(2, 3)" )
2359             pset = PSetTester()
2360             lid.insertInto(pset,'foo')
2361             lid2 = LuminosityBlockID._valueFromString('3:4')
2362             lid2.insertInto(pset,'foo2')
2363             lid3 = LuminosityBlockID(1)
2364             lid3.setValue((2,3))
2365             self.assertEqual(repr(lid3), "cms.LuminosityBlockID(2, 3)")
2366             self.assertEqual(lid3.value(), "2:3")
2367             other = LuminosityBlockID(1,1)
2368             other.setValue(lid3.value())
2369             self.assertEqual(other.value(), "2:3")
2370 
2371         def testVLuminosityBlockID(self):
2372             vlid = VLuminosityBlockID(LuminosityBlockID(2, 3))
2373             vlid2 = VLuminosityBlockID("1:2", "3:4")
2374             self.assertEqual( repr(vlid[0]), "cms.LuminosityBlockID(2, 3)" )
2375             self.assertEqual( repr(vlid2[0]), "'1:2'" )
2376             self.assertEqual( vlid2.dumpPython(), 'cms.VLuminosityBlockID("1:2", "3:4")')
2377             vlid3 = VLuminosityBlockID((1,2),(3,4))
2378             self.assertEqual( repr(vlid3[0]), '(1, 2)' )
2379             self.assertEqual( vlid3.dumpPython(), 'cms.VLuminosityBlockID((1, 2), (3, 4))')
2380             pset = PSetTester()
2381             vlid.insertInto(pset,'foo')
2382             vlid4 = VLuminosityBlockID()
2383             vlid4.setValue(["1:2"])
2384             self.assertEqual( vlid4.dumpPython(), 'cms.VLuminosityBlockID("1:2")' )
2385             p = PSet(v = VLuminosityBlockID())
2386             p.v = VLuminosityBlockID()
2387             p.v = ["1:2"]
2388             self.assertEqual( p.v.dumpPython(), 'cms.VLuminosityBlockID("1:2")' )
2389             p = PSet( v = VLuminosityBlockID())
2390             p.v = [(3,1)]
2391             self.assertEqual( p.v.dumpPython(), 'cms.VLuminosityBlockID((3, 1))' )
2392 
2393         def testEventRange(self):
2394             range1 = EventRange(1, 0, 2, 3, 0, 4)
2395             range2 = EventRange._valueFromString("1:2 - 3:4")
2396             range3 = EventRange._valueFromString("1:MIN - 3:MAX")
2397             self.assertEqual(repr(range1), repr(range2))
2398             self.assertEqual(range1.value(), "1:0:2-3:0:4")
2399             self.assertEqual(repr(range3), "cms.EventRange(1, 0, 1, 3, 0, 0)")
2400             pset = PSetTester()
2401             range1.insertInto(pset,'foo')
2402             range2.insertInto(pset,'bar')
2403             range4 = EventRange((1,2,3), (4,5,6))
2404             self.assertEqual(repr(range4), "cms.EventRange(1, 2, 3, 4, 5, 6)")
2405             other = EventRange(1,1,1,2,2,2)
2406             other.setValue(range1.value())
2407             self.assertEqual(range1.value(), other.value())
2408 
2409         def testVEventRange(self):
2410             v1 = VEventRange(EventRange(1, 0, 2, 3, 0, 4))
2411             v2 = VEventRange("1:2-3:4", "5:MIN-7:MAX")
2412             self.assertEqual( v2.dumpPython(), 'cms.VEventRange("1:2-3:4", "5:MIN-7:MAX")')
2413             self.assertEqual( repr(v1[0]), "cms.EventRange(1, 0, 2, 3, 0, 4)" )
2414             pset = PSetTester()
2415             v2.insertInto(pset,'foo')
2416             v3 = VEventRange(((1,2,3), (4,5,6)), ((7,1,1),(8,0,0)))
2417             self.assertEqual(v3.dumpPython(), "cms.VEventRange(((1, 2, 3), (4, 5, 6)), ((7, 1, 1), (8, 0, 0)))")
2418             p = PSet(v = VEventRange())
2419             p.v = [((3,2,1), (7,8,9))]
2420             self.assertEqual(p.v[0], ((3,2,1), (7,8,9)))
2421 
2422         def testLuminosityBlockRange(self):
2423             range1 = LuminosityBlockRange(1, 2, 3, 4)
2424             range2 = LuminosityBlockRange._valueFromString("1:2 - 3:4")
2425             range3 = LuminosityBlockRange._valueFromString("1:MIN - 3:MAX")
2426             self.assertEqual(repr(range1), repr(range2))
2427             self.assertEqual(range1.value(), "1:2-3:4")
2428             self.assertEqual(repr(range3), "cms.LuminosityBlockRange(1, 1, 3, 0)")
2429             pset = PSetTester()
2430             range1.insertInto(pset,'foo')
2431             range2.insertInto(pset,'bar')
2432             range4 = LuminosityBlockRange(1, 2, 3, 4)
2433             range4.setValue((2,3,4,5))
2434             self.assertEqual(repr(range4), "cms.LuminosityBlockRange(2, 3, 4, 5)")
2435             range5 = LuminosityBlockRange((1,2), (3,4))
2436             self.assertEqual(repr(range5), "cms.LuminosityBlockRange(1, 2, 3, 4)")
2437             other = LuminosityBlockRange(1,1,2,2)
2438             other.setValue(range1.value())
2439             self.assertEqual(range1.value(), other.value())
2440         def testVLuminosityBlockRange(self):
2441             v1 = VLuminosityBlockRange(LuminosityBlockRange(1, 2, 3, 4))
2442             v2 = VLuminosityBlockRange("1:2-3:4", "5:MIN-7:MAX")
2443             self.assertEqual( repr(v1[0]), "cms.LuminosityBlockRange(1, 2, 3, 4)" )
2444             pset = PSetTester()
2445             v2.insertInto(pset,'foo')
2446             v3 = VLuminosityBlockRange(((1,2), (3,4)), ((5,6), (7,8)))
2447             self.assertEqual( v3.dumpPython(), "cms.VLuminosityBlockRange(((1, 2), (3, 4)), ((5, 6), (7, 8)))")
2448             p = PSet(v = VLuminosityBlockRange())
2449             p.v = [((3,2), (7,8))]
2450             self.assertEqual(p.v[0], ((3,2), (7,8)))
2451             self.assertRaises(TypeError, lambda x: VLuminosityBlockRange(x), 1)
2452 
2453             self.assertRaises(TypeError, lambda x: VLuminosityBlockRange(x), ((1,2,3),(1,2)))
2454 
2455         def testPSetConversion(self):
2456             p = PSet(a = untracked.int32(7),
2457                      b = untracked.InputTag("b:"),
2458                      c = untracked.ESInputTag("c:"),
2459                      d = EventID(1,1,1),
2460                      e = LuminosityBlockID(1,1),
2461                      f = EventRange(1,1,1,8,8,8),
2462                      g = LuminosityBlockRange(1,1,8,8),
2463                      h = untracked.string('dummy'),
2464                      i = untracked.bool(False),
2465                      j = untracked.uint32(7),
2466                      k = untracked.int64(7),
2467                      l = untracked.uint64(7),
2468                      m = untracked.double(7.0),
2469                      n = FileInPath("xxx"),
2470                      o = untracked.vint32(7,8),
2471                      p = untracked.VInputTag(InputTag("b:"),InputTag("c:")),
2472                      q = untracked.VESInputTag(ESInputTag("c:"),ESInputTag("d:")),
2473                      r = untracked.VEventID(EventID(1,1,1),EventID(2,2,2)),
2474                      s = untracked.VLuminosityBlockID(LuminosityBlockID(1,1),LuminosityBlockID(2,3)),
2475                      t = untracked.VEventRange(EventRange(1,1,1,8,8,8), EventRange(9,9,9,18,18,18)),
2476                      u = untracked.VLuminosityBlockRange(LuminosityBlockRange(1,1,8,8), LuminosityBlockRange(9,9,18,18)),
2477                      v = untracked.vstring('dummy','anotherdummy'),
2478                      w = untracked.vbool(False,True),
2479                      x = untracked.vuint32(7,8),
2480                      y = untracked.vint64(7,8),
2481                      z = untracked.vuint64(7,8),
2482                      A = vdouble(7.0,8.0)
2483             )
2484             convert = _ConvertToPSet()
2485             p.insertInto(convert,"p")
2486             self.assertTrue(hasattr(convert.pset,'p'))
2487             self.assertTrue(hasattr(convert.pset.p,'a'))
2488             self.assertEqual(p.a,convert.pset.p.a)
2489             self.assertEqual(p.a.isTracked(),convert.pset.p.a.isTracked())
2490 
2491             q = PSet(b = int32(1), p = p)
2492             q.insertInto(convert,"q")
2493             self.assertTrue(hasattr(convert.pset,'q'))
2494             self.assertTrue(hasattr(convert.pset.q,'b'))
2495             self.assertEqual(q.b,convert.pset.q.b)
2496             self.assertTrue(hasattr(convert.pset.q,'p'))
2497             self.assertTrue(hasattr(convert.pset.q.p,'a'))
2498             self.assertEqual(p.a,convert.pset.q.p.a)
2499             for i in p.parameterNames_():
2500                 self.assertEqual(str(getattr(p,i)),str(getattr(convert.pset.p,i)))
2501         def testVPSetConversion(self):
2502             p = PSet(a = untracked.int32(7))
2503             q = PSet(b = int32(1), p = p)
2504             v = VPSet(p,q)
2505             convert = _ConvertToPSet()
2506             v.insertInto(convert,'v')
2507             self.assertTrue(hasattr(convert.pset,'v'))
2508             self.assertTrue(len(convert.pset.v)==2)
2509             self.assertEqual(v[0].a,convert.pset.v[0].a)
2510             self.assertEqual(v[1].b,convert.pset.v[1].b)
2511             self.assertEqual(v[1].p.a, convert.pset.v[1].p.a)
2512 
2513     class testInequalities(unittest.TestCase):
2514         def testnumbers(self):
2515             self.assertGreater(int32(5), int32(-1))
2516             self.assertGreater(int64(100), 99)
2517             self.assertLess(3, uint32(4))
2518             self.assertLess(6.999999999, uint64(7))
2519             self.assertLessEqual(-5, int32(-5))
2520             self.assertLessEqual(int32(-5), uint32(1))
2521             self.assertGreaterEqual(double(5.3), uint32(5))
2522             self.assertGreater(double(5.3), uint64(5))
2523             self.assertGreater(double(5.3), uint64(5))
2524             self.assertGreater(6, double(5))
2525             self.assertLess(uint64(0xFFFFFFFFFFFFFFFF), 0xFFFFFFFFFFFFFFFF+1)
2526             self.assertEqual(double(5.0), double(5))
2527         def teststring(self):
2528             self.assertGreater(string("I am a string"), "I am a strinf")
2529             self.assertGreaterEqual("I am a string", string("I am a string"))
2530         def testincompatibletypes(self):
2531             import sys
2532             if sys.version_info < (3, 0): #python 2, comparing incompatible types compares the class name
2533                 self.assertLess(double(3), "I am a string")
2534                 self.assertLess(3, string("I am a string"))
2535                 self.assertLess(double(5), "4")
2536             else:                         #python 3, comparing incompatible types fails
2537                 with self.assertRaises(TypeError):
2538                     double(3) < "I am a string"
2539                 with self.assertRaises(TypeError):
2540                     3 < string("I am a string")
2541         def testinfinity(self):
2542             self.assertLess(1e99, double(float("inf")))
2543             self.assertLess(double(1e99), float("inf"))
2544             self.assertGreater(1e99, double(float("-inf")))
2545             self.assertEqual(double(float("inf")), float("inf"))
2546         def testnan(self):
2547             nan = double(float("nan"))
2548             self.assertNotEqual(nan, nan)
2549             self.assertFalse(nan > 3 or nan < 3 or nan == 3)
2550 
2551     unittest.main()