much improved PS summary parsing thanks to carls help

This commit is contained in:
steffen123 2010-07-07 08:05:42 +02:00
parent 2046fc1122
commit 160ca30abe
2 changed files with 15 additions and 18 deletions

View File

@ -67,7 +67,7 @@ for messageData in neededMessages:
summaryTexts=(splitPokerStarsSummaries(bodyData)) summaryTexts=(splitPokerStarsSummaries(bodyData))
for summaryText in summaryTexts: for summaryText in summaryTexts:
result=PokerStarsSummary.PokerStarsSummary(sitename="PokerStars", gametype=None, summaryText=summaryText, builtFrom = "IMAP") result=PokerStarsSummary.PokerStarsSummary(sitename="PokerStars", gametype=None, summaryText=summaryText, builtFrom = "IMAP")
print "result:",result #print "result:",result
#TODO: count results and output to shell like hand importer does #TODO: count results and output to shell like hand importer does
print "completed running Imap import, closing server connection" print "completed running Imap import, closing server connection"

View File

@ -17,23 +17,22 @@
"""pokerstars-specific summary parsing code""" """pokerstars-specific summary parsing code"""
from TourneySummary import * from decimal import Decimal
from PokerStarsToFpdb import PokerStars from PokerStarsToFpdb import PokerStars
from TourneySummary import *
class PokerStarsSummary(TourneySummary): class PokerStarsSummary(TourneySummary):
sitename = "PokerStars" sitename = "PokerStars"
siteId = 2 siteId = 2
limits = PokerStars.limits #limits = PokerStars.limits
games = PokerStars.games #games = PokerStars.games
# = PokerStars. # = PokerStars.
re_TourNo = re.compile("\#[0-9]+,") re_TourNo = re.compile("\#[0-9]+,")
re_Entries = re.compile("[0-9]+") re_Entries = re.compile("[0-9]+")
re_Prizepool = re.compile("\$[0-9]+\.[0-9]+") re_Prizepool = re.compile("\$[0-9]+\.[0-9]+")
re_Rank = re.compile("[0-9]+:") re_Player = re.compile("""(?P<RANK>[0-9]+):\s(?P<NAME>.*)\s\(.*\),(\s\$(?P<WINNINGS>[0-9]+\.[0-9]+)\s\()?""")
re_Name = re.compile(":.*\(")
re_Winnings = re.compile("\$[0-9]+\.[0-9]+ \(")
# = re.compile("") # = re.compile("")
def parseSummary(self): def parseSummary(self):
@ -53,18 +52,16 @@ class PokerStarsSummary(TourneySummary):
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:
break break
rank=self.re_Rank.findall(lines[i])[0][:-1] result=self.re_Player.search(lines[i])
start = lines[i].find(":")+2 result=result.groupdict()
end = lines[i].find("(")-1 rank=result['RANK']
name=lines[i][start:end] name=result['NAME']
winnings=self.re_Winnings.findall(lines[i]) winnings=result['WINNINGS']
if winnings: if winnings:
winnings=winnings[0][1:-5]+winnings[0][-4:-2] winnings=int(100*Decimal(winnings))
else: else:
winnings=0 winnings=0
self.addPlayer(rank, name, winnings, "USD", -1, -1, -1) self.addPlayer(rank, name, winnings, "USD", -1, -1, -1)#TODO: currency, ko/addon/rebuy count -> need examples!
#end def parseSummary #end def parseSummary
#end class PokerStarsSummary #end class PokerStarsSummary