3 __all__ = [
'Logic',
'Not']
8 from AthenaCommon.Logging
import logging
9 log = logging.getLogger(__name__)
30 __slots__ = [
'content',
'logicType',
'subConditions']
35 a.logicType = LogicType.NOT
36 a.subConditions.append(x)
43 for sc
in theLogic.subConditions:
44 if sc.logicType
is LogicType.INTERNAL
and sc.name().startswith(
'BGRP'):
45 bunchGroups.append(sc.name())
50 theLogic.subConditions = subConds
51 return (theLogic, bunchGroups)
54 return (subConds[0], bunchGroups)
56 raise RuntimeError(
"Item with logic '%s' has only internal triggers defined" % theLogic)
60 def __init__(self, logicType = LogicType.NONE, content = None):
67 newLogic =
Logic( logicType = LogicType.OR )
72 newLogic.subConditions += [
copy(self)]
74 if x.logicType
is LogicType.OR:
75 newLogic.subConditions +=
copy(x.subConditions)
77 newLogic.subConditions += [
copy(x)]
83 newLogic =
Logic( logicType = LogicType.AND )
88 newLogic.subConditions += [
copy(self)]
90 if x.logicType
is LogicType.AND:
91 newLogic.subConditions +=
copy(x.subConditions)
93 newLogic.subConditions += [
copy(x)]
102 log.debug(
'not is a unary operator, ignore it')
110 log.error(
'LogicType NONE should not have an instance')
119 log.error(
'Logic NOT must have exactly one element but has %i', len(self.
subConditions))
122 if self.
logicType in (LogicType.AND, LogicType.OR):
131 if a.logicType
in (LogicType.THRESHOLD, LogicType.INTERNAL, LogicType.NOT):
134 s +=
'(' +
str(a) +
')'
140 if self.
logicType is LogicType.THRESHOLD:
141 names.add( self.threshold.name )
142 elif self.
logicType is LogicType.INTERNAL:
144 names.add(self.name())
147 names.update( sc.thresholdNames(include_bgrp) )
153 if hasattr(self,
'condition')
and self.condition
is not None:
154 from .CTPCondition
import InternalTrigger
155 if isinstance(self.condition, InternalTrigger):
157 cond.add(self.condition)
159 cond.add( self.condition )
162 cond.update( sc.conditions(include_internal) )
167 if self.
logicType in (LogicType.AND, LogicType.OR):
171 if c.logicType == mylogic:
174 newconditions.extend(c.subConditions)
176 newconditions.append(c)