3 import FWCore.ParameterSet.Config
as cms
7 "Find all EDProducers in the Process that are instances of the given C++ type."
8 return (module
for module
in process._Process__producers.values()
if module._TypedParameterizable__type
in types)
11 "Find all EDFilters in the Process that are instances of the given C++ type."
12 return (filter
for filter
in process._Process__filters.values()
if filter._TypedParameterizable__type
in types)
15 "Find all EDAnalyzers in the Process that are instances of the given C++ type."
16 return (analyzer
for analyzer
in process._Process__analyzers.values()
if analyzer._TypedParameterizable__type
in types)
19 "Find all ESProducers in the Process that are instances of the given C++ type."
20 return (module
for module
in process._Process__esproducers.values()
if module._TypedParameterizable__type
in types)
23 "Find all modiles or other components in the Process that are instances of the given C++ type."
24 return (module
for module
in process.__dict__.values()
if hasattr(module,
'_TypedParameterizable__type')
and module._TypedParameterizable__type
in types)
28 "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter."
29 for sequence
in itertools.chain(
30 six.itervalues(process._Process__sequences),
31 six.itervalues(process._Process__paths),
32 six.itervalues(process._Process__endpaths)
35 position = sequence.index(target)
39 for module
in reversed(modules):
40 sequence.insert(position, module)
44 "Add the `modules` after the `target` in any Sequence, Paths or EndPath that contains the latter."
45 for sequence
in itertools.chain(
46 six.itervalues(process._Process__sequences),
47 six.itervalues(process._Process__paths),
48 six.itervalues(process._Process__endpaths)
51 position = sequence.index(target)
55 for module
in reversed(modules):
56 sequence.insert(position+1, module)
61 """Replace one object with a different one of the same type.
63 This function replaces the contents of `fromObj` object with those of `toObj`,
64 so all references ot it remain valid.
67 if not isinstance(toObj, type(fromObj)):
68 raise TypeError(
'replaceWith requires both arguments to be the same type')
70 if isinstance(toObj, cms._ModuleSequenceType):
71 fromObj._seq = toObj._seq
73 elif isinstance(toObj, cms._Parameterizable):
75 for p
in fromObj.parameterNames_():
77 for p
in toObj.parameterNames_():
78 setattr(fromObj, p, getattr(toObj, p))
79 if isinstance(toObj, cms._TypedParameterizable):
80 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
83 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))