1 from SequenceTypes
import *
2 from Modules
import OutputModule, EDProducer, EDFilter, EDAnalyzer, Service, ESProducer, ESSource, _Module
3 from Mixins
import _Labelable
11 if isinstance(visitee, _Labelable):
12 if not visitee.hasLabel_():
13 raise ValueError(
"A task associated with the Schedule contains a module of type '"+visitee.type_()+
"'\nwhich has no assigned label.")
14 elif isinstance(visitee, Service):
15 if not visitee._inProcess:
16 raise ValueError(
"A task associated with the Schedule contains a service of type '"+visitee.type_()+
"'\nwhich is not attached to the process.")
27 if isinstance(visitee,OutputModule):
28 raise ValueError(
"Path "+self.
__label+
"cannot contain an OutputModule, '"+visitee.type_()+
"', with label '"+visitee.label_()+
"'")
30 if isinstance(visitee, _Labelable):
31 if not visitee.hasLabel_():
32 raise ValueError(
"Path "+self.
__label+
"contains a module of type '"+visitee.type_()+
"' which has no assigned label.")
33 elif isinstance(visitee, Service):
34 if not visitee._inProcess:
35 raise ValueError(
"Path "+self.
__label+
"contains a service of type '"+visitee.type_()+
"' which is not attached to the process.\n")
41 _presetFilters = [
"TriggerResultsFilter",
"HLTPrescaler"]
50 if isinstance(visitee, _Labelable):
51 if not visitee.hasLabel_():
52 raise ValueError(
"EndPath "+self.
__label+
"contains a module of type '"+visitee.type_()+
"' which has\nno assigned label.")
53 elif isinstance(visitee, Service):
54 if not visitee._inProcess:
55 raise ValueError(
"EndPath "+self.
__label+
"contains a service of type '"+visitee.type_()+
"' which is not attached to the process.\n")
56 if isinstance(visitee, Task):
60 if isinstance(visitee,EDFilter):
61 if (visitee.type_()
in self._presetFilters):
63 self.filtersOnEndpaths.append(visitee.type_())
66 if isinstance(visitee, Task):
70 """Form sets of all modules, ESProducers, ESSources and Services in visited objects. Can be used 71 to visit Paths, EndPaths, Sequences or Tasks. Includes in sets objects on sub-Sequences and sub-Tasks""" 79 if isinstance(visitee, _Module):
80 self.modules.add(visitee)
81 elif isinstance(visitee, ESProducer):
82 self.esProducers.add(visitee)
83 elif isinstance(visitee, ESSource):
84 self.esSources.add(visitee)
85 elif isinstance(visitee, Service):
86 self.services.add(visitee)
91 """ Combines 3 different visitor classes in 1 so we only have to visit all the paths and endpaths once""" 92 def __init__(self, validator, node, decorated):
97 self._validator.enter(visitee)
98 self._node.enter(visitee)
99 self._decorated.enter(visitee)
101 self._validator.leave(visitee)
104 self._decorated.leave(visitee)
107 """Fill a list with the names of Event module types in a sequence. The names are determined 108 by using globals() to lookup the variable names assigned to the modules. This 109 allows the determination of the labels before the modules have been attached to a Process.""" 111 self.
_moduleToName = { v[1]:v[0]
for v
in globals_.iteritems()
if isinstance(v[1],_Module) }
114 if isinstance(node,_Module):
119 if __name__==
"__main__":
125 def testValidators(self):
131 producer.setLabel(
"producer")
132 analyzer.setLabel(
"analyzer")
133 output.setLabel(
"output")
134 filter.setLabel(
"filter")
139 p3 =
Path(s1+unlabeled)
140 ep1 =
EndPath(producer+output+analyzer)
146 p1.visit(pathValidator)
147 self.assertRaises(ValueError, p2.visit, pathValidator)
148 self.assertRaises(ValueError, p3.visit, pathValidator)
149 ep1.visit(endpathValidator)
150 ep2.visit(endpathValidator)
151 ep3.visit(endpathValidator)
152 self.assertRaises(ValueError, ep4.visit, endpathValidator)
def __init__(self, validator, node, decorated)
def setLabel(self, label)
def __init__(self, globals_, l)
def setLabel(self, label)