mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-23 00:30:14 +01:00
regex filter - set dataField to check
This commit is contained in:
parent
fa328676e8
commit
3370b4387d
|
|
@ -43,10 +43,14 @@ filter_range_end = 9999999
|
|||
[Filters]
|
||||
#RegEX Filter Configuration
|
||||
#No Filter for a Typ/Plugin Combination = all Data pass
|
||||
#INDIVIDUAL_NAME = TYP;PLUGIN;REGEX
|
||||
#INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;REGEX
|
||||
TYP = the Data Typ (FMS|ZVEI|POC)
|
||||
DATAFIELD = the field of the Data Array. See interface.txt for names.
|
||||
PLUGIN = the name of the Plugin to call with this Filter.
|
||||
REGEX = the RegEX
|
||||
|
||||
#only ZVEI to template with 25###
|
||||
#testfilter = ZVEI;template;25[0-9F]{3}
|
||||
#testfilter = ZVEI;zvei;template;25[0-9F]{3}
|
||||
|
||||
|
||||
[Plugins]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def getFilters():
|
|||
for key,val in globals.config.items("Filters"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
filter = val.split(";")
|
||||
globals.filterList.append({"name": key, "typ": filter[0], "plugin": filter[1], "regex": filter[2]})
|
||||
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "regex": filter[3]})
|
||||
except:
|
||||
logging.exception("cannot read config file")
|
||||
|
||||
|
|
@ -23,17 +23,12 @@ def checkFilters(data,typ,plugin):
|
|||
try:
|
||||
logging.debug("search Filter for %s to %s", typ, plugin)
|
||||
|
||||
#extract the correct data for filtering
|
||||
if typ == "FMS": data = data["fms"]
|
||||
if typ == "ZVEI": data = data["zvei"]
|
||||
if typ == "POC": data = data["ric"]
|
||||
|
||||
foundFilter = False
|
||||
for i in globals.filterList:
|
||||
if i["typ"] == typ and i["plugin"] == plugin:
|
||||
foundFilter = True
|
||||
logging.debug("found Filter: %s = %s", i["name"], i["regex"])
|
||||
if re.search(i["regex"], data):
|
||||
if re.search(i["regex"], data[i["dataField"]]):
|
||||
logging.debug("Filter passed: %s", i["name"])
|
||||
return True
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue