PS Summary now parses start/endTime. fixes MySQL support

also removed some but not all the new prints
This commit is contained in:
steffen123 2010-07-08 21:41:27 +02:00
parent 7070c1431a
commit 201b3a5b6c
3 changed files with 13 additions and 4 deletions

View File

@ -805,7 +805,7 @@ class Database:
def get_player_id(self, config, siteName, playerName): def get_player_id(self, config, siteName, playerName):
c = self.connection.cursor() c = self.connection.cursor()
playerNameUtf = Charset.to_utf8(playerName) 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)) c.execute(self.sql.query['get_player_id'], (playerNameUtf, siteName))
row = c.fetchone() row = c.fetchone()
if row: if row:
@ -1998,7 +1998,6 @@ class Database:
def createOrUpdateTourneysPlayers(self, hand, source=None): def createOrUpdateTourneysPlayers(self, hand, source=None):
tourneysPlayersIds=[] tourneysPlayersIds=[]
for player in hand.players: 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 if source=="TourneySummary": #TODO remove this horrible hack
playerId = hand.dbid_pids[player] playerId = hand.dbid_pids[player]
else: else:

View File

@ -18,6 +18,7 @@
"""pokerstars-specific summary parsing code""" """pokerstars-specific summary parsing code"""
from decimal import Decimal from decimal import Decimal
import datetime
from PokerStarsToFpdb import PokerStars from PokerStarsToFpdb import PokerStars
from TourneySummary import * from TourneySummary import *
@ -28,6 +29,7 @@ class PokerStarsSummary(TourneySummary):
re_Prizepool = re.compile("\$[0-9]+\.[0-9]+") re_Prizepool = re.compile("\$[0-9]+\.[0-9]+")
re_Player = re.compile(u"""(?P<RANK>[0-9]+):\s(?P<NAME>.*)\s\(.*\),(\s\$(?P<WINNINGS>[0-9]+\.[0-9]+)\s\()?""") re_Player = re.compile(u"""(?P<RANK>[0-9]+):\s(?P<NAME>.*)\s\(.*\),(\s\$(?P<WINNINGS>[0-9]+\.[0-9]+)\s\()?""")
re_BuyInFee = re.compile("(?P<BUYIN>[0-9]+\.[0-9]+).*(?P<FEE>[0-9]+\.[0-9]+)") re_BuyInFee = re.compile("(?P<BUYIN>[0-9]+\.[0-9]+).*(?P<FEE>[0-9]+\.[0-9]+)")
re_DateTime = re.compile("(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)")
# = re.compile("") # = re.compile("")
def parseSummary(self): def parseSummary(self):
@ -52,7 +54,15 @@ class PokerStarsSummary(TourneySummary):
self.prizepool = self.re_Prizepool.findall(lines[3])[0] self.prizepool = self.re_Prizepool.findall(lines[3])[0]
self.prizepool = self.prizepool[1:-3]+self.prizepool[-2:] 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 for i in range(6,len(lines)-2): #lines with rank and winnings info
if lines[i].find(":")==-1: if lines[i].find(":")==-1:

View File

@ -194,7 +194,7 @@ class TourneySummary(object):
self.playerIds.update({player:id}) 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.buyinCurrency=self.currency
self.dbid_pids=self.playerIds #TODO:rename this field in Hand so this silly renaming can be removed self.dbid_pids=self.playerIds #TODO:rename this field in Hand so this silly renaming can be removed