Working resolver integration with buildSelect3 exception
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,8 +4,8 @@ from .request import buildRequest
|
||||
|
||||
session = requests.Session()
|
||||
|
||||
def executeRequest(action, outputs):
|
||||
request, outputs = buildRequest(action, outputs)
|
||||
def executeRequest(action, outputs, resolved):
|
||||
request, outputs = buildRequest(action, outputs, resolved)
|
||||
|
||||
response = session.request(
|
||||
method=request["method"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
def buildKey(key, outputs):
|
||||
def buildKey(key, outputs, resolved):
|
||||
value = key["keyvalue"]
|
||||
|
||||
if isinstance(value, dict) and "output" in value:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from .key import buildKey
|
||||
|
||||
def buildObject(keys, outputs):
|
||||
def buildObject(keys, outputs, resolved):
|
||||
object = {}
|
||||
|
||||
for key in keys:
|
||||
object.update(
|
||||
buildKey(key, outputs),
|
||||
buildKey(key, outputs, resolved),
|
||||
)
|
||||
|
||||
return object
|
||||
|
||||
+26
-4
@@ -1,4 +1,4 @@
|
||||
def buildPath(path, outputs):
|
||||
def buildPath(path, outputs, resolved):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
|
||||
@@ -6,9 +6,10 @@ def buildPath(path, outputs):
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
value = outputs[part["output"]][part["keys"]]
|
||||
|
||||
|
||||
for key, val in part.items():
|
||||
#value = outputs[part["output"]][part["keys"]]
|
||||
value = outputs[val]
|
||||
#print("DEBUG path", value)
|
||||
|
||||
#for key in part.get("keys", []):
|
||||
#value = value[key]
|
||||
@@ -16,5 +17,26 @@ def buildPath(path, outputs):
|
||||
result += str(value)
|
||||
else:
|
||||
result += part
|
||||
#print(result)
|
||||
return result
|
||||
|
||||
def buildPath2(path, outputs, resolved):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
|
||||
result = ""
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
#value = outputs[part["output"]][part["keys"]]
|
||||
value = outputs["path"]
|
||||
#print("DEBUG path", value)
|
||||
|
||||
#for key in part.get("keys", []):
|
||||
#value = value[key]
|
||||
|
||||
result += str(value)
|
||||
else:
|
||||
result += part
|
||||
#print(result)
|
||||
return result
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from .object import buildObject
|
||||
from .path import buildPath
|
||||
|
||||
def buildRequest(definition, outputs):
|
||||
path = buildPath(definition.path, outputs)
|
||||
def buildRequest(definition, outputs, resolved):
|
||||
path = buildPath(definition.path, outputs, resolved)
|
||||
|
||||
request = {
|
||||
"method": definition.method,
|
||||
@@ -10,7 +10,7 @@ def buildRequest(definition, outputs):
|
||||
}
|
||||
|
||||
if hasattr(definition, "keys"):
|
||||
request["object"] = buildObject(definition.keys, outputs)
|
||||
request["object"] = buildObject(definition.keys, outputs, resolved)
|
||||
|
||||
if hasattr(definition, "headers"):
|
||||
headers = {}
|
||||
|
||||
Binary file not shown.
@@ -3,16 +3,23 @@ from core.runtime.savedata import loadSave, buildSave
|
||||
from core.runtime.outputs import buildOutput
|
||||
from core.runtime.logs import buildLog
|
||||
from core.runtime.runtimecontract import buildRuntimeAttr
|
||||
from core.runtime.resolver import resolveItem
|
||||
|
||||
def buildAction (action, outputs):
|
||||
|
||||
#resolved ={}
|
||||
def buildAction (action, outputs):#, resolved):
|
||||
|
||||
if hasattr(action, "loaddata"):
|
||||
outputs = loadSave(outputs, action)
|
||||
|
||||
response, outputs = executeRequest(action, outputs)
|
||||
resolved = {}
|
||||
if hasattr(action, "resolve"):
|
||||
resolved = resolveItem(action, outputs)
|
||||
|
||||
response, outputs = executeRequest(action, outputs, resolved)
|
||||
|
||||
#print("DEBUG:", outputs)
|
||||
|
||||
#print(resolved)
|
||||
|
||||
outputs, response = buildRuntimeAttr(action, outputs, response)
|
||||
|
||||
return outputs, response
|
||||
|
||||
Binary file not shown.
@@ -6,32 +6,39 @@ from core.runtime.outputs import buildOutput
|
||||
from core.runtime.managefailure import manageFailure
|
||||
from core.execution.action.action import buildAction
|
||||
from .skipstep import skipStep
|
||||
from core.runtime.resolver import resolveItem
|
||||
from core.runtime.resolver import resolveItem2
|
||||
from core.apirequest import executeRequest
|
||||
|
||||
def buildOperation(definition):
|
||||
actions = definition.actions
|
||||
#print("DEBUG", actions)
|
||||
responses = []
|
||||
outputs = {}
|
||||
#resolved = {}
|
||||
|
||||
for action in actions:
|
||||
#try:
|
||||
if hasattr(definition, "skipstep"):
|
||||
if skipStep(definition, action, outputs):
|
||||
continue
|
||||
|
||||
#if hasattr(definition, "resolve"):
|
||||
#resolved = {}
|
||||
#if hasattr(action, "resolve"):
|
||||
#print(outputs)
|
||||
#resolved = resolveItem(action, outputs)
|
||||
#print(resolved)
|
||||
if hasattr(action, "recursive"):
|
||||
outputs[action.recursive["target"]] = {}
|
||||
#outputs[action.recursive["target"]] = {}
|
||||
for item in outputs[action.recursive["source"]]:
|
||||
resolved = resolveItem(action, item)
|
||||
print("Resolved value:", resolved)
|
||||
outputs = resolveItem2(action, item, outputs)#, resolved)
|
||||
#print("Resolved value:", outputs)
|
||||
#outputs[action.recursive["target"]] = outputs[action.recursive["source"]][][action.recursive["target"]]
|
||||
#print(outputs[action.recursive["target"]])
|
||||
outputs[action.recursive["target"]] = item
|
||||
print(outputs[action.recursive["target"]])
|
||||
#print(outputs[action.recursive["target"]])
|
||||
#target = outputs[action.recursive["source"]["target"]
|
||||
outputs, response = buildAction(action, outputs)
|
||||
#print(item)
|
||||
outputs, response = buildAction(action, outputs)#, resolved)
|
||||
#print(outputs)
|
||||
#return outputs
|
||||
else:
|
||||
outputs, response = buildAction(action, outputs)
|
||||
@@ -39,5 +46,5 @@ def buildOperation(definition):
|
||||
|
||||
#except Exception as error:
|
||||
#outputs = manageFailure(error, action, outputs)
|
||||
print(outputs["message"])
|
||||
#print(outputs["message"])
|
||||
return outputs
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,8 +2,9 @@ def resolveItem(action, item):
|
||||
resolved = {}
|
||||
label = action.resolve["label"]
|
||||
targetkeys = action.resolve["targetkeys"]
|
||||
|
||||
#print(item)
|
||||
target = item
|
||||
|
||||
for key in targetkeys:
|
||||
target = target[key]
|
||||
|
||||
@@ -20,3 +21,29 @@ def resolveItem(action, item):
|
||||
#print(resolved[label])
|
||||
|
||||
return resolved
|
||||
|
||||
def resolveItem2(action, item, outputs):
|
||||
#resolved = {}
|
||||
label = action.resolve["label"]
|
||||
targetkeys = action.resolve["targetkeys"]
|
||||
#print(item)
|
||||
target = item
|
||||
|
||||
for key in targetkeys:
|
||||
target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
|
||||
#for label, keys in action.resolve.items():
|
||||
#target = item
|
||||
|
||||
#print(target)
|
||||
#for key in keys:
|
||||
#target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
#print(resolved[label])
|
||||
|
||||
outputs[label] = target
|
||||
#print("Resolver DEBUG", target, outputs[label])
|
||||
return outputs
|
||||
|
||||
@@ -66,8 +66,41 @@ def buildSelect2(action, outputs):
|
||||
#select_data.append(item)
|
||||
|
||||
def buildSelect3(action, outputs):
|
||||
#print(outputs)
|
||||
try:
|
||||
select_data = []
|
||||
|
||||
target = outputs[action.select["source"]]
|
||||
includekey = action.select["include"]["key"]
|
||||
includevalue = action.select["include"]["value"]
|
||||
excludekey = action.select["exclude"]["key"]
|
||||
excludevalue = action.select["exclude"]["value"]
|
||||
|
||||
|
||||
for item in target:
|
||||
include_match = True
|
||||
exclude_match = True
|
||||
|
||||
if includekey:
|
||||
include_match = item[includekey] == includevalue
|
||||
|
||||
if excludekey:
|
||||
exclude_match = item[excludekey] != excludevalue
|
||||
|
||||
if include_match and exclude_match:
|
||||
select_data.append(item)
|
||||
|
||||
|
||||
outputs[action.select["source"]] = select_data
|
||||
print(select_data)
|
||||
return select_data, action, outputs
|
||||
except (KeyError, TypeError):
|
||||
return select_data, action, outputs
|
||||
|
||||
def buildSelect4(action, outputs):
|
||||
#print(outputs)
|
||||
select_data = []
|
||||
|
||||
target = outputs[action.select["source"]]
|
||||
#selectmethod = action.select["selectmethod"]
|
||||
includekey = action.select["include"]["key"]
|
||||
|
||||
Reference in New Issue
Block a user