GTI: Cleanup

Remove a series of debug messages

Add some code to remove heading or trailing characters after the split
This commit is contained in:
Worros 2010-11-11 14:59:18 +08:00
parent e8155123b2
commit 17bd4f3954

View File

@ -158,15 +158,12 @@ class SummaryImporter:
self.updatedtime = {} self.updatedtime = {}
def addImportFile(self, filename, site = "default", tsc = "passthrough"): def addImportFile(self, filename, site = "default", tsc = "passthrough"):
print "DEBUG: addImportFile"
if filename in self.filelist or not os.path.exists(filename): if filename in self.filelist or not os.path.exists(filename):
print "DEBUG: addImportFile: File exists, or path non-existent" print "DEBUG: addImportFile: File exists, or path non-existent"
return return
self.filelist[filename] = [site] + [tsc] 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"): def addImportDirectory(self,dir,monitor=False, site="default", tsc="passthrough"):
print "DEBUG: addImportDirectory"
if os.path.isdir(dir): if os.path.isdir(dir):
if monitor == True: if monitor == True:
self.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)) log.warning(_("Attempted to add non-directory '%s' as an import directory") % str(dir))
def addImportFileOrDir(self, inputPath, site = "PokerStars"): def addImportFileOrDir(self, inputPath, site = "PokerStars"):
print "DEBUG: addImportFileOrDir"
tsc = self.config.hhcs[site].summaryImporter tsc = self.config.hhcs[site].summaryImporter
if os.path.isdir(inputPath): if os.path.isdir(inputPath):
for subdir in os.walk(inputPath): for subdir in os.walk(inputPath):
@ -213,6 +209,17 @@ class SummaryImporter:
if callable(obj): if callable(obj):
foabs = self.readFile(obj, filename) foabs = self.readFile(obj, filename)
summaryTexts = re.split(obj.re_SplitTourneys, foabs) 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)) print "Found %s summaries" %(len(summaryTexts))
errors = 0 errors = 0
imported = 0 imported = 0
@ -236,7 +243,6 @@ class SummaryImporter:
tsc.codepage tsc.codepage
for kodec in codepage: for kodec in codepage:
print "DEBUG: TSC.readFile: trying codepage '%s'" % kodec
try: try:
in_fh = codecs.open(filename, 'r', kodec) in_fh = codecs.open(filename, 'r', kodec)
whole_file = in_fh.read() whole_file = in_fh.read()