test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
printPaths.py
Go to the documentation of this file.
2 import FWCore.ParameterSet.Config as cms
3 import FWCore.ParameterSet.Modules as mod
4 
5 def printPaths(process):
6  "print all the paths in the process"
7  for p in process.paths.itervalues():
8  printPath(p)
9 
10 def printPath(pth, indent="", indentDelta=" ", type="path"):
11  item = pth._seq
12  print indent+type+": "+pth.label_()
13  indent += indentDelta
14  if isinstance(item,mod._Module):
15  print indent+"module: "+item.label_()+" <"+item.type_()+">"
16  elif isinstance(item,cms.Sequence):
17  printPath(item,indent,indentDelta,"seq")
18  else:
19  _printOp(item,indent,indentDelta)
20 
21 def _printOp(op,indent, indentDelta):
22  indent += indentDelta
23  for i in dir(op):
24  o = getattr(op,i)
25  if isinstance(o,mod._Module):
26  print indent+"module: "+o.label_()+" <"+o.type_()+">"
27  elif isinstance(o, cms.Sequence):
28  printPath(o,indent,indentDelta, "seq")
29  elif isinstance(o,sqt._Sequenceable):
30  _printOp(o,indent,indentDelta)
31 
32 if __name__ == "__main__":
33  import unittest
34  class TestPrintPath(unittest.TestCase):
35  def testPrint(self):
36  p=cms.Process("Test")
37  p.foo = cms.EDProducer("Foo")
38  p.p = cms.Path(p.foo)
39  printPath(p.p)
40 
41  p=cms.Process("Test")
42  p.foo = cms.EDProducer("Foo")
43  p.bar = cms.EDProducer("Bar")
44  p.p = cms.Path(p.foo*p.bar)
45  printPath(p.p)
46 
47  p=cms.Process("Test")
48  p.foo = cms.EDProducer("Foo")
49  p.bar = cms.EDProducer("Bar")
50  p.s = cms.Sequence(p.foo*p.bar)
51  p.fii = cms.EDProducer("Fii")
52  p.p = cms.Path(p.s*p.fii)
53  printPath(p.p)
54 
55  printPaths(p)
56 
57  unittest.main()
def printPath
Definition: printPaths.py:10
def printPaths
Definition: printPaths.py:5
def _printOp
Definition: printPaths.py:21
dbl *** dir
Definition: mlp_gen.cc:35