Apply conditions included in action runtime. Actions now decide their own execution conditions
This commit is contained in:
@@ -1,58 +1,57 @@
|
||||
def applyConditions(definition, dictionary, outputs):
|
||||
if hasattr(definition, "filters"):
|
||||
#print("DEBUG DICTIONARY PASS")
|
||||
#print(dictionary)
|
||||
for filter in definition.filters:
|
||||
#print(filter)
|
||||
try:
|
||||
if isinstance(filter["filtervalue"], dict):
|
||||
#print("DEBUGGING INT ERROR")
|
||||
#print(filter["filtervalue"])
|
||||
resolvedoutput = outputs[filter["filtervalue"]["outputs"]]
|
||||
#print(resolvedoutput)
|
||||
#filter["filtervalue"] = outputs[filter["filtervalue"]["outputs"]]
|
||||
#print(outputs[filter["filtervalue"]["outputs"]])
|
||||
filter["filtervalue"] = resolvedoutput
|
||||
|
||||
for filter in definition.filters:
|
||||
try:
|
||||
filtervalue = filter["filtervalue"]
|
||||
if isinstance(filter["filtervalue"], dict):
|
||||
|
||||
filtervalue = outputs[filtervalue["outputs"]]
|
||||
|
||||
if filter["operator"] == ">=":
|
||||
if dictionary.get(filter["filterkey"]) >= filter["filtervalue"]:
|
||||
if dictionary.get(filter["filterkey"]) >= int(filtervalue):
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
if filter["operator"] == "<=":
|
||||
if dictionary.get(filter["filterkey"]) <= filter["filtervalue"]:
|
||||
if dictionary.get(filter["filterkey"]) <= int(filtervalue):
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
if filter["operator"] == "==":
|
||||
if dictionary.get(filter["filterkey"]) == filter["filtervalue"]:
|
||||
if dictionary.get(filter["filterkey"]) == filtervalue:
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
if filter["operator"] == "!=":
|
||||
if dictionary.get(filter["filterkey"]) != filter["filtervalue"]:
|
||||
if dictionary.get(filter["filterkey"]) != filtervalue:
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
if filter["operator"] == ">":
|
||||
if dictionary.get(filter["filterkey"]) > filter["filtervalue"]:
|
||||
if dictionary.get(filter["filterkey"]) > int(filtervalue):
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
if filter["operator"] == "<":
|
||||
if dictionary.get(filter["filterkey"]) < filter["filtervalue"]:
|
||||
if dictionary.get(filter["filterkey"]) < int(filtervalue):
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
if filter["operator"] == "in":
|
||||
if filter["filtervalue"] in dictionary:
|
||||
if filtervalue in dictionary:
|
||||
print(filter["print"])
|
||||
return True, filter
|
||||
|
||||
except KeyError:
|
||||
print("Recording last unread for future checks")
|
||||
continue
|
||||
print("Value not present")
|
||||
print(filter)
|
||||
return True, filter
|
||||
#continue
|
||||
|
||||
#except TypeError:
|
||||
# print("TypeError")
|
||||
# return False, None
|
||||
|
||||
return False, None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user