From d97be04066458dd6845a3d48bcca36b846a34dcd Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 20 Dec 2010 13:18:05 +0800 Subject: [PATCH] FTP: Change the way the number format is dealt with Rather than define [.,0-9] multiple times thoughout the regexes, add it to the substitutions section. Passes existing regression suite. --- pyfpdb/FulltiltToFpdb.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index 44cc9fbe..1ea80f4d 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -37,7 +37,8 @@ class Fulltilt(HandHistoryConverter): substitutions = { 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes 'LS' : u"\$|\u20AC|\xe2\x82\xac|", # legal currency symbols - Euro(cp1252, utf-8) - 'TAB' : u"-\u2013'\s\da-zA-Z" + 'TAB' : u"-\u2013'\s\da-zA-Z", # legal characters for tablename + 'NUM' : u".,\d", # legal characters in number format } # Static regexes @@ -45,10 +46,10 @@ class Fulltilt(HandHistoryConverter): (?:(?P.+)\s\((?P\d+)\),\s)? .+ -\s(?P[%(LS)s]|)? - (?P[.0-9]+)/ - [%(LS)s]?(?P[.0-9]+)\s - (Ante\s\$?(?P[.0-9]+)\s)?-\s - [%(LS)s]?(?P[.0-9]+\sCap\s)? + (?P[%(NUM)s]+)/ + [%(LS)s]?(?P[%(NUM)s]+)\s + (Ante\s\$?(?P[%(NUM)s]+)\s)?-\s + [%(LS)s]?(?P[%(NUM)s]+\sCap\s)? (?P(No\sLimit|Pot\sLimit|Limit))?\s (?P(Hold\'em|Omaha\sHi|Omaha\sH/L|7\sCard\sStud|Stud\sH/L|Razz|Stud\sHi|2-7\sTriple\sDraw|5\sCard\sDraw|Badugi)) ''' % substitutions, re.VERBOSE) @@ -60,7 +61,7 @@ class Fulltilt(HandHistoryConverter): (?PPlay\sChip\s|PC)? (?P[%(TAB)s]+)\s (\((?P.+)\)\s)?-\s - [%(LS)s]?(?P[.0-9]+)/[%(LS)s]?(?P[.0-9]+)\s(Ante\s[%(LS)s]?(?P[.0-9]+)\s)?-\s + [%(LS)s]?(?P[%(NUM)s]+)/[%(LS)s]?(?P[%(NUM)s]+)\s(Ante\s[%(LS)s]?(?P[.0-9]+)\s)?-\s [%(LS)s]?(?P[.0-9]+\sCap\s)? (?P[-\da-zA-Z\/\'\s]+)\s-\s (?P.*$) @@ -140,16 +141,16 @@ class Fulltilt(HandHistoryConverter): self.substitutions['PLAYERS'] = player_re logging.debug("player_re: " + player_re) - self.re_PostSB = re.compile(r"^%(PLAYERS)s posts the small blind of [%(LS)s]?(?P[.0-9]+)" % self.substitutions, re.MULTILINE) - self.re_PostDead = re.compile(r"^%(PLAYERS)s posts a dead small blind of [%(LS)s]?(?P[.0-9]+)" % self.substitutions, re.MULTILINE) - self.re_PostBB = re.compile(r"^%(PLAYERS)s posts (the big blind of )?[%(LS)s]?(?P[.0-9]+)" % self.substitutions, re.MULTILINE) - self.re_Antes = re.compile(r"^%(PLAYERS)s antes [%(LS)s]?(?P[.0-9]+)" % self.substitutions, re.MULTILINE) - self.re_BringIn = re.compile(r"^%(PLAYERS)s brings in for [%(LS)s]?(?P[.0-9]+)" % self.substitutions, re.MULTILINE) - self.re_PostBoth = re.compile(r"^%(PLAYERS)s posts small \& big blinds \[[%(LS)s]? (?P[.0-9]+)" % self.substitutions, re.MULTILINE) + self.re_PostSB = re.compile(r"^%(PLAYERS)s posts the small blind of [%(LS)s]?(?P[%(NUM)s]+)" % self.substitutions, re.MULTILINE) + 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_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) - self.re_Action = re.compile(r"^%(PLAYERS)s(?P bets| checks| raises to| completes it to| calls| folds)( [%(LS)s]?(?P[.,\d]+))?" % self.substitutions, re.MULTILINE) + self.re_Action = re.compile(r"^%(PLAYERS)s(?P bets| checks| raises to| completes it to| calls| folds)( [%(LS)s]?(?P[%(NUM)s]+))?" % self.substitutions, re.MULTILINE) self.re_ShowdownAction = re.compile(r"^%s shows \[(?P.*)\]" % player_re, re.MULTILINE) - self.re_CollectPot = re.compile(r"^Seat (?P[0-9]+): %(PLAYERS)s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \([%(LS)s]?(?P[.,\d]+)\)(, mucked| with.*)" % self.substitutions, re.MULTILINE) + self.re_CollectPot = re.compile(r"^Seat (?P[0-9]+): %(PLAYERS)s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \([%(LS)s]?(?P[%(NUM)s]+)\)(, mucked| with.*)" % self.substitutions, re.MULTILINE) self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE) self.re_ShownCards = re.compile(r"^Seat (?P[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(?Pshowed|mucked) \[(?P.*)\].*" % player_re, re.MULTILINE)