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)
106 if __name__==
"__main__":
112 def testValidators(self):
118 producer.setLabel(
"producer")
119 analyzer.setLabel(
"analyzer")
120 output.setLabel(
"output")
121 filter.setLabel(
"filter")
126 p3 =
Path(s1+unlabeled)
127 ep1 =
EndPath(producer+output+analyzer)
133 p1.visit(pathValidator)
134 self.assertRaises(ValueError, p2.visit, pathValidator)
135 self.assertRaises(ValueError, p3.visit, pathValidator)
136 ep1.visit(endpathValidator)
137 ep2.visit(endpathValidator)
138 ep3.visit(endpathValidator)
139 self.assertRaises(ValueError, ep4.visit, endpathValidator)
def __init__(self, validator, node, decorated)
def setLabel(self, label)
def setLabel(self, label)