Apply conditions included in action runtime. Actions now decide their own execution conditions
This commit is contained in:
@@ -3,7 +3,6 @@ from core.runtime.runtimecontract import buildRuntimeAttr, buildPreRuntimeAttr
|
|||||||
|
|
||||||
|
|
||||||
def buildAction (action, outputs):
|
def buildAction (action, outputs):
|
||||||
#outputs, resolved = buildPreRuntimeAttr(action, outputs)
|
|
||||||
|
|
||||||
if hasattr(action, "recursive"):
|
if hasattr(action, "recursive"):
|
||||||
recursiveresponses = []
|
recursiveresponses = []
|
||||||
@@ -15,19 +14,24 @@ def buildAction (action, outputs):
|
|||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
outputs[action.recursive["label"]] = item
|
outputs[action.recursive["label"]] = item
|
||||||
|
outputs, resolved, match, filter = buildPreRuntimeAttr(action, outputs)
|
||||||
|
|
||||||
outputs, resolved = buildPreRuntimeAttr(action, outputs)
|
if match:
|
||||||
|
continue
|
||||||
|
|
||||||
response, outputs = executeRequest(action, outputs, resolved)
|
response, outputs = executeRequest(action, outputs, resolved)
|
||||||
recursiveresponses.append(response)
|
recursiveresponses.append(response)
|
||||||
|
|
||||||
outputs, response = buildRuntimeAttr(action, outputs, resolved, response)
|
outputs, response = buildRuntimeAttr(action, outputs, resolved, response)
|
||||||
|
|
||||||
return outputs, recursiveresponses
|
return outputs, recursiveresponses, match, filter
|
||||||
|
|
||||||
else:
|
else:
|
||||||
outputs, resolved = buildPreRuntimeAttr(action, outputs)
|
outputs, resolved, match, filter = buildPreRuntimeAttr(action, outputs)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
return outputs, resolved, match, filter
|
||||||
|
|
||||||
response, outputs = executeRequest(action, outputs, resolved)
|
response, outputs = executeRequest(action, outputs, resolved)
|
||||||
outputs, response = buildRuntimeAttr(action, outputs, resolved, response)
|
outputs, response = buildRuntimeAttr(action, outputs, resolved, response)
|
||||||
|
|
||||||
return outputs, response
|
return outputs, response, match, filter
|
||||||
|
|||||||
@@ -8,24 +8,18 @@ outputs = {}
|
|||||||
def buildOperation(definition, outputs):
|
def buildOperation(definition, outputs):
|
||||||
actions = definition.actions
|
actions = definition.actions
|
||||||
responses = []
|
responses = []
|
||||||
#outputs = {}
|
|
||||||
|
|
||||||
for action in actions:
|
for action in actions:
|
||||||
|
|
||||||
if skipStep(definition, action, outputs):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if action == "recursiveset":
|
if action == "recursiveset":
|
||||||
outputs, responses = recursiveSet(definition, outputs, responses)
|
outputs, responses = recursiveSet(definition, outputs, responses)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
outputs, response = buildAction(action, outputs)
|
outputs, response, match, filter = buildAction(action, outputs)
|
||||||
|
|
||||||
responses.append(response)
|
responses.append(response)
|
||||||
|
|
||||||
|
|
||||||
#print("DEBUG ID GRAB. CHECK LASTMESSAGES")
|
|
||||||
#print(outputs)
|
|
||||||
#print(responses)
|
|
||||||
|
|
||||||
#except Exception as error:
|
#except Exception as error:
|
||||||
#outputs = manageFailure(error, action, outputs)
|
#outputs = manageFailure(error, action, outputs)
|
||||||
|
|||||||
@@ -1,58 +1,57 @@
|
|||||||
def applyConditions(definition, dictionary, outputs):
|
def applyConditions(definition, dictionary, outputs):
|
||||||
if hasattr(definition, "filters"):
|
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 filter["operator"] == ">=":
|
||||||
if dictionary.get(filter["filterkey"]) >= filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) >= int(filtervalue):
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
if filter["operator"] == "<=":
|
if filter["operator"] == "<=":
|
||||||
if dictionary.get(filter["filterkey"]) <= filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) <= int(filtervalue):
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
if filter["operator"] == "==":
|
if filter["operator"] == "==":
|
||||||
if dictionary.get(filter["filterkey"]) == filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) == filtervalue:
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
if filter["operator"] == "!=":
|
if filter["operator"] == "!=":
|
||||||
if dictionary.get(filter["filterkey"]) != filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) != filtervalue:
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
if filter["operator"] == ">":
|
if filter["operator"] == ">":
|
||||||
if dictionary.get(filter["filterkey"]) > filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) > int(filtervalue):
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
if filter["operator"] == "<":
|
if filter["operator"] == "<":
|
||||||
if dictionary.get(filter["filterkey"]) < filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) < int(filtervalue):
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
if filter["operator"] == "in":
|
if filter["operator"] == "in":
|
||||||
if filter["filtervalue"] in dictionary:
|
if filtervalue in dictionary:
|
||||||
print(filter["print"])
|
print(filter["print"])
|
||||||
return True, filter
|
return True, filter
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print("Recording last unread for future checks")
|
print("Value not present")
|
||||||
continue
|
print(filter)
|
||||||
|
return True, filter
|
||||||
|
#continue
|
||||||
|
|
||||||
|
#except TypeError:
|
||||||
|
# print("TypeError")
|
||||||
|
# return False, None
|
||||||
|
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user