46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
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)
|