Working list selection filter
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
def buildPath(path, outputs):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
|
||||
result = ""
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
value = outputs[part["output"]]
|
||||
|
||||
for key in part.get("keys", []):
|
||||
value = value[key]
|
||||
|
||||
result += str(value)
|
||||
else:
|
||||
result += part
|
||||
|
||||
return result
|
||||
@@ -1,9 +1,12 @@
|
||||
from .object import buildObject
|
||||
from .path import buildPath
|
||||
|
||||
def buildRequest(definition, outputs):
|
||||
path = buildPath(definition.path, outputs)
|
||||
|
||||
request = {
|
||||
"method": definition.method,
|
||||
"path": definition.path,
|
||||
"path": path,
|
||||
}
|
||||
|
||||
if hasattr(definition, "keys"):
|
||||
@@ -25,4 +28,6 @@ def buildRequest(definition, outputs):
|
||||
|
||||
request["headers"] = headers
|
||||
|
||||
print(path)
|
||||
|
||||
return request, outputs
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#from . import outputs
|
||||
#from . import managefailure
|
||||
#from . import savedata
|
||||
from .select import buildSelect, buildSelect2
|
||||
from .outputs import buildOutput
|
||||
from .savedata import buildSave, loadSave
|
||||
from .logs import buildLog
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
|
||||
def buildLog (action, outputs):
|
||||
def buildLog (action, outputs, response):
|
||||
#if response.status_code == 200:
|
||||
#print(f"{action.name} successful")
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
def buildOutput(response, action, outputs):
|
||||
|
||||
def buildOutput(response, action, outputs):#, select_data):
|
||||
#if select_data != "not applied":
|
||||
#response_data = select_data
|
||||
#else:
|
||||
#response_data = response.json()
|
||||
|
||||
response_data = response.json()
|
||||
response_objects = [response_data]
|
||||
|
||||
@@ -17,3 +21,5 @@ def buildOutput(response, action, outputs):
|
||||
|
||||
|
||||
return outputs
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
from core.runtime import buildOutput, buildSave, buildLog
|
||||
from core.runtime import buildSelect, buildSelect2, buildOutput, buildSave, buildLog
|
||||
|
||||
#select_data = {}
|
||||
|
||||
def buildRuntimeAttr(action, outputs, response):
|
||||
#select_data = {}
|
||||
#response_data = response.json()
|
||||
|
||||
#if hasattr(action, "select"):
|
||||
#select_data, action, outputs = buildSelect(response, action, outputs)
|
||||
#else:
|
||||
#select_data = "not applied"
|
||||
#print("BEFORE buildOutput:", type(outputs))
|
||||
if hasattr(action, "outputs"):
|
||||
outputs = buildOutput(response, action, outputs)
|
||||
|
||||
outputs = buildOutput(response, action, outputs)#, select_data)
|
||||
|
||||
if hasattr(action, "select"):
|
||||
select_data, action, outputs = buildSelect2(action, outputs)
|
||||
#print("AFTER buildOutput:", type(outputs))
|
||||
#print("DEBUG buildSave")
|
||||
#print("outputs type:", type(outputs))
|
||||
@@ -15,7 +26,7 @@ def buildRuntimeAttr(action, outputs, response):
|
||||
buildSave(outputs, action)
|
||||
|
||||
if hasattr(action, "prints"):
|
||||
buildLog(action, outputs)
|
||||
buildLog(action, outputs, response)
|
||||
|
||||
#if hasattr(action, "conversion"):
|
||||
#conversions = action.conversion.items()
|
||||
@@ -26,5 +37,5 @@ def buildRuntimeAttr(action, outputs, response):
|
||||
|
||||
if action.showstatus is True and response.status_code == 200:
|
||||
print(f"{action.name} successful")
|
||||
|
||||
|
||||
return outputs, response
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
def buildSelect(response, action, outputs):
|
||||
#if hasattr(action, "select"):
|
||||
|
||||
response_data = response.json()
|
||||
#selection = action.select
|
||||
#print(response_data)
|
||||
|
||||
select_data ={}
|
||||
for item, index in action.select.items():
|
||||
select_data[item] = response_data[item][index]
|
||||
|
||||
print(select_data)
|
||||
|
||||
#if select_data == None:
|
||||
# selection = "not applied"
|
||||
#else:
|
||||
selection = select_data
|
||||
|
||||
return selection, action, outputs
|
||||
|
||||
def buildSelect2(action, outputs):
|
||||
#print(outputs)
|
||||
select_data = []
|
||||
target = outputs[action.select["source"]]
|
||||
selectmethod = action.select["selectmethod"]
|
||||
targetkey = action.select["key"]
|
||||
targetvalue = action.select["value"]
|
||||
#for item in target:
|
||||
for item in target:
|
||||
#print (item)
|
||||
for key, value in item.items():
|
||||
if selectmethod == "exclude":
|
||||
if targetkey == key and item[key] != targetvalue:
|
||||
select_data.append(item)
|
||||
#print(item)
|
||||
if selectmethod == "include":
|
||||
if targetkey == key and item[key] == targetvalue:
|
||||
select_data.append(item)
|
||||
#print(item)
|
||||
print(select_data)
|
||||
return select_data, action, outputs
|
||||
#for item in outputs[output_name]:
|
||||
#for key, value in action.select.include.items():
|
||||
#if key in item and item[key] == value:
|
||||
#select_data.append(item)
|
||||
Reference in New Issue
Block a user