CMS 3D CMS Logo

Functions
common Namespace Reference

Functions

def analyzers_by_type (process, types)
 
def esproducers_by_type (process, types)
 
def filters_by_type (process, types)
 
def insert_modules_after (process, target, modules)
 
def insert_modules_before (process, target, modules)
 
def producers_by_type (process, types)
 
def replace_with (fromObj, toObj)
 

Function Documentation

def common.analyzers_by_type (   process,
  types 
)

Definition at line 14 of file common.py.

14 def analyzers_by_type(process, *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)
17 
def analyzers_by_type(process, types)
Definition: common.py:14
def common.esproducers_by_type (   process,
  types 
)

Definition at line 18 of file common.py.

18 def esproducers_by_type(process, *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)
21 
22 
def esproducers_by_type(process, types)
Definition: common.py:18
def common.filters_by_type (   process,
  types 
)

Definition at line 10 of file common.py.

10 def filters_by_type(process, *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)
13 
def filters_by_type(process, types)
Definition: common.py:10
def common.insert_modules_after (   process,
  target,
  modules 
)

Definition at line 39 of file common.py.

39 def insert_modules_after(process, target, *modules):
40  "Add the `modules` after the `target` in any Sequence, Paths or EndPath that contains the latter."
41  for sequence in itertools.chain(
42  six.itervalues(process._Process__sequences),
43  six.itervalues(process._Process__paths),
44  six.itervalues(process._Process__endpaths)
45  ):
46  try:
47  position = sequence.index(target)
48  except ValueError:
49  continue
50  else:
51  for module in reversed(modules):
52  sequence.insert(position+1, module)
53 
54 
55 # logic from Modifier.toModify from FWCore/ParameterSet/python/Config.py
def insert_modules_after(process, target, modules)
Definition: common.py:39
def common.insert_modules_before (   process,
  target,
  modules 
)

Definition at line 23 of file common.py.

23 def insert_modules_before(process, target, *modules):
24  "Add the `modules` before the `target` in any Sequence, Paths or EndPath that contains the latter."
25  for sequence in itertools.chain(
26  six.itervalues(process._Process__sequences),
27  six.itervalues(process._Process__paths),
28  six.itervalues(process._Process__endpaths)
29  ):
30  try:
31  position = sequence.index(target)
32  except ValueError:
33  continue
34  else:
35  for module in reversed(modules):
36  sequence.insert(position, module)
37 
38 
def insert_modules_before(process, target, modules)
Definition: common.py:23
def common.producers_by_type (   process,
  types 
)

Definition at line 6 of file common.py.

6 def producers_by_type(process, *types):
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)
9 
def producers_by_type(process, types)
Definition: common.py:6
def common.replace_with (   fromObj,
  toObj 
)
Replace one object with a different one of the same type.

This function replaces the contents of `fromObj` object with those of `toObj`,
so all references ot it remain valid.

Definition at line 56 of file common.py.

References str.

56 def replace_with(fromObj, toObj):
57  """Replace one object with a different one of the same type.
58 
59  This function replaces the contents of `fromObj` object with those of `toObj`,
60  so all references ot it remain valid.
61  """
62 
63  if not isinstance(toObj, type(fromObj)):
64  raise TypeError('replaceWith requires both arguments to be the same type')
65 
66  if isinstance(toObj, cms._ModuleSequenceType):
67  fromObj._seq = toObj._seq
68 
69  elif isinstance(toObj, cms._Parameterizable):
70  # delete the old items, in case `toObj` is not a complete superset of `fromObj`
71  for p in fromObj.parameterNames_():
72  delattr(fromObj, p)
73  for p in toObj.parameterNames_():
74  setattr(fromObj, p, getattr(toObj, p))
75  if isinstance(toObj, cms._TypedParameterizable):
76  fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
77 
78  else:
79  raise TypeError('replaceWith does not work with "%s" objects' % str(type(fromObj)))
80 
81 
def replace_with(fromObj, toObj)
Definition: common.py:56
#define str(s)