Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-13 23:03:13

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 class ExternalGeneratorFilter(cms.EDFilter):
0004     def __init__(self, prod, _external_process_waitTime_ = cms.untracked.uint32(300), _external_process_verbose_ = cms.untracked.bool(False),
0005                  _external_process_components_ = cms.vstring()):
0006         self.__dict__['_external_process_verbose_']=_external_process_verbose_
0007         self.__dict__['_external_process_waitTime_']=_external_process_waitTime_
0008         self.__dict__['_external_process_components_'] = _external_process_components_
0009         self.__dict__['_prod'] = prod
0010         super(cms.EDFilter,self).__init__('ExternalGeneratorFilter')
0011     def __setattr__(self, name, value):
0012         if name =='_external_process_verbose_':
0013             return self.__dict__['_external_process_verbose_']
0014         setattr(self._prod, name, value)
0015     def __getattr__(self, name):
0016         if name =='_prod':
0017             return self.__dict__['_prod']
0018         if name == '_external_process_verbose_':
0019             return self.__dict__['_external_process_verbose_']
0020         return getattr(self._prod, name)
0021     def __getstate__(self): return self.__dict__
0022     def __setstate__(self, d): self.__dict__.update(d)
0023     def clone(self, **params):
0024         returnValue = ExternalGeneratorFilter.__new__(type(self))
0025         returnValue.__init__(self._prod.clone())
0026         return returnValue
0027     def insertInto(self, parameterSet, myname):
0028         newpset = parameterSet.newPSet()
0029         newpset.addString(True, "@module_label", self.moduleLabel_(myname))
0030         newpset.addString(True, "@module_type", self.type_())
0031         newpset.addString(True, "@module_edm_type", cms.EDFilter.__name__)
0032         newpset.addString(True, "@external_type", self._prod.type_())
0033         newpset.addString(False,"@python_config", self._prod.dumpPython().replace(R"\n", R"\\n"))
0034         newpset.addBool(False,"_external_process_verbose_", self._external_process_verbose_.value())
0035         newpset.addUInt32(False,"_external_process_waitTime_", self._external_process_waitTime_.value())
0036         newpset.addVString(True, "_external_process_components_", self._external_process_components_.value())
0037 
0038         extraConfig =''
0039         for x in self._external_process_components_.value():
0040             extraConfig += "process."+x+"="+parameterSet.getTopPSet_(x).dumpPython()
0041             extraConfig += '\n'
0042         newpset.addString(False, "_external_process_extraConfig_", extraConfig)
0043         self._prod.insertContentsInto(newpset)
0044         parameterSet.addPSet(True, self.nameInProcessDesc_(myname), newpset)
0045     def dumpPython(self, options=cms.PrintOptions()):
0046         cms.specialImportRegistry.registerUse(self)
0047         result = "%s(" % self.__class__.__name__ # not including cms. since the deriving classes are not in cms "namespace"
0048         options.indent()
0049         result += "\n"+options.indentation() + self._prod.dumpPython(options)
0050         result +=options.indentation()+",\n"
0051         result += options.indentation() + "_external_process_waitTime_ = " + self._external_process_waitTime_.dumpPython(options) + ',\n'
0052         result += options.indentation() + "_external_process_verbose_ = " + self._external_process_verbose_.dumpPython(options) + ',\n'
0053         result += options.indentation() + "_external_process_components_ =" + self._external_process_components_.dumpPython(options) + ','
0054         options.unindent()
0055         result += "\n)\n"
0056         return result
0057 
0058 cms.specialImportRegistry.registerSpecialImportForType(ExternalGeneratorFilter, "from GeneratorInterface.Core.ExternalGeneratorFilter import ExternalGeneratorFilter")