Merge branch 'master' of git://github.com/grindi/fpdb-grindi
This commit is contained in:
commit
a1bdf68dc2
|
@ -26,29 +26,21 @@ from HandHistoryConverter import *
|
||||||
|
|
||||||
# PartyPoker HH Format
|
# PartyPoker HH Format
|
||||||
|
|
||||||
class PartyPokerParseError(FpdbParseError):
|
class FpdbParseError(FpdbParseError):
|
||||||
"Usage: raise PartyPokerParseError(<msg>[, hh=<hh>][, hid=<hid>])"
|
"Usage: raise FpdbParseError(<msg>[, hh=<hh>][, hid=<hid>])"
|
||||||
|
|
||||||
def __init__(self, msg='', hh=None, hid=None):
|
def __init__(self, msg='', hh=None, hid=None):
|
||||||
if hh is not None:
|
return super(FpdbParseError, self).__init__(msg, hid=hid)
|
||||||
msg += "\n\nHand history attached below:\n" + self.wrapHh(hh)
|
|
||||||
return super(PartyPokerParseError, self).__init__(msg, hid=hid)
|
|
||||||
|
|
||||||
def wrapHh(self, hh):
|
def wrapHh(self, hh):
|
||||||
return ("%(DELIMETER)s\n%(HH)s\n%(DELIMETER)s") % \
|
return ("%(DELIMETER)s\n%(HH)s\n%(DELIMETER)s") % \
|
||||||
{'DELIMETER': '#'*50, 'HH': hh}
|
{'DELIMETER': '#'*50, 'HH': hh}
|
||||||
|
|
||||||
class PartyPoker(HandHistoryConverter):
|
class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
############################################################
|
|
||||||
# Class Variables
|
|
||||||
|
|
||||||
sitename = "PartyPoker"
|
sitename = "PartyPoker"
|
||||||
codepage = "cp1252"
|
codepage = "cp1252"
|
||||||
siteId = 9 # TODO: automate; it's a class variable so shouldn't hit DB too often
|
siteId = 9
|
||||||
filetype = "text" # "text" or "xml". I propose we subclass HHC to HHC_Text and HHC_XML.
|
filetype = "text"
|
||||||
|
|
||||||
|
|
||||||
sym = {'USD': "\$", }
|
sym = {'USD': "\$", }
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
|
@ -86,15 +78,15 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
re_HandInfo = re.compile("""
|
re_HandInfo = re.compile("""
|
||||||
^Table\s+
|
^Table\s+
|
||||||
(?P<TTYPE>[a-zA-Z0-9 ]+)\s+
|
(?P<TABLE_TYPE>[^#()]+)\s+ # Regular, Speed, etc
|
||||||
(?: \#|\(|)(?P<TABLE>\d+)\)?\s+
|
(?P<TABLE_ID_WRAPPER>\(|\#| ) # \# means sng, ( - mtt, nothing - cash game
|
||||||
(?:[^ ]+\s+\#(?P<MTTTABLE>\d+).+)? # table number for mtt
|
(?P<TABLE_ID>\d+) \)? \s+ # it's global unique id for this table
|
||||||
\((?P<PLAY>Real|Play)\s+Money\)\s+ # FIXME: check if play money is correct
|
(?:Table\s+\#(?P<TABLE_NUM>\d+).+)? # table num for mtt tournaments
|
||||||
Seat\s+(?P<BUTTON>\d+)\sis\sthe\sbutton
|
\((?P<PLAY>Real|Play)\s+Money\)\s*
|
||||||
""",
|
""",
|
||||||
re.MULTILINE|re.VERBOSE)
|
re.VERBOSE|re.MULTILINE)
|
||||||
|
|
||||||
# re_TotalPlayers = re.compile("^Total\s+number\s+of\s+players\s*:\s*(?P<MAXSEATS>\d+)", re.MULTILINE)
|
re_CountedSeats = re.compile("^Total\s+number\s+of\s+players\s*:\s*(?P<COUNTED_SEATS>\d+)", re.MULTILINE)
|
||||||
re_SplitHands = re.compile('\x00+')
|
re_SplitHands = re.compile('\x00+')
|
||||||
re_TailSplitHands = re.compile('(\x00+)')
|
re_TailSplitHands = re.compile('(\x00+)')
|
||||||
lineSplitter = '\n'
|
lineSplitter = '\n'
|
||||||
|
@ -131,16 +123,12 @@ class PartyPoker(HandHistoryConverter):
|
||||||
'CUR': hand.gametype['currency'] if hand.gametype['currency']!='T$' else ''}
|
'CUR': hand.gametype['currency'] if hand.gametype['currency']!='T$' else ''}
|
||||||
for key in ('CUR_SYM', 'CUR'):
|
for key in ('CUR_SYM', 'CUR'):
|
||||||
subst[key] = re.escape(subst[key])
|
subst[key] = re.escape(subst[key])
|
||||||
log.debug("player_re: '%s'" % subst['PLYR'])
|
|
||||||
log.debug("CUR_SYM: '%s'" % subst['CUR_SYM'])
|
|
||||||
log.debug("CUR: '%s'" % subst['CUR'])
|
|
||||||
self.re_PostSB = re.compile(
|
self.re_PostSB = re.compile(
|
||||||
r"^%(PLYR)s posts small blind \[%(CUR_SYM)s(?P<SB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts small blind \[%(CUR_SYM)s(?P<SB>[,.0-9]+) ?%(CUR)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_PostBB = re.compile(
|
self.re_PostBB = re.compile(
|
||||||
r"^%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.,0-9]+) ?%(CUR)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
# NOTE: comma is used as a fraction part delimeter in re below
|
|
||||||
self.re_PostDead = re.compile(
|
self.re_PostDead = re.compile(
|
||||||
r"^%(PLYR)s posts big blind \+ dead \[(?P<BBNDEAD>[.,0-9]+) ?%(CUR_SYM)s\]\." % subst,
|
r"^%(PLYR)s posts big blind \+ dead \[(?P<BBNDEAD>[.,0-9]+) ?%(CUR_SYM)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
|
@ -195,8 +183,6 @@ class PartyPoker(HandHistoryConverter):
|
||||||
gametype dict is:
|
gametype dict is:
|
||||||
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
||||||
|
|
||||||
log.debug(PartyPokerParseError().wrapHh( handText ))
|
|
||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
m = self._getGameType(handText)
|
m = self._getGameType(handText)
|
||||||
if m is None:
|
if m is None:
|
||||||
|
@ -213,22 +199,16 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
for expectedField in ['LIMIT', 'GAME']:
|
for expectedField in ['LIMIT', 'GAME']:
|
||||||
if mg[expectedField] is None:
|
if mg[expectedField] is None:
|
||||||
raise PartyPokerParseError(
|
raise FpdbParseError( "Cannot fetch field '%s'" % expectedField)
|
||||||
"Cannot fetch field '%s'" % expectedField,
|
|
||||||
hh = handText)
|
|
||||||
try:
|
try:
|
||||||
info['limitType'] = limits[mg['LIMIT'].strip()]
|
info['limitType'] = limits[mg['LIMIT'].strip()]
|
||||||
except:
|
except:
|
||||||
raise PartyPokerParseError(
|
raise FpdbParseError("Unknown limit '%s'" % mg['LIMIT'])
|
||||||
"Unknown limit '%s'" % mg['LIMIT'],
|
|
||||||
hh = handText)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(info['base'], info['category']) = games[mg['GAME']]
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
except:
|
except:
|
||||||
raise PartyPokerParseError(
|
raise FpdbParseError("Unknown game type '%s'" % mg['GAME'])
|
||||||
"Unknown game type '%s'" % mg['GAME'],
|
|
||||||
hh = handText)
|
|
||||||
|
|
||||||
if 'TOURNO' in mg:
|
if 'TOURNO' in mg:
|
||||||
info['type'] = 'tour'
|
info['type'] = 'tour'
|
||||||
|
@ -251,23 +231,21 @@ class PartyPoker(HandHistoryConverter):
|
||||||
try:
|
try:
|
||||||
info.update(self.re_Hid.search(hand.handText).groupdict())
|
info.update(self.re_Hid.search(hand.handText).groupdict())
|
||||||
except:
|
except:
|
||||||
raise PartyPokerParseError("Cannot read HID for current hand", hh=hand.handText)
|
raise FpdbParseError("Cannot read HID for current hand")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info.update(self.re_HandInfo.search(hand.handText,re.DOTALL).groupdict())
|
info.update(self.re_HandInfo.search(hand.handText,re.DOTALL).groupdict())
|
||||||
except:
|
except:
|
||||||
raise PartyPokerParseError("Cannot read Handinfo for current hand",
|
raise FpdbParseError("Cannot read Handinfo for current hand", hid = info['HID'])
|
||||||
hh=hand.handText, hid = info['HID'])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info.update(self._getGameType(hand.handText).groupdict())
|
info.update(self._getGameType(hand.handText).groupdict())
|
||||||
except:
|
except:
|
||||||
raise PartyPokerParseError("Cannot read GameType for current hand",
|
raise FpdbParseError("Cannot read GameType for current hand", hid = info['HID'])
|
||||||
hh=hand.handText, hid = info['HID'])
|
|
||||||
|
|
||||||
|
|
||||||
# m = self.re_TotalPlayers.search(hand.handText)
|
m = self.re_CountedSeats.search(hand.handText)
|
||||||
# if m: info.update(m.groupdict())
|
if m: info.update(m.groupdict())
|
||||||
|
|
||||||
|
|
||||||
# FIXME: it's dirty hack
|
# FIXME: it's dirty hack
|
||||||
|
@ -294,6 +272,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
if key == 'DATETIME':
|
if key == 'DATETIME':
|
||||||
#Saturday, July 25, 07:53:52 EDT 2009
|
#Saturday, July 25, 07:53:52 EDT 2009
|
||||||
#Thursday, July 30, 21:40:41 MSKS 2009
|
#Thursday, July 30, 21:40:41 MSKS 2009
|
||||||
|
#Sunday, October 25, 13:39:07 MSK 2009
|
||||||
m2 = re.search("\w+, (?P<M>\w+) (?P<D>\d+), (?P<H>\d+):(?P<MIN>\d+):(?P<S>\d+) (?P<TZ>[A-Z]+) (?P<Y>\d+)", info[key])
|
m2 = re.search("\w+, (?P<M>\w+) (?P<D>\d+), (?P<H>\d+):(?P<MIN>\d+):(?P<S>\d+) (?P<TZ>[A-Z]+) (?P<Y>\d+)", info[key])
|
||||||
# we cant use '%B' due to locale problems
|
# we cant use '%B' due to locale problems
|
||||||
months = ['January', 'February', 'March', 'April','May', 'June',
|
months = ['January', 'February', 'March', 'April','May', 'June',
|
||||||
|
@ -307,21 +286,28 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
if key == 'HID':
|
if key == 'HID':
|
||||||
hand.handid = info[key]
|
hand.handid = info[key]
|
||||||
if key == 'TABLE':
|
|
||||||
hand.tablename = info[key]
|
|
||||||
if key == 'BUTTON':
|
|
||||||
hand.buttonpos = info[key]
|
|
||||||
if key == 'TOURNO':
|
if key == 'TOURNO':
|
||||||
hand.tourNo = info[key]
|
hand.tourNo = info[key]
|
||||||
|
if key == 'TABLE_ID_WRAPPER':
|
||||||
|
if info[key] == '#':
|
||||||
|
# FIXME: there is no such property in Hand class
|
||||||
|
self.isSNG = True
|
||||||
if key == 'BUYIN':
|
if key == 'BUYIN':
|
||||||
# FIXME: it's dirty hack T_T
|
# FIXME: it's dirty hack T_T
|
||||||
# code below assumes that tournament rake is equal to zero
|
# code below assumes that tournament rake is equal to zero
|
||||||
cur = info[key][0] if info[key][0] not in '0123456789' else ''
|
cur = info[key][0] if info[key][0] not in '0123456789' else ''
|
||||||
hand.buyin = info[key] + '+%s0' % cur
|
hand.buyin = info[key] + '+%s0' % cur
|
||||||
|
if key == 'TABLE_ID':
|
||||||
|
hand.tablename = info[key]
|
||||||
|
if key == 'TABLE_NUM':
|
||||||
|
# FIXME: there is no such property in Hand class
|
||||||
|
hand.table_num = info[key]
|
||||||
|
if key == 'COUNTED_SEATS':
|
||||||
|
hand.counted_seats = info[key]
|
||||||
if key == 'LEVEL':
|
if key == 'LEVEL':
|
||||||
hand.level = info[key]
|
hand.level = info[key]
|
||||||
if key == 'PLAY' and info['PLAY'] != 'Real':
|
if key == 'PLAY' and info['PLAY'] != 'Real':
|
||||||
# if realy there's no play money hh on party
|
# if realy party doesn's save play money hh
|
||||||
hand.gametype['currency'] = 'play'
|
hand.gametype['currency'] = 'play'
|
||||||
|
|
||||||
def readButton(self, hand):
|
def readButton(self, hand):
|
||||||
|
@ -406,8 +392,6 @@ class PartyPoker(HandHistoryConverter):
|
||||||
blind = smartMin(hand.bb, playersMap[bigBlindSeat][1])
|
blind = smartMin(hand.bb, playersMap[bigBlindSeat][1])
|
||||||
hand.addBlind(playersMap[bigBlindSeat][0], 'big blind', blind)
|
hand.addBlind(playersMap[bigBlindSeat][0], 'big blind', blind)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
# we need to grab hero's cards
|
# we need to grab hero's cards
|
||||||
for street in ('PREFLOP',):
|
for street in ('PREFLOP',):
|
||||||
|
@ -418,7 +402,6 @@ class PartyPoker(HandHistoryConverter):
|
||||||
newcards = renderCards(found.group('NEWCARDS'))
|
newcards = renderCards(found.group('NEWCARDS'))
|
||||||
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
|
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
|
||||||
|
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.re_Action.finditer(hand.streets[street])
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
for action in m:
|
for action in m:
|
||||||
|
@ -453,10 +436,9 @@ class PartyPoker(HandHistoryConverter):
|
||||||
elif actionType == 'checks':
|
elif actionType == 'checks':
|
||||||
hand.addCheck( street, playerName )
|
hand.addCheck( street, playerName )
|
||||||
else:
|
else:
|
||||||
raise PartyPokerParseError(
|
raise FpdbParseError(
|
||||||
"Unimplemented readAction: '%s' '%s'" % (playerName,actionType,),
|
"Unimplemented readAction: '%s' '%s'" % (playerName,actionType,),
|
||||||
hid = hand.hid, hh = hand.handText )
|
hid = hand.hid, )
|
||||||
|
|
||||||
|
|
||||||
def readShowdownActions(self, hand):
|
def readShowdownActions(self, hand):
|
||||||
# all action in readShownCards
|
# all action in readShownCards
|
||||||
|
@ -475,6 +457,17 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=True, mucked=mucked)
|
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=True, mucked=mucked)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getTableTitleRe(type, table_name=None, tournament = None, table_number=None):
|
||||||
|
"Returns string to search in windows titles"
|
||||||
|
if type=="tour":
|
||||||
|
print 'party', 'getTableTitleRe', "%s.+Table\s#%s" % (table_name, table_number)
|
||||||
|
return "%s.+Table\s#%s" % (table_name, table_number)
|
||||||
|
else:
|
||||||
|
print 'party', 'getTableTitleRe', table_number
|
||||||
|
return table_name
|
||||||
|
|
||||||
|
|
||||||
def ringBlinds(ringLimit):
|
def ringBlinds(ringLimit):
|
||||||
"Returns blinds for current limit in cash games"
|
"Returns blinds for current limit in cash games"
|
||||||
ringLimit = float(clearMoneyString(ringLimit))
|
ringLimit = float(clearMoneyString(ringLimit))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user