35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
def buildSelect(action, outputs):
|
|
#***THIS IS THE CANONICAL BUILD***
|
|
select_data = []
|
|
|
|
if hasattr(action, "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
|
|
#print(select_data)
|
|
|
|
return select_data, action, outputs
|
|
except: (KeyError, TypeError)
|
|
#select_data = ["no selection"]
|
|
return select_data, action, outputs
|
|
|