From 89bb0e453e182eea9efd58f252635df70d3dd57a Mon Sep 17 00:00:00 2001 From: nanotube Date: Tue, 27 Sep 2005 01:05:53 +0000 Subject: [PATCH] compile the filter regexp for efficiency --- logwriter.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/logwriter.py b/logwriter.py index d98808a..f90f0bb 100644 --- a/logwriter.py +++ b/logwriter.py @@ -21,6 +21,8 @@ class LogWriter: else: print "OSError:", detail + self.filter = re.compile(r"[\\\/\:\*\?\"\<\>\|]+") #regexp filter for the non-allowed characters in windows filenames. + self.writeTarget = "" if self.options.systemLog != None: self.systemlog = open(os.path.join(os.path.normpath(self.options.dirName), self.options.systemLog), 'a') @@ -86,12 +88,9 @@ class LogWriter: self.PrintDebug("writing to: " + self.writeTarget + "\n") return + subDirName = self.filter.sub(r'__',self.processName) #our subdirname is the full path of the process owning the hwnd, filtered. - filter=r"[\\\/\:\*\?\"\<\>\|]+" #regexp filter for the non-allowed characters in windows filenames. - - subDirName = re.sub(filter,r'__',self.processName) #our subdirname is the full path of the process owning the hwnd, filtered. - - WindowName = re.sub(filter,r'__',str(event.WindowName)) + WindowName = self.filter.sub(r'__',str(event.WindowName)) try: os.makedirs(os.path.join(self.options.dirName, subDirName), 0777) -- 2.45.1