CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FWCore/ParameterSet/python/printPaths.py

Go to the documentation of this file.
00001 import FWCore.ParameterSet.SequenceTypes as sqt
00002 import FWCore.ParameterSet.Config as cms
00003 import FWCore.ParameterSet.Modules as mod
00004 
00005 def printPaths(process):
00006     "print all the paths in the process"
00007     for p  in process.paths.itervalues():
00008         printPath(p)
00009 
00010 def printPath(pth, indent="", indentDelta=" ", type="path"):
00011     item = pth._seq
00012     print indent+type+": "+pth.label_()
00013     indent += indentDelta
00014     if isinstance(item,mod._Module):
00015         print indent+"module: "+item.label_()+" <"+item.type_()+">"
00016     elif isinstance(item,cms.Sequence):
00017         printPath(item,indent,indentDelta,"seq")
00018     else:
00019         _printOp(item,indent,indentDelta)
00020 
00021 def _printOp(op,indent, indentDelta):
00022     indent += indentDelta
00023     for i in dir(op):
00024         o = getattr(op,i)
00025         if isinstance(o,mod._Module):
00026             print indent+"module: "+o.label_()+" <"+o.type_()+">"            
00027         elif isinstance(o, cms.Sequence):
00028             printPath(o,indent,indentDelta, "seq")
00029         elif isinstance(o,sqt._Sequenceable):
00030             _printOp(o,indent,indentDelta)
00031 
00032 if __name__ == "__main__":
00033     import unittest
00034     class TestPrintPath(unittest.TestCase):
00035         def testPrint(self):
00036             p=cms.Process("Test")
00037             p.foo = cms.EDProducer("Foo")
00038             p.p = cms.Path(p.foo)
00039             printPath(p.p)
00040 
00041             p=cms.Process("Test")
00042             p.foo = cms.EDProducer("Foo")
00043             p.bar = cms.EDProducer("Bar")
00044             p.p = cms.Path(p.foo*p.bar)
00045             printPath(p.p)
00046 
00047             p=cms.Process("Test")
00048             p.foo = cms.EDProducer("Foo")
00049             p.bar = cms.EDProducer("Bar")
00050             p.s = cms.Sequence(p.foo*p.bar)
00051             p.fii = cms.EDProducer("Fii")
00052             p.p = cms.Path(p.s*p.fii)
00053             printPath(p.p)
00054             
00055             printPaths(p)
00056 
00057     unittest.main()