CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SequenceVisitors.py
Go to the documentation of this file.
1 #from Modules import OutputModule, EDProducer, EDFilter
2 from SequenceTypes import *
3 from Modules import OutputModule, EDProducer, EDFilter, EDAnalyzer
4 
5 
7  def enter(self,visitee):
8  if isinstance(visitee,OutputModule):
9  raise ValueError("Path cannot contain an OutputModule, "+visitee.type_()+", with label "+visitee.label_())
10  def leave(self,visitee):
11  pass
12 
13 class EndPathValidator(object):
14  _presetFilters = ["TriggerResultsFilter", "HLTPrescaler"]
15  def __init__(self):
17  def enter(self,visitee):
18  if isinstance(visitee,EDFilter):
19  if (visitee.type_() in self._presetFilters):
20  if (visitee.type_() not in self.filtersOnEndpaths):
21  self.filtersOnEndpaths.append(visitee.type_())
22  def leave(self,visitee):
23  pass
24 
25 if __name__=="__main__":
26  import unittest
27  class TestModuleCommand(unittest.TestCase):
28  def setUp(self):
29  """Nothing to do """
30  pass
31  def testValidators(self):
32  producer = EDProducer("Producer")
33  analyzer = EDAnalyzer("Analyzer")
34  output = OutputModule("Out")
35  filter = EDFilter("Filter")
36  producer.setLabel("producer")
37  analyzer.setLabel("analyzer")
38  output.setLabel("output")
39  filter.setLabel("filter")
40  s1 = Sequence(analyzer*producer)
41  s2 = Sequence(output+filter)
42  p1 = Path(s1)
43  p2 = Path(s1*s2)
44  ep1 = EndPath(producer+output+analyzer)
45  ep2 = EndPath(filter+output)
46  ep3 = EndPath(s2)
47  pathValidator = PathValidator()
48  endpathValidator = EndPathValidator()
49  p1.visit(pathValidator)
50  self.assertRaises(ValueError, p2.visit, pathValidator)
51  ep1.visit(endpathValidator)
52  ep2.visit(endpathValidator)
53  ep3.visit(endpathValidator)
54 
55  unittest.main()
56 
list object
Definition: dbtoconf.py:77