mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-07 15:33:43 +00:00
reduce entries in globals.py
only entries for use in more than one .py-file have to stay here...
This commit is contained in:
parent
e26fc45313
commit
02efb9552a
4 changed files with 45 additions and 37 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Functions for the RegEX filter
|
||||
|
|
@ -10,22 +10,25 @@ Functions for the RegEX filter
|
|||
"""
|
||||
|
||||
import logging # Global logger
|
||||
|
||||
import re #Regex for Filter Check
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
from includes import converter # converter functions
|
||||
|
||||
|
||||
# local variables
|
||||
filterList = []
|
||||
|
||||
|
||||
def loadFilters():
|
||||
"""
|
||||
load all filters from the config.ini into globals.filterList
|
||||
load all filters from the config.ini into filterList
|
||||
|
||||
@requires: Configuration has to be set in the config.ini
|
||||
|
||||
@return: nothing
|
||||
"""
|
||||
global filterList
|
||||
try:
|
||||
logging.debug("loading filters")
|
||||
# For each entry in config.ini [Filters] section
|
||||
|
|
@ -37,15 +40,15 @@ def loadFilters():
|
|||
if not filter[3] == "*":
|
||||
filter[3] = converter.freqToHz(filter[3])
|
||||
|
||||
# insert splitet data into globals.filterList
|
||||
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": filter[3], "regex": filter[4]})
|
||||
# insert splitet data into filterList
|
||||
filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": filter[3], "regex": filter[4]})
|
||||
except:
|
||||
logging.error("cannot read config file")
|
||||
logging.debug("cannot read config file", exc_info=True)
|
||||
return
|
||||
|
||||
|
||||
def checkFilters(typ,data,plugin,freq):
|
||||
def checkFilters(typ, data, plugin, freq):
|
||||
"""
|
||||
Check the Typ/Plugin combination with the RegEX filter
|
||||
If no filter for the combination is found, function returns True.
|
||||
|
|
@ -63,12 +66,13 @@ def checkFilters(typ,data,plugin,freq):
|
|||
|
||||
@return: nothing
|
||||
"""
|
||||
global filterList
|
||||
try:
|
||||
logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq)
|
||||
|
||||
foundFilter = False
|
||||
# go to all filter in globals.filterList
|
||||
for i in globals.filterList:
|
||||
# go to all filter in filterList
|
||||
for i in filterList:
|
||||
# if typ/plugin/freq combination is found
|
||||
if i["typ"] == typ and (i["plugin"] == plugin or i['plugin'] == "*") and (i["freq"] == freq or i['freq'] == "*"):
|
||||
foundFilter = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue