From 016b0ed48f15b8b92b2e15b997a296ce1fe7a7a1 Mon Sep 17 00:00:00 2001 From: Worros Date: Sat, 4 Sep 2010 20:06:24 +0800 Subject: [PATCH] Tourney Graphing and Summary import update It now gets through my 200 tourney torture test. --- pyfpdb/GuiTourneyGraphViewer.py | 2 +- pyfpdb/ImapFetcher.py | 3 ++- pyfpdb/PokerStarsSummary.py | 38 ++++++++++++++++++--------------- pyfpdb/SQL.py | 2 +- pyfpdb/TourneySummary.py | 4 ++-- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/pyfpdb/GuiTourneyGraphViewer.py b/pyfpdb/GuiTourneyGraphViewer.py index e213e1f4..e8a3d41e 100644 --- a/pyfpdb/GuiTourneyGraphViewer.py +++ b/pyfpdb/GuiTourneyGraphViewer.py @@ -268,7 +268,7 @@ class GuiTourneyGraphViewer (threading.Thread): if len(winnings) == 0: return None - green = map(lambda x:float(x[0]), winnings) + green = map(lambda x:float(x[1]), winnings) #blue = map(lambda x: float(x[1]) if x[2] == True else 0.0, winnings) #red = map(lambda x: float(x[1]) if x[2] == False else 0.0, winnings) greenline = cumsum(green) diff --git a/pyfpdb/ImapFetcher.py b/pyfpdb/ImapFetcher.py index 01d75a54..b3b5785f 100755 --- a/pyfpdb/ImapFetcher.py +++ b/pyfpdb/ImapFetcher.py @@ -119,6 +119,7 @@ def runFake(db, config, infile): for summary in summaryList[1:]: result = PokerStarsSummary.PokerStarsSummary(db=db, config=config, siteName=u"PokerStars", summaryText=summary, builtFrom = "file") + print "DEBUG: Processed: %s: tournNo: %s" % (result.tourneyId, result.tourNo) def splitPokerStarsSummaries(emailText): splitSummaries=emailText.split("\nPokerStars Tournament #")[1:] @@ -136,7 +137,7 @@ def main(argv=None): sys.exit(0) # These options should really come from the OptionsParser - config = Configuration.Config(file = "HUD_config.test.xml") + config = Configuration.Config() db = Database.Database(config) sql = SQL.Sql(db_server = 'sqlite') settings = {} diff --git a/pyfpdb/PokerStarsSummary.py b/pyfpdb/PokerStarsSummary.py index 732e8a85..36ceae48 100644 --- a/pyfpdb/PokerStarsSummary.py +++ b/pyfpdb/PokerStarsSummary.py @@ -65,12 +65,15 @@ class PokerStarsSummary(TourneySummary): \#(?P[0-9]+),\s (?PNo\sLimit|Limit|LIMIT|Pot\sLimit)\s (?PHold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s - Buy-In:\s\$(?P[.0-9]+)\/\$(?P[.0-9]+)\s + (?P[ a-zA-Z]+\s)? + (Buy-In:\s\$(?P[.0-9]+)(\/\$(?P[.0-9]+))?\s)? (?P[0-9]+)\splayers\s - Total\sPrize\sPool:\s\$?(?P[.0-9]+)\s + (\$?(?P[.\d]+)\sadded\sto\sthe\sprize\spool\sby\sPokerStars\.com\s)? + (Total\sPrize\sPool:\s\$?(?P[.0-9]+)\s)? + (Target\sTournament\s.*)? Tournament\sstarted\s-\s (?P[0-9]{4})\/(?P[0-9]{2})\/(?P[0-9]{2})[\-\s]+(?P[0-9]+):(?P[0-9]+):(?P[0-9]+)\s?\(?(?P[A-Z]+)\)\s - """ % substitutions ,re.VERBOSE|re.MULTILINE) + """ % substitutions ,re.VERBOSE|re.MULTILINE|re.DOTALL) re_Currency = re.compile(u"""(?P[%(LS)s]|FPP)""" % substitutions) @@ -190,22 +193,23 @@ class PokerStarsSummary(TourneySummary): #end def parseSummary def parseSummaryFile(self): - print self.summaryText m = self.re_TourneyInfo.search(self.summaryText) - if m: - print "DEBUG: m.groupdict(): %s" % m.groupdict() - else: - tmp = self.summaryText[0:100] + if m == None: + tmp = self.summaryText[0:200] log.error(_("parseSummaryFile: Unable to recognise Tourney Info: '%s'") % tmp) log.error(_("parseSummaryFile: Raising FpdbParseError")) raise FpdbParseError(_("Unable to recognise Tourney Info: '%s'") % tmp) + #print "DEBUG: m.groupdict(): %s" % m.groupdict() + mg = m.groupdict() if 'TOURNO' in mg: self.tourNo = mg['TOURNO'] if 'LIMIT' in mg: self.gametype['limitType'] = self.limits[mg['LIMIT']] if 'GAME' in mg: self.gametype['category'] = self.games[mg['GAME']][1] - if 'BUYIN' in mg: self.buyin = int(100*Decimal(mg['BUYIN'])) - if 'FEE' in mg: self.fee = int(100*Decimal(mg['FEE'])) + if mg['BUYIN'] != None: + self.buyin = int(100*Decimal(mg['BUYIN'])) + if mg['FEE'] != None: + self.fee = int(100*Decimal(mg['FEE'])) if 'PRIZEPOOL' in mg: self.prizepool = mg['PRIZEPOOL'] if 'ENTRIES' in mg: self.entries = mg['ENTRIES'] @@ -217,12 +221,11 @@ class PokerStarsSummary(TourneySummary): m = self.re_Currency.search(self.summaryText) - if m: - print "DEBUG: m.groupdict(): %s" % m.groupdict() - else: + if m == None: log.error(_("parseSummaryFile: Unable to locate currency")) log.error(_("parseSummaryFile: Raising FpdbParseError")) raise FpdbParseError(_("Unable to locate currency")) + #print "DEBUG: m.groupdict(): %s" % m.groupdict() mg = m.groupdict() if mg['CURRENCY'] == "$": self.currency = "USD" @@ -232,7 +235,7 @@ class PokerStarsSummary(TourneySummary): m = self.re_Player.finditer(self.summaryText) for a in m: mg = a.groupdict() - print "DEBUG: a.groupdict(): %s" % mg + #print "DEBUG: a.groupdict(): %s" % mg name = mg['NAME'] rank = mg['RANK'] winnings = 0 @@ -240,15 +243,16 @@ class PokerStarsSummary(TourneySummary): if 'WINNINGS' in mg and mg['WINNINGS'] != None: winnings = int(100*Decimal(mg['WINNINGS'])) - if 'STILLPLAYING' in mg: + if 'STILLPLAYING' in mg and mg['STILLPLAYING'] != None: #print "stillplaying" rank=None winnings=None #TODO: currency, ko/addon/rebuy count -> need examples! + #print "DEBUG: addPlayer(%s, %s, %s, %s, None, None, None)" %(rank, name, winnings, self.currency) + #print "DEBUG: self.buyin: %s self.fee %s" %(self.buyin, self.fee) self.addPlayer(rank, name, winnings, self.currency, None, None, None) - print self - sys.exit(0) + #print self #end class PokerStarsSummary diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 87857908..fff3f07e 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -3050,7 +3050,7 @@ class Sql: # Tourney Results query #################################### self.query['tourneyResults'] = """ - SELECT (tp.winnings - tt.buyIn - tt.fee) as profit, tp.koCount, tp.rebuyCount, tp.addOnCount, tt.buyIn, tt.fee + SELECT tp.tourneyId, (tp.winnings - tt.buyIn - tt.fee) as profit, tp.koCount, tp.rebuyCount, tp.addOnCount, tt.buyIn, tt.fee, t.siteTourneyNo FROM TourneysPlayers tp INNER JOIN Players pl ON (pl.id = tp.playerId) INNER JOIN Tourneys t ON (t.id = tp.tourneyId) diff --git a/pyfpdb/TourneySummary.py b/pyfpdb/TourneySummary.py index 8fe7ceaa..f78d96de 100644 --- a/pyfpdb/TourneySummary.py +++ b/pyfpdb/TourneySummary.py @@ -74,8 +74,8 @@ class TourneySummary(object): self.endTime = None self.tourNo = None self.currency = None - self.buyin = None - self.fee = None + self.buyin = 0 + self.fee = 0 self.hero = None self.maxseats = 0 self.entries = 0