diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py old mode 100755 new mode 100644 index efd2d689..a9a9f179 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -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[$€]?)(?P[.0-9]+)/[$€]?(?P[.0-9]+) (?PNL|PL|) ?(?P(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE) - #re.compile(ur"^(Blinds )?(?P\$| €|)(?P[.0-9]+)/(?:\$| €)?(?P[.0-9]+) (?PNL|PL|) ?(?P(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE) - re_HandInfo = re.compile(ur".*#(?P[0-9]+)\n.*\n(Blinds )?(?P[$€])?(?P[.0-9]+)/(?:[$€])?(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P.+$)", re.MULTILINE) + re_GameInfo = re.compile(ur"^(Blinds )? ?(?P[%(LS)s]?)(?P[.0-9]+) ?/ ? ?[%(LS)s]?(?P[.0-9]+) (?PNL|PL|) ?(?P(Hold\'em|Omaha|7 Card Stud))" % substitutions, re.MULTILINE) + + #re_HandInfo = re.compile(ur".*#(?P[0-9]+)\n.*\n(Blinds )?(?P[$€])?(?P[.0-9]+)/(?:[$€])?(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P
.+$)", re.MULTILINE) + + re_HandInfo = re.compile(ur".*\n(.*#|.* partie )(?P[0-9]+).*(\n|\n\n)(Blinds )? ?(?P[%(LS)s])?(?P[.0-9]+) ?/ ?(?:[%(LS)s])?(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P
.+$)" % substitutions, re.MULTILINE) + # + + #re_HandInfo = re.compile(ur"(.*#|.*\n.* partie )(?P[0-9]+).*(\n|\n\n)(Blinds )?(?:\$| €|)(?P[.0-9]+)/(?:\$| €|)(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P
.+$)", re.MULTILINE) + + re_Button = re.compile(ur"^Seat (?P
[0-9]+)\.txt") @@ -58,16 +72,16 @@ class Everleaf(HandHistoryConverter): self.compiledPlayers = players player_re = "(?P" + "|".join(map(re.escape, players)) + ")" logging.debug("player_re: "+ player_re) - self.re_PostSB = re.compile(ur"^%s: posts small blind \[[$€]? (?P[.0-9]+)\s.*\]$" % player_re, re.MULTILINE) - self.re_PostBB = re.compile(ur"^%s: posts big blind \[[$€]? (?P[.0-9]+)\s.*\]$" % player_re, re.MULTILINE) - self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[[$€]? (?P[.0-9]+)\s.*\]$" % player_re, re.MULTILINE) - self.re_Antes = re.compile(ur"^%s: posts ante \[[$€]? (?P[.0-9]+)\s.*\]$" % player_re, re.MULTILINE) - self.re_BringIn = re.compile(ur"^%s posts bring-in [$€]? (?P[.0-9]+)\." % player_re, re.MULTILINE) + self.re_PostSB = re.compile(ur"^%s: posts small blind \[ ?[%s]? (?P[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE) + self.re_PostBB = re.compile(ur"^%s: posts big blind \[ ?[%s]? (?P[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE) + self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[ ?[%s]? (?P[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE) + self.re_Antes = re.compile(ur"^%s: posts ante \[ ?[%s]? (?P[.0-9]+)\s.*\]$" % (player_re, self.substitutions["LS"]), re.MULTILINE) + self.re_BringIn = re.compile(ur"^%s posts bring-in ?[%s]? (?P[.0-9]+)\." % (player_re, self.substitutions["LS"]), re.MULTILINE) self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P.*) \]$" % player_re, re.MULTILINE) - # ^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.,\d]+) (USD|EURO|Chips)\])? - self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:[$€]?) (?P[.,\d]+)\s?(USD|EURO|Chips|)\])?" % player_re, re.MULTILINE) + # ^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.,\d]+) (USD|EURO|EUR|Chips)\])? + self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?: ?[%s]?) (?P[.,\d]+)\s?(USD|EURO|EUR|Chips|)\])?" % (player_re, self.substitutions["LS"]), re.MULTILINE) self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P.*) \]" % player_re, re.MULTILINE) - self.re_CollectPot = re.compile(ur"^%s wins (?:[$€]?)\s?(?P[.\d]+) (USD|EURO|chips)(.*?\[ (?P.*?) \])?" % player_re, re.MULTILINE) + self.re_CollectPot = re.compile(ur"^%s wins ?(?: ?[%s]?)\s?(?P[.\d]+) (USD|EURO|EUR|chips)(.*?\[ (?P.*?) \])?" % (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) @@ -254,8 +269,10 @@ or None if we fail to get the info """ #Not involved in hand hand.involved = False + def readStudPlayerCards(self, hand, street): - logging.warning(_("Absolute cannot read all stud/razz hands yet.")) + logging.warning(_("Everleaf cannot read all stud/razz hands yet.")) + def readAction(self, hand, street): logging.debug("readAction (%s)" % street) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index e3e0db09..e3809d95 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -171,6 +171,7 @@ class Fulltilt(HandHistoryConverter): self.re_PostDead = re.compile(r"^%(PLAYERS)s posts a dead small blind of [%(LS)s]?(?P[%(NUM)s]+)" % self.substitutions, re.MULTILINE) self.re_PostBB = re.compile(r"^%(PLAYERS)s posts (the big blind of )?[%(LS)s]?(?P[%(NUM)s]+)" % self.substitutions, re.MULTILINE) self.re_Antes = re.compile(r"^%(PLAYERS)s antes [%(LS)s]?(?P[%(NUM)s]+)" % self.substitutions, re.MULTILINE) + self.re_ReturnsAnte = re.compile(r"^Ante of [%(LS)s]?[%(NUM)s]+ returned to %(PLAYERS)s" % self.substitutions, re.MULTILINE) self.re_BringIn = re.compile(r"^%(PLAYERS)s brings in for [%(LS)s]?(?P[%(NUM)s]+)" % self.substitutions, re.MULTILINE) self.re_PostBoth = re.compile(r"^%(PLAYERS)s posts small \& big blinds \[[%(LS)s]? (?P[%(NUM)s]+)" % self.substitutions, re.MULTILINE) self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P.+?)\])?( \[(?P.+?)\])" % player_re, re.MULTILINE) @@ -356,8 +357,9 @@ class Fulltilt(HandHistoryConverter): # Remove any listed as sitting out in the summary as start of hand info unreliable n = self.re_SummarySitout.finditer(post) for b in n: - del plist[b.group('PNAME')] - #print "DEBUG: Deleting '%s' from player dict" %(b.group('PNAME')) + if b.group('PNAME') in plist: + #print "DEBUG: Deleting '%s' from player dict" %(b.group('PNAME')) + del plist[b.group('PNAME')] # Add remaining players for a in plist: @@ -414,11 +416,16 @@ class Fulltilt(HandHistoryConverter): def readAntes(self, hand): logging.debug(_("reading antes")) + slist = [] + n = self.re_ReturnsAnte.finditer(hand.handText) + for player in n: + #If a player has their ante returned, then they timed out and are actually sitting out + slist.append(player.group('PNAME')) m = self.re_Antes.finditer(hand.handText) for player in m: logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE'))) -# if player.group() != - hand.addAnte(player.group('PNAME'), player.group('ANTE')) + if player.group('PNAME') not in slist: + hand.addAnte(player.group('PNAME'), player.group('ANTE')) def readBringIn(self, hand): m = self.re_BringIn.search(hand.handText,re.DOTALL) diff --git a/pyfpdb/regression-test-files/cash/Everleaf/Flop/NLHE-EUR-0.01-0.02-20091027.partouche b/pyfpdb/regression-test-files/cash/Everleaf/Flop/NLHE-EUR-0.01-0.02-20091027.partouche new file mode 100644 index 00000000..33780c8a --- /dev/null +++ b/pyfpdb/regression-test-files/cash/Everleaf/Flop/NLHE-EUR-0.01-0.02-20091027.partouche @@ -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 ] + +