CMS 3D CMS Logo

printPaths.py
Go to the documentation of this file.
1 from __future__ import print_function
3 import FWCore.ParameterSet.Config as cms
4 import FWCore.ParameterSet.Modules as mod
5 import six
6 
7 def printPaths(process):
8  "print all the paths in the process"
9  for p in six.itervalues(process.paths):
10  printPath(p)
11 
12 def printPath(pth, indent="", indentDelta=" ", type="path"):
13  item = pth._seq
14  print(indent+type+": "+pth.label_())
15  indent += indentDelta
16  if isinstance(item,mod._Module):
17  print(indent+"module: "+item.label_()+" <"+item.type_()+">")
18  elif isinstance(item,cms.Sequence):
19  printPath(item,indent,indentDelta,"seq")
20  else:
21  _printOp(item,indent,indentDelta)
22 
23 def _printOp(op,indent, indentDelta):
24  indent += indentDelta
25  for i in dir(op):
26  o = getattr(op,i)
27  if isinstance(o,mod._Module):
28  print(indent+"module: "+o.label_()+" <"+o.type_()+">")
29  elif isinstance(o, cms.Sequence):
30  printPath(o,indent,indentDelta, "seq")
31  elif isinstance(o,sqt._Sequenceable):
32  _printOp(o,indent,indentDelta)
33 
34 if __name__ == "__main__":
35  import unittest
36  class TestPrintPath(unittest.TestCase):
37  def testPrint(self):
38  p=cms.Process("Test")
39  p.foo = cms.EDProducer("Foo")
40  p.p = cms.Path(p.foo)
41  printPath(p.p)
42 
43  p=cms.Process("Test")
44  p.foo = cms.EDProducer("Foo")
45  p.bar = cms.EDProducer("Bar")
46  p.p = cms.Path(p.foo*p.bar)
47  printPath(p.p)
48 
49  p=cms.Process("Test")
50  p.foo = cms.EDProducer("Foo")
51  p.bar = cms.EDProducer("Bar")
52  p.s = cms.Sequence(p.foo*p.bar)
53  p.fii = cms.EDProducer("Fii")
54  p.p = cms.Path(p.s*p.fii)
55  printPath(p.p)
56 
57  printPaths(p)
58 
59  unittest.main()
printPaths.printPath
def printPath(pth, indent="", indentDelta=" ", type="path")
Definition: printPaths.py:12
printPaths.TestPrintPath.testPrint
def testPrint(self)
Definition: printPaths.py:37
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
printPaths.printPaths
def printPaths(process)
Definition: printPaths.py:7
printPaths.TestPrintPath
Definition: printPaths.py:36
printPaths
Definition: printPaths.py:1
printPaths._printOp
def _printOp(op, indent, indentDelta)
Definition: printPaths.py:23
SequenceTypes
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23