From 17bd4f39548354d5de56be9e68dbe2b24b430b7d Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 11 Nov 2010 14:59:18 +0800 Subject: [PATCH] GTI: Cleanup Remove a series of debug messages Add some code to remove heading or trailing characters after the split --- pyfpdb/GuiTourneyImport.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pyfpdb/GuiTourneyImport.py b/pyfpdb/GuiTourneyImport.py index bb2731b3..d8fe6ec5 100755 --- a/pyfpdb/GuiTourneyImport.py +++ b/pyfpdb/GuiTourneyImport.py @@ -158,15 +158,12 @@ class SummaryImporter: self.updatedtime = {} def addImportFile(self, filename, site = "default", tsc = "passthrough"): - print "DEBUG: addImportFile" if filename in self.filelist or not os.path.exists(filename): print "DEBUG: addImportFile: File exists, or path non-existent" return self.filelist[filename] = [site] + [tsc] - print "DEBUG: addImportFile: self.filelist[%s]: %s" %(filename, self.filelist[filename]) def addImportDirectory(self,dir,monitor=False, site="default", tsc="passthrough"): - print "DEBUG: addImportDirectory" if os.path.isdir(dir): if monitor == True: self.monitor = True @@ -178,7 +175,6 @@ class SummaryImporter: log.warning(_("Attempted to add non-directory '%s' as an import directory") % str(dir)) def addImportFileOrDir(self, inputPath, site = "PokerStars"): - print "DEBUG: addImportFileOrDir" tsc = self.config.hhcs[site].summaryImporter if os.path.isdir(inputPath): for subdir in os.walk(inputPath): @@ -213,6 +209,17 @@ class SummaryImporter: if callable(obj): foabs = self.readFile(obj, filename) summaryTexts = re.split(obj.re_SplitTourneys, foabs) + + # The summary files tend to have a header or footer + # Remove the first and/or last entry if it has < 100 characters + if len(summaryTexts[-1]) <= 100: + summaryTexts.pop() + log.warn(_("TourneyImport: Removing text < 100 characters from end of file")) + + if len(summaryTexts[0]) <= 130: + del summaryTexts[0] + log.warn(_("TourneyImport: Removing text < 100 characters from start of file")) + print "Found %s summaries" %(len(summaryTexts)) errors = 0 imported = 0 @@ -236,7 +243,6 @@ class SummaryImporter: tsc.codepage for kodec in codepage: - print "DEBUG: TSC.readFile: trying codepage '%s'" % kodec try: in_fh = codecs.open(filename, 'r', kodec) whole_file = in_fh.read()