diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py old mode 100755 new mode 100644 index c5525e36..f98911e8 --- 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) @@ -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): 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 ] + +