1 from __future__
import absolute_import
2 from .SequenceTypes
import *
3 from .Modules
import OutputModule, EDProducer, EDFilter, EDAnalyzer, Service, ESProducer, ESSource, _Module
4 from .Mixins
import _Labelable
13 if isinstance(visitee, _Labelable):
14 if not visitee.hasLabel_():
15 raise ValueError(
"A task associated with the Schedule contains a module of type '"+visitee.type_()+
"'\nwhich has no assigned label.")
16 elif isinstance(visitee, Service):
17 if not visitee._inProcess:
18 raise ValueError(
"A task associated with the Schedule contains a service of type '"+visitee.type_()+
"'\nwhich is not attached to the process.")
29 if isinstance(visitee,OutputModule):
30 raise ValueError(
"Path "+self.
__label+
"cannot contain an OutputModule, '"+visitee.type_()+
"', with label '"+visitee.label_()+
"'")
32 if isinstance(visitee, _Labelable):
33 if not visitee.hasLabel_():
34 raise ValueError(
"Path "+self.
__label+
"contains a module of type '"+visitee.type_()+
"' which has no assigned label.")
35 elif isinstance(visitee, Service):
36 if not visitee._inProcess:
37 raise ValueError(
"Path "+self.
__label+
"contains a service of type '"+visitee.type_()+
"' which is not attached to the process.\n")
43 _presetFilters = [
"TriggerResultsFilter",
"HLTPrescaler"]
52 if isinstance(visitee, _Labelable):
53 if not visitee.hasLabel_():
54 raise ValueError(
"EndPath "+self.
__label+
"contains a module of type '"+visitee.type_()+
"' which has\nno assigned label.")
55 elif isinstance(visitee, Service):
56 if not visitee._inProcess:
57 raise ValueError(
"EndPath "+self.
__label+
"contains a service of type '"+visitee.type_()+
"' which is not attached to the process.\n")
58 if isinstance(visitee, Task):
62 if isinstance(visitee,EDFilter):
65 self.filtersOnEndpaths.append(visitee.type_())
68 if isinstance(visitee, Task):
72 """Form sets of all modules, ESProducers, ESSources and Services in visited objects. Can be used 73 to visit Paths, EndPaths, Sequences or Tasks. Includes in sets objects on sub-Sequences and sub-Tasks""" 81 if isinstance(visitee, _Module):
82 self.modules.add(visitee)
83 elif isinstance(visitee, ESProducer):
84 self.esProducers.add(visitee)
85 elif isinstance(visitee, ESSource):
86 self.esSources.add(visitee)
87 elif isinstance(visitee, Service):
88 self.services.add(visitee)
93 """ Combines 3 different visitor classes in 1 so we only have to visit all the paths and endpaths once""" 94 def __init__(self, validator, node, decorated):
99 self._validator.enter(visitee)
100 self._node.enter(visitee)
101 self._decorated.enter(visitee)
103 self._validator.leave(visitee)
106 self._decorated.leave(visitee)
109 """Fill a list with the names of Event module types in a sequence. The names are determined 110 by using globals() to lookup the variable names assigned to the modules. This 111 allows the determination of the labels before the modules have been attached to a Process.""" 113 self.
_moduleToName = { v[1]:v[0]
for v
in six.iteritems(globals_)
if isinstance(v[1],_Module) }
116 if isinstance(node,_Module):
121 if __name__==
"__main__":
127 def testValidators(self):
133 producer.setLabel(
"producer")
134 analyzer.setLabel(
"analyzer")
135 output.setLabel(
"output")
136 filter.setLabel(
"filter")
141 p3 =
Path(s1+unlabeled)
142 ep1 =
EndPath(producer+output+analyzer)
148 p1.visit(pathValidator)
149 self.assertRaises(ValueError, p2.visit, pathValidator)
150 self.assertRaises(ValueError, p3.visit, pathValidator)
151 ep1.visit(endpathValidator)
152 ep2.visit(endpathValidator)
153 ep3.visit(endpathValidator)
154 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)