Refined apply conditions
This commit is contained in:
Binary file not shown.
@@ -1,26 +1,32 @@
|
||||
def applyConditions(definition, outputs):
|
||||
def applyConditions(definition, dictionary):
|
||||
if hasattr(definition, "filters"):
|
||||
print("DEBUG DICTIONARY PASS")
|
||||
print(dictionary)
|
||||
for filter in definition.filters:
|
||||
print("DEBUG applyConditons filter item consumption")
|
||||
print(outputs["event"])
|
||||
|
||||
item = outputs["event"]
|
||||
|
||||
#current_value = item[filter["filterkey"]]
|
||||
|
||||
if filter["operator"] == ">=":
|
||||
if item[filter["filterkey"]] >= filter["filtervalue"]:
|
||||
print("Applying filters")
|
||||
if dictionary.get(filter["filterkey"]) >= filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "<=":
|
||||
if dictionary.get(filter["filterkey"]) <= filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "==":
|
||||
if item[filter["filterkey"]] == filter["filtervalue"]:
|
||||
print("Applying filters")
|
||||
if dictionary.get(filter["filterkey"]) == filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "!=":
|
||||
if dictionary.get(filter["filterkey"]) != filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "in":
|
||||
if filter["filtervalue"] in outputs[filter["filterkey"]]:
|
||||
print("Applying filters")
|
||||
if filter["filtervalue"] in dictionary:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
return False
|
||||
Binary file not shown.
@@ -25,14 +25,14 @@ def buildListener(listener, self):
|
||||
|
||||
|
||||
for item in outputs[listener.recursive["source"]]:
|
||||
outputs[listener.recursive["label"]] = item
|
||||
#outputs[listener.recursive["label"]] = item
|
||||
|
||||
print("DEBUG item selection")
|
||||
#print("DEBUG item selection")
|
||||
#print(listener.recursive["label"])
|
||||
print(item)
|
||||
print(outputs["event"])
|
||||
#print(item)
|
||||
#print(outputs["event"])
|
||||
|
||||
if applyConditions(listener, outputs):
|
||||
if applyConditions(listener, item):
|
||||
continue
|
||||
|
||||
#if "state_key" in event:
|
||||
|
||||
Reference in New Issue
Block a user