handle FPP and added money tourneys, general currency improvements
This commit is contained in:
parent
86a1f86b51
commit
604e242349
|
@ -20,6 +20,7 @@
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from Exceptions import FpdbParseError
|
||||||
import PokerStarsToFpdb
|
import PokerStarsToFpdb
|
||||||
from TourneySummary import *
|
from TourneySummary import *
|
||||||
|
|
||||||
|
@ -27,8 +28,11 @@ class PokerStarsSummary(TourneySummary):
|
||||||
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_Player = re.compile(u"""(?P<RANK>[0-9]+):\s(?P<NAME>.*)\s\(.*\),(\s\$(?P<WINNINGS>[0-9]+\.[0-9]+)\s\()?""")
|
re_Player = re.compile("""(?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_FPP = re.compile("(?P<FPP>[0-9]+)\sFPP")
|
||||||
|
#note: the dollar and cent in the below line are currency-agnostic
|
||||||
|
re_Added = re.compile("(?P<DOLLAR>[0-9]+)\.(?P<CENT>[0-9]+)\s(?P<CURRENCY>[A-Z]+)(\sadded\sto\sthe\sprize\spool\sby\sPokerStars)")
|
||||||
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_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("")
|
||||||
|
|
||||||
|
@ -37,35 +41,60 @@ class PokerStarsSummary(TourneySummary):
|
||||||
|
|
||||||
self.tourNo = self.re_TourNo.findall(lines[0])[0][1:-1] #ignore game and limit type as thats not recorded
|
self.tourNo = self.re_TourNo.findall(lines[0])[0][1:-1] #ignore game and limit type as thats not recorded
|
||||||
|
|
||||||
if lines[1].find("$")!=-1:
|
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"
|
self.currency="USD"
|
||||||
elif lines[1].find(u"€")!=-1:
|
elif lines[1].find(u"€")!=-1:
|
||||||
self.currency="EUR"
|
self.currency="EUR"
|
||||||
|
elif lines[1].find("FPP")!=-1:
|
||||||
|
self.currency="PSFP"
|
||||||
else:
|
else:
|
||||||
raise fpdbParseError("didn't recognise buyin currency")
|
raise FpdbParseError("didn't recognise buyin currency in:"+lines[1])
|
||||||
|
|
||||||
result=self.re_BuyInFee.search(lines[1])
|
if self.currency=="USD" or self.currency=="EUR":
|
||||||
result=result.groupdict()
|
result=self.re_BuyInFee.search(lines[1])
|
||||||
self.buyin=int(100*Decimal(result['BUYIN']))
|
result=result.groupdict()
|
||||||
self.fee=int(100*Decimal(result['FEE']))
|
self.buyin=int(100*Decimal(result['BUYIN']))
|
||||||
|
self.fee=int(100*Decimal(result['FEE']))
|
||||||
|
elif self.currency=="PSFP":
|
||||||
|
result=self.re_FPP.search(lines[1])
|
||||||
|
result=result.groupdict()
|
||||||
|
self.buyin=int(Decimal(result['FPP']))
|
||||||
|
self.fee=0
|
||||||
|
|
||||||
self.entries = self.re_Entries.findall(lines[2])[0]
|
currentLine=2
|
||||||
|
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]
|
||||||
|
|
||||||
self.prizepool = self.re_Prizepool.findall(lines[3])[0]
|
result=self.re_Added.search(lines[currentLine])
|
||||||
|
if result:
|
||||||
|
print "detected addon [currentLine]", lines[currentLine]
|
||||||
|
result=result.groupdict()
|
||||||
|
self.added=100*int(Decimal(result['DOLLAR']))+int(Decimal(result['CENT']))
|
||||||
|
self.addedCurrency=result['CURRENCY']
|
||||||
|
#print "TODO: implement added:",self.added,self.addedCurrency
|
||||||
|
currentLine+=1
|
||||||
|
|
||||||
|
self.prizepool = self.re_Prizepool.findall(lines[currentLine])[0]
|
||||||
self.prizepool = self.prizepool[1:-3]+self.prizepool[-2:]
|
self.prizepool = self.prizepool[1:-3]+self.prizepool[-2:]
|
||||||
|
currentLine+=1
|
||||||
|
#print "after prizepool lines[currentLine]", lines[currentLine]
|
||||||
|
|
||||||
result=self.re_DateTime.search(lines[4])
|
result=self.re_DateTime.search(lines[currentLine])
|
||||||
result=result.groupdict()
|
result=result.groupdict()
|
||||||
datetimestr = "%s/%s/%s %s:%s:%s" % (result['Y'], result['M'],result['D'],result['H'],result['MIN'],result['S'])
|
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"
|
self.startTime= datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
|
||||||
self.startTime = PokerStarsToFpdb.removeET(self.startTime)
|
self.startTime = PokerStarsToFpdb.removeET(self.startTime)
|
||||||
|
currentLine+=1
|
||||||
|
|
||||||
result=self.re_DateTime.search(lines[5])
|
result=self.re_DateTime.search(lines[currentLine])
|
||||||
result=result.groupdict()
|
result=result.groupdict()
|
||||||
datetimestr = "%s/%s/%s %s:%s:%s" % (result['Y'], result['M'],result['D'],result['H'],result['MIN'],result['S'])
|
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"
|
self.endTime= datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
|
||||||
|
currentLine+=1
|
||||||
|
|
||||||
for i in range(6,len(lines)-2): #lines with rank and winnings info
|
for i in range(currentLine,len(lines)-2): #lines with rank and winnings info
|
||||||
if lines[i].find(":")==-1:
|
if lines[i].find(":")==-1:
|
||||||
break
|
break
|
||||||
result=self.re_Player.search(lines[i])
|
result=self.re_Player.search(lines[i])
|
||||||
|
@ -78,6 +107,6 @@ class PokerStarsSummary(TourneySummary):
|
||||||
else:
|
else:
|
||||||
winnings=0
|
winnings=0
|
||||||
|
|
||||||
self.addPlayer(rank, name, winnings, "USD", None, None, None)#TODO: currency, ko/addon/rebuy count -> need examples!
|
self.addPlayer(rank, name, winnings, self.currency, None, None, None)#TODO: currency, ko/addon/rebuy count -> need examples!
|
||||||
#end def parseSummary
|
#end def parseSummary
|
||||||
#end class PokerStarsSummary
|
#end class PokerStarsSummary
|
||||||
|
|
Loading…
Reference in New Issue
Block a user