48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
def buildSelect(action, outputs):
|
|
#***THIS IS THE CANONICAL BUILD***
|
|
select_log = False
|
|
|
|
select_data = []
|
|
|
|
if hasattr(action, "select"):
|
|
#outputs[f"{action.alias}_select"] = []
|
|
try:
|
|
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
|
|
outputs[f"{action.alias}_select"] = select_data
|
|
|
|
#print(select_data)
|
|
|
|
if select_log:
|
|
if select_data is None:
|
|
print(f"No data selected during {action.name}")
|
|
|
|
return action, outputs
|
|
except KeyError as error:
|
|
print(f"Error in selection of {error} during {action.name}")
|
|
|
|
except TypeError as error:
|
|
print(f"TypeError during select: {error} during {action.name}")
|
|
|
|
return action, outputs
|
|
|