Merge branch 'master' of git://git.assembla.com/fpdboz.git

This commit is contained in:
Eric Blade 2010-10-01 22:20:32 -04:00
commit fa3a9c54b8
6 changed files with 41 additions and 28 deletions

View File

@ -37,7 +37,7 @@ class Betfair(HandHistoryConverter):
# Static regexes
re_GameInfo = re.compile("^(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAME>(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<HID>[0-9]+) \*\*\*\*\*\n(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>(Texas Hold\'em|Omaha Hi|Razz)) - (?P<DATETIME>[a-zA-Z]+, [a-zA-Z]+ \d+, \d\d:\d\d:\d\d GMT \d\d\d\d)\nTable (?P<TABLE>[ a-zA-Z0-9]+) \d-max \(Real Money\)\nSeat (?P<BUTTON>[0-9]+)", re.MULTILINE)
re_HandInfo = re.compile("\*\*\*\*\* Betfair Poker Hand History for Game (?P<HID>[0-9]+) \*\*\*\*\*\n(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>(Texas Hold\'em|Omaha|Razz)) - (?P<DATETIME>[a-zA-Z]+, [a-zA-Z]+ \d+, \d\d:\d\d:\d\d GMT \d\d\d\d)\nTable (?P<TABLE>[ a-zA-Z0-9]+) \d-max \(Real Money\)\nSeat (?P<BUTTON>[0-9]+)", re.MULTILINE)
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
re_PlayerInfo = re.compile("Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*)\s\(\s(\$(?P<CASH>[.0-9]+)) \)")
re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
@ -107,7 +107,6 @@ class Betfair(HandHistoryConverter):
if(m == None):
log.error(_("Didn't match re_HandInfo"))
raise FpdbParseError(_("No match in readHandInfo."))
print "DEBUG: got this far!"
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
hand.handid = m.group('HID')
hand.tablename = m.group('TABLE')

View File

@ -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):

View File

@ -262,9 +262,16 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
self.obs = m.sub('', self.obs)
if self.obs is None or self.obs == "":
log.info(_("Read no hands."))
log.error(_("Read no hands."))
return []
return re.split(self.re_SplitHands, self.obs)
handlist = re.split(self.re_SplitHands, self.obs)
# Some HH formats leave dangling text after the split
# ie. </game> (split) </session>EOL
# Remove this dangler if less than 50 characters and warn in the log
if len(handlist[-1]) <= 50:
handlist.pop()
log.warn(_("Removing text < 50 characters"))
return handlist
def processHand(self, handText):
gametype = self.determineGameType(handText)

View File

@ -52,15 +52,15 @@ 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'),
# '5 Card Draw' : ('draw','fivedraw')
'FIVE_CARD_DRAW' : ('draw','fivedraw')
}
# Static regexes
@ -88,7 +88,7 @@ class OnGame(HandHistoryConverter):
Table:\s(?P<TABLE>[\'\w\s]+)\s\[\d+\]\s\(
(
(?P<LIMIT>NO_LIMIT|Limit|LIMIT|Pot\sLimit)\s
(?P<GAME>TEXAS_HOLDEM|RAZZ)\s
(?P<GAME>TEXAS_HOLDEM|OMAHA_HI|SEVEN_CARD_STUD|SEVEN_CARD_STUD_HI_LO|RAZZ|FIVE_CARD_DRAW)\s
(%(LS)s)?(?P<SB>[.0-9]+)/
(%(LS)s)?(?P<BB>[.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):
@ -239,18 +240,24 @@ 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<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', 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:
if hand.gametype['base'] in ("hold"):
m = re.search(r"pocket cards(?P<PREFLOP>.+(?= Dealing flop )|.+(?=Summary))"
r"( Dealing flop (?P<FLOP>\[\S\S, \S\S, \S\S\].+(?= Dealing turn)|.+(?=Summary)))?"
r"( Dealing turn (?P<TURN>\[\S\S\].+(?= Dealing river)|.+(?=Summary)))?"
r"( Dealing river (?P<RIVER>\[\S\S\].+(?=Summary)))?", hand.handText, re.DOTALL)
elif hand.gametype['base'] in ("stud"):
m = re.search(r"(?P<ANTES>.+(?=Dealing pocket cards)|.+)"
r"(Dealing pocket cards(?P<THIRD>.+(?=Dealing 4th street)|.+))?"
r"(Dealing 4th street(?P<FOURTH>.+(?=Dealing 5th street)|.+))?"
r"(Dealing 5th street(?P<FIFTH>.+(?=Dealing 6th street)|.+))?"
r"(Dealing 6th street(?P<SIXTH>.+(?=Dealing river)|.+))?"
r"(Dealing river(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
elif hand.gametype['base'] in ("draw"):
m = re.search(r"(?P<PREDEAL>.+(?=Dealing pocket cards)|.+)"
r"(Dealing pocket cards(?P<DEAL>.+(?=\*\*\* FIRST DRAW \*\*\*)|.+))?"
r"(\*\*\* FIRST DRAW \*\*\*(?P<DRAWONE>.+(?=\*\*\* SECOND DRAW \*\*\*)|.+))?"
r"(\*\*\* SECOND DRAW \*\*\*(?P<DRAWTWO>.+(?=\*\*\* THIRD DRAW \*\*\*)|.+))?"
r"(\*\*\* THIRD DRAW \*\*\*(?P<DRAWTHREE>.+))?", hand.handText,re.DOTALL)
hand.addStreets(m)

View File

@ -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,

View File

@ -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)