add support for partouche poker gibraltar to everleaf parser - thanks elwood42 for providing a regex and some sample files

This commit is contained in:
Steffen Schaumburg 2011-04-07 10:34:34 +02:00
parent 5e1c8364cf
commit 9db4d1db55
2 changed files with 80 additions and 20 deletions

52
pyfpdb/EverleafToFpdb.py Executable file → Normal file
View File

@ -33,20 +33,34 @@ class Everleaf(HandHistoryConverter):
filetype = "text"
codepage = "cp1252"
siteId = 3 # Needs to match id entry in Sites database
substitutions = {
'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
'LS' : u"\$|\u20AC|\xe2\x82\xac|\x80|", # legal currency symbols - Euro(cp1252, utf-8) #TODO change \x80 to \x20\x80, update all regexes accordingly
'TAB' : u"-\u2013'\s\da-zA-Z#_", # legal characters for tablename
'NUM' : u".,\d", # legal characters in number format
}
# Static regexes
re_SplitHands = re.compile(r"\n\n\n+")
re_TailSplitHands = re.compile(r"(\n\n\n+)")
re_GameInfo = re.compile(ur"^(Blinds )?(?P<CURRENCY>[$€]?)(?P<SB>[.0-9]+)/[$€]?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
#re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?P<CURRENCY>[$€])?(?P<SB>[.0-9]+)/(?:[$€])?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
re_GameInfo = re.compile(ur"^(Blinds )? ?(?P<CURRENCY>[%(LS)s]?)(?P<SB>[.0-9]+) ?/ ? ?[%(LS)s]?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))" % substitutions, re.MULTILINE)
#re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?P<CURRENCY>[$€])?(?P<SB>[.0-9]+)/(?:[$€])?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
re_HandInfo = re.compile(ur".*\n(.*#|.* partie )(?P<HID>[0-9]+).*(\n|\n\n)(Blinds )? ?(?P<CURRENCY>[%(LS)s])?(?P<SB>[.0-9]+) ?/ ?(?:[%(LS)s])?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)" % substitutions, re.MULTILINE)
#
#re_HandInfo = re.compile(ur"(.*#|.*\n.* partie )(?P<HID>[0-9]+).*(\n|\n\n)(Blinds )?(?:\$| €|)(?P<SB>[.0-9]+)/(?:\$| €|)(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button$", re.MULTILINE)
re_PlayerInfo = re.compile(ur"""^Seat\s(?P<SEAT>[0-9]+):\s(?P<PNAME>.*)\s+
\(
\s+[$]?\s?(?P<CASH>[.0-9]+)
(\s(USD|EURO|Chips)?(new\splayer|All-in)?)?
\s+[%(LS)s]?\s?(?P<CASH>[.0-9]+)
(\s(USD|EURO|EUR|Chips)?(new\splayer|All-in)?)?
\s?\)$
""", re.MULTILINE|re.VERBOSE)
""" % substitutions, re.MULTILINE|re.VERBOSE)
re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
re_TourneyInfoFromFilename = re.compile(ur".*TID_(?P<TOURNO>[0-9]+)-(?P<TABLE>[0-9]+)\.txt")
@ -58,16 +72,16 @@ class Everleaf(HandHistoryConverter):
self.compiledPlayers = players
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
logging.debug("player_re: "+ player_re)
self.re_PostSB = re.compile(ur"^%s: posts small blind \[[$€]? (?P<SB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
self.re_PostBB = re.compile(ur"^%s: posts big blind \[[$€]? (?P<BB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[[$€]? (?P<SBBB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
self.re_Antes = re.compile(ur"^%s: posts ante \[[$€]? (?P<ANTE>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
self.re_BringIn = re.compile(ur"^%s posts bring-in [$€]? (?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
self.re_PostSB = re.compile(ur"^%s: posts small blind \[ ?[%s]? (?P<SB>[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_PostBB = re.compile(ur"^%s: posts big blind \[ ?[%s]? (?P<BB>[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[ ?[%s]? (?P<SBBB>[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_Antes = re.compile(ur"^%s: posts ante \[ ?[%s]? (?P<ANTE>[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_BringIn = re.compile(ur"^%s posts bring-in ?[%s]? (?P<BRINGIN>[.0-9]+)\." % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P<CARDS>.*) \]$" % player_re, re.MULTILINE)
# ^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.,\d]+) (USD|EURO|Chips)\])?
self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:[$€]?) (?P<BET>[.,\d]+)\s?(USD|EURO|Chips|)\])?" % player_re, re.MULTILINE)
# ^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.,\d]+) (USD|EURO|EUR|Chips)\])?
self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?: ?[%s]?) (?P<BET>[.,\d]+)\s?(USD|EURO|EUR|Chips|)\])?" % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
self.re_CollectPot = re.compile(ur"^%s wins (?:[$€]?)\s?(?P<POT>[.\d]+) (USD|EURO|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
self.re_CollectPot = re.compile(ur"^%s wins ?(?: ?[%s]?)\s?(?P<POT>[.\d]+) (USD|EURO|EUR|chips)(.*?\[ (?P<CARDS>.*?) \])?" % (player_re, self.substitutions["LS"]), re.MULTILINE)
self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE)
def readSupportedGames(self):
@ -106,10 +120,11 @@ or None if we fail to get the info """
# Blinds 10/20 NL Hold'em - 2009/02/25 - 17:30:32
# Table 2
info = {'type':'ring'}
m = self.re_GameInfo.search(handText)
if not m:
tmp = handText[0:100]
tmp = handText[0:150]
log.error(_("Unable to recognise gametype from: '%s'") % tmp)
log.error("determineGameType: " + _("Raising FpdbParseError"))
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
@ -256,10 +271,7 @@ or None if we fail to get the info """
def readStudPlayerCards(self, hand, street):
# lol. see Plymouth.txt
logging.warning(_("Everleaf readStudPlayerCards is only a stub."))
#~ if street in ('THIRD', 'FOURTH', 'FIFTH', 'SIXTH'):
#~ hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = [], open = [])
def readAction(self, hand, street):

View File

@ -0,0 +1,48 @@
Partouche Poker Gibraltar
*** Historique des Mains pour la partie 25324991 ***
Blinds €0.01/ €0.02 NL Hold'em - 2009/10/27 - 19:04:57
Table Andernos 2
Seat 1 is the button
Total number of players: 6
Seat 1: player1 ( € 0.76 EUR )
Seat 2: player2 ( € 1.83 EUR )
Seat 3: player3 ( € 0.81 EUR )
Seat 4: player4 ( € 2 EUR )
Seat 5: player5 ( € 1.39 EUR )
Seat 6: player6 ( new player )
player2: posts small blind [ € 0.01 EUR]
player3: posts big blind [ € 0.02 EUR]
player4: posts big blind [ € 0.02 EUR]
** Dealing down cards **
Dealt to player4 [ 5s, 4s ]
player4 checks
player5 raises [ € 0.04 EUR]
player1 folds
player2 calls [ € 0.03 EUR]
player3 est déconnecté et dispose de 20 secondes supplémentaires pour agir
player3 calls [ € 0.02 EUR]
player4 calls [ € 0.02 EUR]
** Dealing Flop ** [ Qs, 8s, 7c ]
player3 est déconnecté et dispose de 20 secondes supplémentaires pour agir
player2 checks
player3 est déconnecté et dispose de 20 secondes supplémentaires pour agir
player3 checks
player4: bets [ € 0.08 EUR]
player5 raises [ € 0.16 EUR]
player2 folds
player3 calls [ € 0.16 EUR]
player4 calls [ € 0.08 EUR]
** Dealing Turn ** [ Th ]
player3 checks
player4 checks
player5: bets [ € 0.64 EUR]
player3 folds
player4 calls [ € 0.64 EUR]
** Dealing River ** [ Tc ]
player4: bets [ € 1.16 EUR]
player5 calls [ € 0.55 EUR]
player4 shows [ 5s, 4s ]a pair of tens
player5 shows [ Qh, Ad ]two pairs, queens and tens
player5 wins € 2.72 EUR from main pot with two pairs, queens and tens [ Ad, Qh, Qs, Th, Tc ]