From 201b3a5b6c41a902e90a86a4af4cad3cadf83b8b Mon Sep 17 00:00:00 2001 From: steffen123 Date: Thu, 8 Jul 2010 21:41:27 +0200 Subject: [PATCH] PS Summary now parses start/endTime. fixes MySQL support also removed some but not all the new prints --- pyfpdb/Database.py | 3 +-- pyfpdb/PokerStarsSummary.py | 12 +++++++++++- pyfpdb/TourneySummary.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 9f5735a1..c60a8023 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -805,7 +805,7 @@ class Database: def get_player_id(self, config, siteName, playerName): c = self.connection.cursor() playerNameUtf = Charset.to_utf8(playerName) - print "db.get_player_id siteName",siteName,"playerName",playerName + #print "db.get_player_id siteName",siteName,"playerName",playerName c.execute(self.sql.query['get_player_id'], (playerNameUtf, siteName)) row = c.fetchone() if row: @@ -1998,7 +1998,6 @@ class Database: def createOrUpdateTourneysPlayers(self, hand, source=None): tourneysPlayersIds=[] for player in hand.players: - print "beginning of for in createOrUpdateTourneysPlayers, player",player,"dbid_pids",hand.dbid_pids if source=="TourneySummary": #TODO remove this horrible hack playerId = hand.dbid_pids[player] else: diff --git a/pyfpdb/PokerStarsSummary.py b/pyfpdb/PokerStarsSummary.py index ada27448..40b235d0 100644 --- a/pyfpdb/PokerStarsSummary.py +++ b/pyfpdb/PokerStarsSummary.py @@ -18,6 +18,7 @@ """pokerstars-specific summary parsing code""" from decimal import Decimal +import datetime from PokerStarsToFpdb import PokerStars from TourneySummary import * @@ -28,6 +29,7 @@ class PokerStarsSummary(TourneySummary): re_Prizepool = re.compile("\$[0-9]+\.[0-9]+") re_Player = re.compile(u"""(?P[0-9]+):\s(?P.*)\s\(.*\),(\s\$(?P[0-9]+\.[0-9]+)\s\()?""") re_BuyInFee = re.compile("(?P[0-9]+\.[0-9]+).*(?P[0-9]+\.[0-9]+)") + re_DateTime = re.compile("(?P[0-9]{4})\/(?P[0-9]{2})\/(?P[0-9]{2})[\- ]+(?P[0-9]+):(?P[0-9]+):(?P[0-9]+)") # = re.compile("") def parseSummary(self): @@ -52,7 +54,15 @@ class PokerStarsSummary(TourneySummary): self.prizepool = self.re_Prizepool.findall(lines[3])[0] self.prizepool = self.prizepool[1:-3]+self.prizepool[-2:] - #TODO: lines 4 and 5 are dates, read them + result=self.re_DateTime.search(lines[4]) + result=result.groupdict() + datetimestr = "%s/%s/%s %s:%s:%s" % (result['Y'], result['M'],result['D'],result['H'],result['MIN'],result['S']) + self.startTime= datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET" + + result=self.re_DateTime.search(lines[5]) + 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" for i in range(6,len(lines)-2): #lines with rank and winnings info if lines[i].find(":")==-1: diff --git a/pyfpdb/TourneySummary.py b/pyfpdb/TourneySummary.py index 8c6c6c47..032a04e6 100644 --- a/pyfpdb/TourneySummary.py +++ b/pyfpdb/TourneySummary.py @@ -194,7 +194,7 @@ class TourneySummary(object): self.playerIds.update({player:id}) - print "TS.insert players",self.players,"playerIds",self.playerIds + #print "TS.insert players",self.players,"playerIds",self.playerIds self.buyinCurrency=self.currency self.dbid_pids=self.playerIds #TODO:rename this field in Hand so this silly renaming can be removed