CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
6 def printPaths(process):
7  "print all the paths in the process"
8  for p in process.paths.values():
9  printPath(p)
10 
11 def printPath(pth, indent="", indentDelta=" ", type="path"):
12  item = pth._seq
13  print(indent+type+": "+pth.label_())
14  indent += indentDelta
15  if isinstance(item,mod._Module):
16  print(indent+"module: "+item.label_()+" <"+item.type_()+">")
17  elif isinstance(item,cms.Sequence):
18  printPath(item,indent,indentDelta,"seq")
19  else:
20  _printOp(item,indent,indentDelta)
21 
22 def _printOp(op,indent, indentDelta):
23  indent += indentDelta
24  for i in dir(op):
25  o = getattr(op,i)
26  if isinstance(o,mod._Module):
27  print(indent+"module: "+o.label_()+" <"+o.type_()+">")
28  elif isinstance(o, cms.Sequence):
29  printPath(o,indent,indentDelta, "seq")
30  elif isinstance(o,sqt._Sequenceable):
31  _printOp(o,indent,indentDelta)
32 
33 if __name__ == "__main__":
34  import unittest
35  class TestPrintPath(unittest.TestCase):
36  def testPrint(self):
37  p=cms.Process("Test")
38  p.foo = cms.EDProducer("Foo")
39  p.p = cms.Path(p.foo)
40  printPath(p.p)
41 
42  p=cms.Process("Test")
43  p.foo = cms.EDProducer("Foo")
44  p.bar = cms.EDProducer("Bar")
45  p.p = cms.Path(p.foo*p.bar)
46  printPath(p.p)
47 
48  p=cms.Process("Test")
49  p.foo = cms.EDProducer("Foo")
50  p.bar = cms.EDProducer("Bar")
51  p.s = cms.Sequence(p.foo*p.bar)
52  p.fii = cms.EDProducer("Fii")
53  p.p = cms.Path(p.s*p.fii)
54  printPath(p.p)
55 
56  printPaths(p)
57 
58  unittest.main()
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def printPath
Definition: printPaths.py:11
def printPaths
Definition: printPaths.py:6
def _printOp
Definition: printPaths.py:22