Party: First pass at Party.fr support
The USD regression test files show no change in parse problems - 3 files still fail
This commit is contained in:
parent
d48cf03aab
commit
a79dbd8f1b
|
@ -45,22 +45,27 @@ class PartyPoker(HandHistoryConverter):
|
||||||
codepage = "utf8"
|
codepage = "utf8"
|
||||||
siteId = 9
|
siteId = 9
|
||||||
filetype = "text"
|
filetype = "text"
|
||||||
sym = {'USD': "\$", }
|
sym = {'USD': "\$", 'EUR': u"\u20ac", 'T$': ""}
|
||||||
|
currencies = {"\$": "USD", "$": "USD", u"\xe2\x82\xac": "EUR", u"\u20ac": "EUR", '': "T$"}
|
||||||
|
substitutions = {
|
||||||
|
'LEGAL_ISO' : "USD|EUR", # legal ISO currency codes
|
||||||
|
'LS' : "\$|\u20AC|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8)
|
||||||
|
}
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
# $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009
|
# $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009
|
||||||
# NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009
|
# NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009
|
||||||
re_GameInfoRing = re.compile("""
|
re_GameInfoRing = re.compile(u"""
|
||||||
(?P<CURRENCY>\$|)\s*(?P<RINGLIMIT>[.,0-9]+)([.,0-9/$]+)?\s*(?:USD)?\s*
|
(?P<CURRENCY>[%(LS)s])\s*(?P<RINGLIMIT>[.,0-9]+)([.,0-9/$]+)?\s*(?:%(LEGAL_ISO)s)?\s*
|
||||||
(?P<LIMIT>(NL|PL|))\s*
|
(?P<LIMIT>(NL|PL|))\s*
|
||||||
(?P<GAME>(Texas\ Hold\'em|Omaha|7 Card Stud Hi-Lo))
|
(?P<GAME>(Texas\ Hold\'em|Omaha|7 Card Stud Hi-Lo))
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
""", re.VERBOSE | re.UNICODE)
|
""" % substitutions, re.VERBOSE | re.UNICODE)
|
||||||
re_GameInfoTrny = re.compile("""
|
re_GameInfoTrny = re.compile("""
|
||||||
(?P<LIMIT>(NL|PL|))\s*
|
(?P<LIMIT>(NL|PL|))\s*
|
||||||
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
||||||
(?:(?P<BUYIN>\$?[.,0-9]+)\s*(?P<BUYIN_CURRENCY>USD)?\s*Buy-in\s+)?
|
(?:(?P<BUYIN>\$?[.,0-9]+)\s*(?P<BUYIN_CURRENCY>%(LEGAL_ISO)s)?\s*Buy-in\s+)?
|
||||||
Trny:\s?(?P<TOURNO>\d+)\s+
|
Trny:\s?(?P<TOURNO>\d+)\s+
|
||||||
Level:\s*(?P<LEVEL>\d+)\s+
|
Level:\s*(?P<LEVEL>\d+)\s+
|
||||||
((Blinds|Stakes)(?:-Antes)?)\(
|
((Blinds|Stakes)(?:-Antes)?)\(
|
||||||
|
@ -70,15 +75,14 @@ class PartyPoker(HandHistoryConverter):
|
||||||
\)
|
\)
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
""", re.VERBOSE | re.UNICODE)
|
""" % substitutions, re.VERBOSE | re.UNICODE)
|
||||||
re_Hid = re.compile("^Game \#(?P<HID>\d+) starts.")
|
re_Hid = re.compile("Game \#(?P<HID>\d+) starts.")
|
||||||
|
|
||||||
re_PlayerInfo = re.compile("""
|
re_PlayerInfo = re.compile(u"""
|
||||||
Seat\s(?P<SEAT>\d+):\s
|
Seat\s(?P<SEAT>\d+):\s
|
||||||
(?P<PNAME>.*)\s
|
(?P<PNAME>.*)\s
|
||||||
\(\s*\$?(?P<CASH>[0-9,.]+)\s*(?:USD|)\s*\)
|
\(\s*[%(LS)s]?(?P<CASH>[0-9,.]+)\s*(?:%(LEGAL_ISO)s|)\s*\)
|
||||||
""" ,
|
""" % substitutions, re.VERBOSE| re.UNICODE)
|
||||||
re.VERBOSE)
|
|
||||||
|
|
||||||
re_HandInfo = re.compile("""
|
re_HandInfo = re.compile("""
|
||||||
^Table\s+(?P<TTYPE>[$a-zA-Z0-9 ]+)?\s+
|
^Table\s+(?P<TTYPE>[$a-zA-Z0-9 ]+)?\s+
|
||||||
|
@ -123,18 +127,16 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
self.compiledPlayers = players
|
self.compiledPlayers = players
|
||||||
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
subst = {'PLYR': player_re, 'CUR_SYM': hand.SYMBOL[hand.gametype['currency']],
|
subst = {'PLYR': player_re, 'CUR_SYM': self.sym[hand.gametype['currency']],
|
||||||
'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'):
|
|
||||||
subst[key] = re.escape(subst[key])
|
|
||||||
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\]\."
|
||||||
re.MULTILINE)
|
% subst, 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,
|
u"%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.,0-9]+) ?%(CUR)s\]\."
|
||||||
re.MULTILINE)
|
% subst, re.MULTILINE)
|
||||||
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)
|
||||||
self.re_Antes = re.compile(
|
self.re_Antes = re.compile(
|
||||||
r"^%(PLYR)s posts ante \[%(CUR_SYM)s(?P<ANTE>[.,0-9]+) ?%(CUR)s\]" % subst,
|
r"^%(PLYR)s posts ante \[%(CUR_SYM)s(?P<ANTE>[.,0-9]+) ?%(CUR)s\]" % subst,
|
||||||
|
@ -142,11 +144,10 @@ class PartyPoker(HandHistoryConverter):
|
||||||
self.re_HeroCards = re.compile(
|
self.re_HeroCards = re.compile(
|
||||||
r"^Dealt to %(PLYR)s \[\s*(?P<NEWCARDS>.+)\s*\]" % subst,
|
r"^Dealt to %(PLYR)s \[\s*(?P<NEWCARDS>.+)\s*\]" % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_Action = re.compile(r"""
|
self.re_Action = re.compile(u"""
|
||||||
^%(PLYR)s\s+(?P<ATYPE>bets|checks|raises|calls|folds|is\sall-In)
|
^%(PLYR)s\s+(?P<ATYPE>bets|checks|raises|calls|folds|is\sall-In)
|
||||||
(?:\s+\[%(CUR_SYM)s(?P<BET>[.,\d]+)\s*%(CUR)s\])?
|
(?:\s+\[%(CUR_SYM)s(?P<BET>[.,\d]+)\s*%(CUR)s\])?
|
||||||
""" % subst,
|
""" % subst, re.MULTILINE|re.VERBOSE)
|
||||||
re.MULTILINE|re.VERBOSE)
|
|
||||||
self.re_ShownCards = re.compile(
|
self.re_ShownCards = re.compile(
|
||||||
r"^%s (?P<SHOWED>(?:doesn\'t )?shows?) " % player_re +
|
r"^%s (?P<SHOWED>(?:doesn\'t )?shows?) " % player_re +
|
||||||
r"\[ *(?P<CARDS>.+) *\](?P<COMBINATION>.+)\.",
|
r"\[ *(?P<CARDS>.+) *\](?P<COMBINATION>.+)\.",
|
||||||
|
@ -205,7 +206,6 @@ class PartyPoker(HandHistoryConverter):
|
||||||
'Omaha' : ('hold','omahahi'),
|
'Omaha' : ('hold','omahahi'),
|
||||||
"7 Card Stud Hi-Lo" : ('stud','studhi'),
|
"7 Card Stud Hi-Lo" : ('stud','studhi'),
|
||||||
}
|
}
|
||||||
currencies = { '$':'USD', '':'T$' }
|
|
||||||
|
|
||||||
for expectedField in ['LIMIT', 'GAME']:
|
for expectedField in ['LIMIT', 'GAME']:
|
||||||
if mg[expectedField] is None:
|
if mg[expectedField] is None:
|
||||||
|
@ -238,7 +238,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
info['bb'] = "%.2f" % (bb)
|
info['bb'] = "%.2f" % (bb)
|
||||||
info['sb'] = "%.2f" % (sb)
|
info['sb'] = "%.2f" % (sb)
|
||||||
info['currency'] = currencies[mg['CURRENCY']]
|
info['currency'] = self.currencies[mg['CURRENCY']]
|
||||||
else:
|
else:
|
||||||
info['sb'] = clearMoneyString(mg['SB'])
|
info['sb'] = clearMoneyString(mg['SB'])
|
||||||
info['bb'] = clearMoneyString(mg['BB'])
|
info['bb'] = clearMoneyString(mg['BB'])
|
||||||
|
@ -251,8 +251,8 @@ class PartyPoker(HandHistoryConverter):
|
||||||
info = {}
|
info = {}
|
||||||
try:
|
try:
|
||||||
info.update(self.re_Hid.search(hand.handText).groupdict())
|
info.update(self.re_Hid.search(hand.handText).groupdict())
|
||||||
except:
|
except AttributeError, e:
|
||||||
raise FpdbParseError(_("Cannot read HID for current hand"))
|
raise FpdbParseError(_("Cannot read HID for current hand: %s" % e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info.update(self.re_HandInfo.search(hand.handText,re.DOTALL).groupdict())
|
info.update(self.re_HandInfo.search(hand.handText,re.DOTALL).groupdict())
|
||||||
|
@ -365,7 +365,6 @@ class PartyPoker(HandHistoryConverter):
|
||||||
else:
|
else:
|
||||||
#zero stacked players are added later
|
#zero stacked players are added later
|
||||||
zeroStackPlayers.append([int(a.group('SEAT')), a.group('PNAME'), clearMoneyString(a.group('CASH'))])
|
zeroStackPlayers.append([int(a.group('SEAT')), a.group('PNAME'), clearMoneyString(a.group('CASH'))])
|
||||||
|
|
||||||
if hand.gametype['type'] == 'ring':
|
if hand.gametype['type'] == 'ring':
|
||||||
#finds first vacant seat after an exact seat
|
#finds first vacant seat after an exact seat
|
||||||
def findFirstEmptySeat(startSeat):
|
def findFirstEmptySeat(startSeat):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user