From 43edb615b08778870b4656d352443a15f1855632 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 30 Sep 2010 17:19:35 +0800 Subject: [PATCH 1/6] SQL: Fix MySQL/Postgres Actions and HandsActions --- pyfpdb/SQL.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 25dd36e5..7d2931a7 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -162,13 +162,13 @@ class Sql: self.query['createActionsTable'] = """CREATE TABLE Actions ( id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), name varchar(32) NOT NULL, - code char(2) NOT NULL) + code char(4) NOT NULL) ENGINE=INNODB""" elif db_server == 'postgresql': self.query['createActionsTable'] = """CREATE TABLE Actions ( id SERIAL, PRIMARY KEY (id), name varchar(32), - code char(2))""" + code char(4))""" elif db_server == 'sqlite': self.query['createActionsTable'] = """CREATE TABLE Actions ( id INTEGER PRIMARY KEY, @@ -1011,7 +1011,7 @@ class Sql: street SMALLINT NOT NULL, actionNo SMALLINT NOT NULL, streetActionNo SMALLINT NOT NULL, - actionId SMALLINT NOT NULL, FOREIGN KEY (actionId) REFERENCES Actions(id), + actionId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (actionId) REFERENCES Actions(id), amount INT NOT NULL, raiseTo INT NOT NULL, amountCalled INT NOT NULL, From bbbf1ec4e6d52cc704c31ebeb70c09bf19fcc66d Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 30 Sep 2010 17:53:52 +0800 Subject: [PATCH 2/6] OnGame: Initial stud support. Added anough that it recognises the header and splits the streets correctly. --- pyfpdb/OnGameToFpdb.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index db7d99a2..9158fb05 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -52,11 +52,11 @@ class OnGame(HandHistoryConverter): games = { # base, category "TEXAS_HOLDEM" : ('hold','holdem'), - # 'Omaha' : ('hold','omahahi'), + 'OMAHA_HI' : ('hold','omahahi'), # 'Omaha Hi/Lo' : ('hold','omahahilo'), # 'Razz' : ('stud','razz'), # 'RAZZ' : ('stud','razz'), - # '7 Card Stud' : ('stud','studhi'), + 'SEVEN_CARD_STUD' : ('stud','studhi'), 'SEVEN_CARD_STUD_HI_LO' : ('stud','studhilo'), # 'Badugi' : ('draw','badugi'), # 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'), @@ -88,7 +88,7 @@ class OnGame(HandHistoryConverter): Table:\s(?P[\'\w\s]+)\s\[\d+\]\s\( ( (?PNO_LIMIT|Limit|LIMIT|Pot\sLimit)\s - (?PTEXAS_HOLDEM|RAZZ)\s + (?PTEXAS_HOLDEM|OMAHA_HI|SEVEN_CARD_STUD|SEVEN_CARD_STUD_HI_LO|RAZZ)\s (%(LS)s)?(?P[.0-9]+)/ (%(LS)s)?(?P[.0-9]+) )? @@ -239,18 +239,19 @@ class OnGame(HandHistoryConverter): hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH')) def markStreets(self, hand): - # PREFLOP = ** Dealing down cards ** - # This re fails if, say, river is missing; then we don't get the ** that starts the river. - #m = re.search('(\*\* Dealing down cards \*\*\n)(?P.*?\n\*\*)?( Dealing Flop \*\* \[ (?P\S\S), (?P\S\S), (?P\S\S) \])?(?P.*?\*\*)?( Dealing Turn \*\* \[ (?P\S\S) \])?(?P.*?\*\*)?( Dealing River \*\* \[ (?P\S\S) \])?(?P.*)', hand.string,re.DOTALL) - - #if hand.gametype['base'] in ("hold"): - #elif hand.gametype['base'] in ("stud"): - #elif hand.gametype['base'] in ("draw"): - # only holdem so far: - m = re.search(r"pocket cards(?P.+(?= Dealing flop )|.+(?=Summary))" + if hand.gametype['base'] in ("hold"): + m = re.search(r"pocket cards(?P.+(?= Dealing flop )|.+(?=Summary))" r"( Dealing flop (?P\[\S\S, \S\S, \S\S\].+(?= Dealing turn)|.+(?=Summary)))?" r"( Dealing turn (?P\[\S\S\].+(?= Dealing river)|.+(?=Summary)))?" r"( Dealing river (?P\[\S\S\].+(?=Summary)))?", hand.handText, re.DOTALL) + elif hand.gametype['base'] in ("stud"): + m = re.search(r"(?P.+(?=Dealing pocket cards)|.+)" + r"(Dealing pocket cards(?P.+(?=Dealing 4th street)|.+))?" + r"(Dealing 4th street(?P.+(?=Dealing 5th street)|.+))?" + r"(Dealing 5th street(?P.+(?=Dealing 6th street)|.+))?" + r"(Dealing 6th street(?P.+(?=Dealing river)|.+))?" + r"(Dealing river(?P.+))?", hand.handText,re.DOTALL) + #elif hand.gametype['base'] in ("draw"): hand.addStreets(m) @@ -311,10 +312,10 @@ class OnGame(HandHistoryConverter): for street in ('PREFLOP', 'DEAL'): if street in hand.streets.keys(): m = self.re_HeroCards.finditer(hand.streets[street]) - for found in m: - hand.hero = found.group('PNAME') - newcards = found.group('CARDS').split(', ') - hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True) + for found in m: + hand.hero = found.group('PNAME') + newcards = found.group('CARDS').split(', ') + hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True) def readAction(self, hand, street): m = self.re_Action.finditer(hand.streets[street]) From 1e0a1a6ad87a31940716ea6132dc9a6c309be05c Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 30 Sep 2010 18:01:47 +0800 Subject: [PATCH 3/6] OnGame: Initial Draw support No longer crashes on a Five Card draw hand --- pyfpdb/OnGameToFpdb.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index 9158fb05..faf52522 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -60,7 +60,7 @@ class OnGame(HandHistoryConverter): 'SEVEN_CARD_STUD_HI_LO' : ('stud','studhilo'), # 'Badugi' : ('draw','badugi'), # 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'), - # '5 Card Draw' : ('draw','fivedraw') + 'FIVE_CARD_DRAW' : ('draw','fivedraw') } # Static regexes @@ -88,7 +88,7 @@ class OnGame(HandHistoryConverter): Table:\s(?P
[\'\w\s]+)\s\[\d+\]\s\( ( (?PNO_LIMIT|Limit|LIMIT|Pot\sLimit)\s - (?PTEXAS_HOLDEM|OMAHA_HI|SEVEN_CARD_STUD|SEVEN_CARD_STUD_HI_LO|RAZZ)\s + (?PTEXAS_HOLDEM|OMAHA_HI|SEVEN_CARD_STUD|SEVEN_CARD_STUD_HI_LO|RAZZ|FIVE_CARD_DRAW)\s (%(LS)s)?(?P[.0-9]+)/ (%(LS)s)?(?P[.0-9]+) )? @@ -156,6 +156,7 @@ class OnGame(HandHistoryConverter): ["ring", "hold", "fl"], ["ring", "hold", "nl"], ["ring", "stud", "fl"], + ["ring", "draw", "fl"], ] def determineGameType(self, handText): @@ -251,7 +252,12 @@ class OnGame(HandHistoryConverter): r"(Dealing 5th street(?P.+(?=Dealing 6th street)|.+))?" r"(Dealing 6th street(?P.+(?=Dealing river)|.+))?" r"(Dealing river(?P.+))?", hand.handText,re.DOTALL) - #elif hand.gametype['base'] in ("draw"): + elif hand.gametype['base'] in ("draw"): + m = re.search(r"(?P.+(?=Dealing pocket cards)|.+)" + r"(Dealing pocket cards(?P.+(?=\*\*\* FIRST DRAW \*\*\*)|.+))?" + r"(\*\*\* FIRST DRAW \*\*\*(?P.+(?=\*\*\* SECOND DRAW \*\*\*)|.+))?" + r"(\*\*\* SECOND DRAW \*\*\*(?P.+(?=\*\*\* THIRD DRAW \*\*\*)|.+))?" + r"(\*\*\* THIRD DRAW \*\*\*(?P.+))?", hand.handText,re.DOTALL) hand.addStreets(m) From 9f64602338a581468e48bc2c0322f17a3f70e4af Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 1 Oct 2010 10:44:27 +0800 Subject: [PATCH 4/6] Database, Importer: Convert print to log.info --- pyfpdb/Database.py | 2 +- pyfpdb/fpdb_import.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index e94074c4..af8c4a3b 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1586,7 +1586,7 @@ class Database: self.connection.set_isolation_level(1) # go back to normal isolation level self.commit() atime = time() - stime - print _("Analyze took %.1f seconds") % (atime,) + log.info(_("Analyze took %.1f seconds") % (atime,)) #end def analyzeDB def vacuumDB(self): diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index cea95321..4c055bd1 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -239,7 +239,7 @@ class Importer: if self.settings['dropIndexes'] == 'drop': self.database.prepareBulkImport() else: - log.debug(_("No need to drop indexes.")) + log.info(_("No need to drop indexes.")) #print "dropInd =", self.settings['dropIndexes'], " dropHudCache =", self.settings['dropHudCache'] if self.settings['threads'] <= 0: @@ -277,11 +277,11 @@ class Importer: if self.settings['dropIndexes'] == 'drop': self.database.afterBulkImport() else: - print _("No need to rebuild indexes.") + log.info (_("No need to rebuild indexes.")) if 'dropHudCache' in self.settings and self.settings['dropHudCache'] == 'drop': self.database.rebuild_hudcache() else: - print _("No need to rebuild hudcache.") + log.info (_("No need to rebuild hudcache.")) self.database.analyzeDB() endtime = time() return (totstored, totdups, totpartial, toterrors, endtime-starttime) From 56b268920d562f0db29548cd2b466a5d52c1647c Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 1 Oct 2010 10:51:38 +0800 Subject: [PATCH 5/6] Betfair: Fix parse error from THP --- pyfpdb/BetfairToFpdb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyfpdb/BetfairToFpdb.py b/pyfpdb/BetfairToFpdb.py index 38aa6dc1..d30b3b8e 100755 --- a/pyfpdb/BetfairToFpdb.py +++ b/pyfpdb/BetfairToFpdb.py @@ -37,7 +37,7 @@ class Betfair(HandHistoryConverter): # Static regexes re_GameInfo = re.compile("^(?PNL|PL|) (?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+) (?P(Texas Hold\'em|Omaha Hi|Omaha|Razz))", re.MULTILINE) re_SplitHands = re.compile(r'\n\n+') - re_HandInfo = re.compile("\*\*\*\*\* Betfair Poker Hand History for Game (?P[0-9]+) \*\*\*\*\*\n(?PNL|PL|) (?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+) (?P(Texas Hold\'em|Omaha Hi|Razz)) - (?P[a-zA-Z]+, [a-zA-Z]+ \d+, \d\d:\d\d:\d\d GMT \d\d\d\d)\nTable (?P
[ a-zA-Z0-9]+) \d-max \(Real Money\)\nSeat (?P
[ a-zA-Z0-9]+) \d-max \(Real Money\)\nSeat (?P