42 lines
954 B
Python
42 lines
954 B
Python
from actions import Action
|
|
from conditions import Condition
|
|
|
|
|
|
class Entry:
|
|
|
|
def __init__(self, name: str, condition: list[Condition], success: list[Action], fail: list[Action]):
|
|
self._name = name
|
|
self._conditions = condition
|
|
self._success = success
|
|
self._fail = fail
|
|
|
|
def execute(self):
|
|
result, output = True, None
|
|
for con in self._conditions:
|
|
res, output = con.execute(output)
|
|
if not res:
|
|
result = False
|
|
break
|
|
if result:
|
|
for s in self._success:
|
|
s.execute(output)
|
|
else:
|
|
for f in self._fail:
|
|
f.execute(output)
|
|
|
|
@property
|
|
def name(self):
|
|
return self._name
|
|
|
|
@property
|
|
def condition(self):
|
|
return self._conditions
|
|
|
|
@property
|
|
def success(self):
|
|
return self._success
|
|
|
|
@property
|
|
def fail(self):
|
|
return self._fail
|