3 import FWCore.ParameterSet.Config
as cms
6 "Find all EDProducers in the Process that are instances of the given C++ type."
7 switches = (module
for module
in (getattr(switchproducer, case) \
8 for switchproducer
in six.itervalues(process._Process__switchproducers) \
9 for case
in switchproducer.parameterNames_()) \
10 if isinstance(module, cms.EDProducer))
11 return (module
for module
in itertools.chain(six.itervalues(process._Process__producers), switches) \
12 if module._TypedParameterizable__type
in types)
15 "Find all EDFilters in the Process that are instances of the given C++ type."
16 return (filter
for filter
in process._Process__filters.values()
if filter._TypedParameterizable__type
in types)
19 "Find all EDAnalyzers in the Process that are instances of the given C++ type."
20 return (analyzer
for analyzer
in process._Process__analyzers.values()
if analyzer._TypedParameterizable__type
in types)
23 "Find all ESProducers in the Process that are instances of the given C++ type."
24 return (module
for module
in process._Process__esproducers.values()
if module._TypedParameterizable__type
in types)
27 "Find all modiles or other components in the Process that are instances of the given C++ type."
28 switches = (module
for module
in (getattr(switchproducer, case) \
29 for switchproducer
in six.itervalues(process._Process__switchproducers) \
30 for case
in switchproducer.parameterNames_()))
31 return (module
for module
in itertools.chain(six.itervalues(process.__dict__), switches) \
32 if hasattr(module,
'_TypedParameterizable__type')
and module._TypedParameterizable__type
in types)
36 "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter."
37 for sequence
in itertools.chain(
38 six.itervalues(process._Process__sequences),
39 six.itervalues(process._Process__paths),
40 six.itervalues(process._Process__endpaths)
43 position = sequence.index(target)
47 for module
in reversed(modules):
48 sequence.insert(position, module)
52 "Add the `modules` after the `target` in any Sequence, Paths or EndPath that contains the latter."
53 for sequence
in itertools.chain(
54 six.itervalues(process._Process__sequences),
55 six.itervalues(process._Process__paths),
56 six.itervalues(process._Process__endpaths)
59 position = sequence.index(target)
63 for module
in reversed(modules):
64 sequence.insert(position+1, module)
69 """Replace one object with a different one of the same type.
71 This function replaces the contents of `fromObj` object with those of `toObj`,
72 so all references ot it remain valid.
75 if not isinstance(toObj, type(fromObj)):
76 raise TypeError(
'replaceWith requires both arguments to be the same type')
78 if isinstance(toObj, cms._ModuleSequenceType):
79 fromObj._seq = toObj._seq
81 elif isinstance(toObj, cms._Parameterizable):
83 for p
in fromObj.parameterNames_():
85 for p
in toObj.parameterNames_():
86 setattr(fromObj, p, getattr(toObj, p))
87 if isinstance(toObj, cms._TypedParameterizable):
88 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
91 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))