minor optimization

This commit is contained in:
Miroslav Stampar 2011-11-22 12:40:12 +00:00
parent 2e10de8921
commit 501fd85fa1

View File

@ -45,7 +45,11 @@ class FingerprintHandler(ContentHandler):
def startElement(self, name, attrs):
if name == "regexp":
self.__regexp = sanitizeStr(attrs.get("value"))
_ = re.match("\A[A-Za-z0-9]+", self.__regexp) # minor trick avoiding compiling of large amount of regexes
if _ and _.group(0).lower() in self.__banner.lower() or not _:
self.__match = re.search(self.__regexp, self.__banner, re.I | re.M)
else:
self.__match = None
if name == "info" and self.__match:
self.__feedInfo("type", attrs.get("type"))