From 87fbd56091b845307ca87beb8b1b3e6e80516248 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sun, 11 Jul 2010 01:55:15 +0200 Subject: [PATCH] imports still playing tourney's TP, but not winnings of finishers --- pyfpdb/Database.py | 11 ++++++++--- pyfpdb/PokerStarsSummary.py | 19 +++++++++++++------ pyfpdb/TourneySummary.py | 11 ++++++++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 659b375c..c4c13dbe 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2043,9 +2043,14 @@ class Database: (hand.tourneyId, playerId, None, None, None, None, None, None)) elif source=="TS": #print "all values: tourneyId",hand.tourneyId, "playerId",playerId, "rank",hand.ranks[player], "winnings",hand.winnings[player], "winCurr",hand.winningsCurrency[player], hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player] - cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']), - (hand.tourneyId, playerId, int(hand.ranks[player]), int(hand.winnings[player]), hand.winningsCurrency[player], - hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player])) + if hand.ranks[player]: + cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']), + (hand.tourneyId, playerId, int(hand.ranks[player]), int(hand.winnings[player]), hand.winningsCurrency[player], + hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player])) + else: + cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']), + (hand.tourneyId, playerId, None, None, None, + hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player])) tourneysPlayersIds.append(self.get_last_insert_id(cursor)) return tourneysPlayersIds #end def createOrUpdateTourneysPlayers diff --git a/pyfpdb/PokerStarsSummary.py b/pyfpdb/PokerStarsSummary.py index ba727bd7..a71baa40 100644 --- a/pyfpdb/PokerStarsSummary.py +++ b/pyfpdb/PokerStarsSummary.py @@ -28,7 +28,7 @@ class PokerStarsSummary(TourneySummary): re_TourNo = re.compile("\#[0-9]+,") re_Entries = re.compile("[0-9]+") re_Prizepool = re.compile("\$[0-9]+\.[0-9]+") - re_Player = re.compile("""(?P[0-9]+):\s(?P.*)\s\(.*\),(\s\$(?P[0-9]+\.[0-9]+)\s\()?""") + re_Player = re.compile("""(?P[0-9]+):\s(?P.*)\s\(.*\),(\s\$(?P[0-9]+\.[0-9]+)\s\()?(\s(?Pstill\splaying))?""") re_BuyInFee = re.compile("(?P[0-9]+\.[0-9]+).*(?P[0-9]+\.[0-9]+)") re_FPP = re.compile("(?P[0-9]+)\sFPP") #note: the dollar and cent in the below line are currency-agnostic @@ -40,7 +40,7 @@ class PokerStarsSummary(TourneySummary): lines=self.summaryText.splitlines() self.tourNo = self.re_TourNo.findall(lines[0])[0][1:-1] #ignore game and limit type as thats not recorded - print "tourNo:",self.tourNo + #print "tourNo:",self.tourNo if lines[1].find("$")!=-1: #TODO: move this into a method and call that from PokerStarsToFpdb.py:269 if hand.buyinCurrency=="USD" etc. self.currency="USD" @@ -66,7 +66,7 @@ class PokerStarsSummary(TourneySummary): self.entries = self.re_Entries.findall(lines[currentLine])[0] currentLine+=1 #note that I chose to make the code keep state (the current line number) #as that means it'll fail rather than silently skip potentially valuable information - print "after entries lines[currentLine]", lines[currentLine] + #print "after entries lines[currentLine]", lines[currentLine] result=self.re_Added.search(lines[currentLine]) if result: @@ -75,11 +75,10 @@ class PokerStarsSummary(TourneySummary): self.addedCurrency=result['CURRENCY'] #print "TODO: implement added:",self.added,self.addedCurrency currentLine+=1 - print "after added/entries lines[currentLine]", lines[currentLine] + #print "after added/entries lines[currentLine]", lines[currentLine] result=self.re_Prizepool.findall(lines[currentLine]) if result: - print "prizepool result", result self.prizepool = result[0] self.prizepool = self.prizepool[1:-3]+self.prizepool[-2:] currentLine+=1 @@ -94,12 +93,14 @@ class PokerStarsSummary(TourneySummary): result=self.re_DateTime.search(lines[currentLine]) if result: - print "endtime result", result result=result.groupdict() datetimestr = "%s/%s/%s %s:%s:%s" % (result['Y'], result['M'],result['D'],result['H'],result['MIN'],result['S']) self.endTime= datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET" currentLine+=1 + if lines[currentLine].find("Tournament is still in progress")!=-1: + currentLine+=1 + for i in range(currentLine,len(lines)-2): #lines with rank and winnings info if lines[i].find(":")==-1: break @@ -108,11 +109,17 @@ class PokerStarsSummary(TourneySummary): rank=result['RANK'] name=result['NAME'] winnings=result['WINNINGS'] + if winnings: winnings=int(100*Decimal(winnings)) else: winnings=0 + if result['STILLPLAYING']: + #print "stillplaying" + rank=None + winnings=None + self.addPlayer(rank, name, winnings, self.currency, None, None, None)#TODO: currency, ko/addon/rebuy count -> need examples! #end def parseSummary #end class PokerStarsSummary diff --git a/pyfpdb/TourneySummary.py b/pyfpdb/TourneySummary.py index f7632ea3..c57a9f0d 100644 --- a/pyfpdb/TourneySummary.py +++ b/pyfpdb/TourneySummary.py @@ -230,9 +230,14 @@ winnings (decimal) the money the player ended the tourney with (can be 0, or """ log.debug("addPlayer: rank:%s - name : '%s' - Winnings (%s)" % (rank, name, winnings)) self.players.append(name) - self.ranks.update( { name : Decimal(rank) } ) - self.winnings.update( { name : Decimal(winnings) } ) - self.winningsCurrency.update( { name : winningsCurrency } ) + if rank: + self.ranks.update( { name : Decimal(rank) } ) + self.winnings.update( { name : Decimal(winnings) } ) + self.winningsCurrency.update( { name : winningsCurrency } ) + else: + self.ranks.update( { name : None } ) + self.winnings.update( { name : None } ) + self.winningsCurrency.update( { name : None } ) if rebuyCount: self.rebuyCounts.update( {name: Decimal(rebuyCount) } ) else: