2008-12-16 15:45:58 +01:00
|
|
|
#!/usr/bin/env python
|
2009-03-10 00:03:17 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2008-12-16 15:45:58 +01:00
|
|
|
# Copyright 2008, Carl Gherardi
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
import sys
|
2009-03-04 17:46:01 +01:00
|
|
|
import logging
|
2008-12-16 15:45:58 +01:00
|
|
|
from HandHistoryConverter import *
|
|
|
|
|
2009-03-13 21:00:12 +01:00
|
|
|
# Fulltilt HH Format converter
|
2008-12-16 15:45:58 +01:00
|
|
|
|
2009-03-13 21:00:12 +01:00
|
|
|
class Fulltilt(HandHistoryConverter):
|
2009-02-25 15:35:28 +01:00
|
|
|
|
|
|
|
# Static regexes
|
2009-03-10 00:03:17 +01:00
|
|
|
re_GameInfo = re.compile('- (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<LIMIT>(No Limit|Pot Limit|Limit))? (?P<GAME>(Hold\'em|Omaha Hi|Razz))')
|
2009-02-25 15:35:28 +01:00
|
|
|
re_SplitHands = re.compile(r"\n\n+")
|
|
|
|
re_HandInfo = re.compile('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[- a-zA-Z]+) (\((?P<TABLEATTRIBUTES>.+)\) )?- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<GAMETYPE>[a-zA-Z\' ]+) - (?P<DATETIME>.*)')
|
2009-02-26 17:26:50 +01:00
|
|
|
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
2009-02-25 15:35:28 +01:00
|
|
|
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[.0-9]+)\)\n')
|
|
|
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
|
|
|
|
2009-03-06 19:10:04 +01:00
|
|
|
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True):
|
2009-03-02 22:48:30 +01:00
|
|
|
"""\
|
|
|
|
in_path (default '-' = sys.stdin)
|
|
|
|
out_path (default '-' = sys.stdout)
|
|
|
|
follow : whether to tail -f the input"""
|
2009-03-13 21:00:12 +01:00
|
|
|
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Fulltilt", follow=follow)
|
|
|
|
logging.info("Initialising Fulltilt converter class")
|
2009-03-02 22:48:30 +01:00
|
|
|
self.filetype = "text"
|
|
|
|
self.codepage = "cp1252"
|
2009-03-06 19:10:04 +01:00
|
|
|
if autostart:
|
|
|
|
self.start()
|
2009-02-22 04:42:16 +01:00
|
|
|
|
2009-03-02 22:48:30 +01:00
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
def compilePlayerRegexs(self, hand):
|
|
|
|
players = set([player[1] for player in hand.players])
|
2009-03-07 10:06:52 +01:00
|
|
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
|
|
|
# we need to recompile the player regexs.
|
|
|
|
self.compiledPlayers = players
|
|
|
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
|
|
|
logging.debug("player_re: " + player_re)
|
|
|
|
self.re_PostSB = re.compile(r"^%s posts the small blind of \$?(?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
|
|
self.re_PostBB = re.compile(r"^%s posts (the big blind of )?\$?(?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
|
|
self.re_Antes = re.compile(r"^%s antes \$?(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
|
|
|
self.re_BringIn = re.compile(r"^%s brings in for \$?(?P<BRINGIN>[.0-9]+)" % player_re, re.MULTILINE)
|
|
|
|
self.re_PostBoth = re.compile(r"^%s posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
2009-03-02 22:48:30 +01:00
|
|
|
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
2009-03-11 17:51:58 +01:00
|
|
|
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| completes it to| calls| folds)(\s\$(?P<BET>[.\d]+))?" % player_re, re.MULTILINE)
|
2009-03-07 10:06:52 +01:00
|
|
|
self.re_ShowdownAction = re.compile(r"^%s shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
|
|
|
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)" % player_re, re.MULTILINE)
|
|
|
|
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
|
|
|
|
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
2009-02-22 04:42:16 +01:00
|
|
|
|
2008-12-16 15:45:58 +01:00
|
|
|
|
|
|
|
def readSupportedGames(self):
|
2009-02-22 10:07:11 +01:00
|
|
|
return [["ring", "hold", "nl"],
|
2009-02-23 11:24:21 +01:00
|
|
|
["ring", "hold", "pl"],
|
2009-03-12 18:21:31 +01:00
|
|
|
["ring", "hold", "fl"],
|
2009-03-12 18:18:34 +01:00
|
|
|
["ring", "stud", "fl"],
|
2009-02-22 10:07:11 +01:00
|
|
|
["ring", "omaha", "pl"]
|
|
|
|
]
|
2008-12-16 15:45:58 +01:00
|
|
|
|
2009-03-04 16:10:08 +01:00
|
|
|
def determineGameType(self, handText):
|
2009-02-22 10:07:11 +01:00
|
|
|
# Full Tilt Poker Game #10777181585: Table Deerfly (deep 6) - $0.01/$0.02 - Pot Limit Omaha Hi - 2:24:44 ET - 2009/02/22
|
|
|
|
# Full Tilt Poker Game #10773265574: Table Butte (6 max) - $0.01/$0.02 - Pot Limit Hold'em - 21:33:46 ET - 2009/02/21
|
|
|
|
# Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09
|
2009-03-04 15:29:13 +01:00
|
|
|
# Full Tilt Poker Game #10809877615: Table Danville - $0.50/$1 Ante $0.10 - Limit Razz - 21:47:27 ET - 2009/02/23
|
2009-03-10 00:03:17 +01:00
|
|
|
info = {'type':'ring'}
|
|
|
|
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_GameInfo.search(handText)
|
2009-03-10 00:03:17 +01:00
|
|
|
if not m:
|
|
|
|
return None
|
2009-02-22 10:07:11 +01:00
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
mg = m.groupdict()
|
|
|
|
|
|
|
|
# translations from captured groups to our info strings
|
|
|
|
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' }
|
|
|
|
games = { # base, category
|
|
|
|
"Hold'em" : ('hold','holdem'),
|
|
|
|
'Omaha Hi' : ('hold','omahahi'),
|
|
|
|
'Razz' : ('stud','razz'),
|
|
|
|
'7 Card Stud' : ('stud','studhi')
|
|
|
|
}
|
|
|
|
currencies = { u' €':'EUR', '$':'USD', '':'T$' }
|
|
|
|
if 'LIMIT' in mg:
|
|
|
|
info['limitType'] = limits[mg['LIMIT']]
|
|
|
|
if 'GAME' in mg:
|
|
|
|
(info['base'], info['category']) = games[mg['GAME']]
|
|
|
|
if 'SB' in mg:
|
|
|
|
info['sb'] = mg['SB']
|
|
|
|
if 'BB' in mg:
|
|
|
|
info['bb'] = mg['BB']
|
|
|
|
if 'CURRENCY' in mg:
|
|
|
|
info['currency'] = currencies[mg['CURRENCY']]
|
|
|
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
2008-12-16 15:45:58 +01:00
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
return info
|
2008-12-16 15:45:58 +01:00
|
|
|
|
|
|
|
def readHandInfo(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
2009-03-18 17:52:18 +01:00
|
|
|
|
|
|
|
if(m == None):
|
|
|
|
logging.info("Didn't match re_HandInfo")
|
|
|
|
logging.info(hand.handText)
|
|
|
|
return None
|
|
|
|
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.handid = m.group('HID')
|
|
|
|
hand.tablename = m.group('TABLE')
|
2008-12-17 00:23:33 +01:00
|
|
|
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
2009-03-18 17:52:18 +01:00
|
|
|
hand.maxseats = 8 # assume 8-max until we see otherwise
|
2009-03-21 17:31:36 +01:00
|
|
|
if m.group('TABLEATTRIBUTES'):
|
|
|
|
m2 = re.search("(\d+) max", m.group('TABLEATTRIBUTES'))
|
|
|
|
hand.maxseats = int(m2.group(1))
|
2008-12-16 15:45:58 +01:00
|
|
|
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
2009-03-04 15:29:13 +01:00
|
|
|
# m.group('SB')
|
|
|
|
# m.group('BB')
|
|
|
|
# m.group('GAMETYPE')
|
2008-12-16 15:45:58 +01:00
|
|
|
|
|
|
|
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
|
|
|
# or : 2008/11/07 12:38:49 ET
|
|
|
|
# Not getting it in my HH files yet, so using
|
|
|
|
# 2008/11/10 3:58:52 ET
|
|
|
|
#TODO: Do conversion from GMT to ET
|
|
|
|
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
2008-12-17 00:23:33 +01:00
|
|
|
#hand.starttime = "%d/%02d/%02d %d:%02d:%02d ET" %(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')),
|
|
|
|
##int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC')))
|
2008-12-16 15:45:58 +01:00
|
|
|
#FIXME: hand.buttonpos = int(m.group('BUTTON'))
|
|
|
|
|
|
|
|
def readPlayerStacks(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
2008-12-16 15:45:58 +01:00
|
|
|
players = []
|
|
|
|
for a in m:
|
|
|
|
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
|
|
|
|
|
|
|
def markStreets(self, hand):
|
|
|
|
# PREFLOP = ** Dealing down cards **
|
|
|
|
|
2009-03-10 17:17:54 +01:00
|
|
|
if hand.gametype['base'] == 'hold':
|
2009-02-24 17:17:25 +01:00
|
|
|
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
|
2008-12-16 18:26:58 +01:00
|
|
|
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
|
|
|
|
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
2009-03-04 16:10:08 +01:00
|
|
|
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.handText,re.DOTALL)
|
2009-03-10 17:17:54 +01:00
|
|
|
elif hand.gametype['base'] == "stud": # or should this be gametype['category'] == 'razz'
|
2009-02-24 18:05:51 +01:00
|
|
|
m = re.search(r"(?P<ANTES>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
|
|
|
|
r"(\*\*\* 3RD STREET \*\*\*(?P<THIRD>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
|
|
|
|
r"(\*\*\* 4TH STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
|
|
|
|
r"(\*\*\* 5TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
|
|
|
|
r"(\*\*\* 6TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?"
|
2009-03-04 16:10:08 +01:00
|
|
|
r"(\*\*\* 7TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.addStreets(m)
|
|
|
|
|
2008-12-16 18:26:58 +01:00
|
|
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
|
|
|
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
2008-12-16 22:08:10 +01:00
|
|
|
#print "DEBUG readCommunityCards:", street, hand.streets.group(street)
|
2009-03-10 17:17:54 +01:00
|
|
|
m = self.re_Board.search(hand.streets[street])
|
2008-12-16 18:26:58 +01:00
|
|
|
hand.setCommunityCards(street, m.group('CARDS').split(' '))
|
|
|
|
|
2008-12-16 15:45:58 +01:00
|
|
|
|
|
|
|
def readBlinds(self, hand):
|
|
|
|
try:
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_PostSB.search(hand.handText)
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
|
|
|
except: # no small blind
|
|
|
|
hand.addBlind(None, None, None)
|
2009-03-04 16:10:08 +01:00
|
|
|
for a in self.re_PostBB.finditer(hand.handText):
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
2009-03-04 16:10:08 +01:00
|
|
|
for a in self.re_PostBoth.finditer(hand.handText):
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
|
|
|
|
2009-02-24 17:17:25 +01:00
|
|
|
def readAntes(self, hand):
|
2009-03-04 17:46:01 +01:00
|
|
|
logging.debug("reading antes")
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_Antes.finditer(hand.handText)
|
2009-02-25 16:45:46 +01:00
|
|
|
for player in m:
|
2009-03-04 17:46:01 +01:00
|
|
|
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
2009-02-25 16:45:46 +01:00
|
|
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
2009-02-24 17:17:25 +01:00
|
|
|
|
|
|
|
def readBringIn(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
2009-03-10 18:25:49 +01:00
|
|
|
if m:
|
|
|
|
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
|
|
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
|
|
|
else:
|
|
|
|
logging.warning("No bringin found")
|
2009-02-24 17:17:25 +01:00
|
|
|
|
|
|
|
def readButton(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
2009-02-24 17:17:25 +01:00
|
|
|
|
2008-12-16 15:45:58 +01:00
|
|
|
def readHeroCards(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
m = self.re_HeroCards.search(hand.handText)
|
2008-12-16 15:45:58 +01:00
|
|
|
if(m == None):
|
|
|
|
#Not involved in hand
|
|
|
|
hand.involved = False
|
|
|
|
else:
|
|
|
|
hand.hero = m.group('PNAME')
|
|
|
|
# "2c, qh" -> set(["2c","qc"])
|
|
|
|
# Also works with Omaha hands.
|
2009-03-06 02:24:38 +01:00
|
|
|
cards = m.group('NEWCARDS')
|
2009-03-07 15:35:52 +01:00
|
|
|
cards = [c.strip() for c in cards.split(' ')]
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.addHoleCards(cards, m.group('PNAME'))
|
|
|
|
|
2009-03-02 22:48:30 +01:00
|
|
|
def readStudPlayerCards(self, hand, street):
|
|
|
|
# This could be the most tricky one to get right.
|
|
|
|
# It looks for cards dealt in 'street',
|
|
|
|
# which may or may not be in the section of the hand designated 'street' by markStreets earlier.
|
|
|
|
# Here's an example at FTP of what 'THIRD' and 'FOURTH' look like to hero PokerAscetic
|
|
|
|
#
|
|
|
|
#"*** 3RD STREET ***
|
|
|
|
#Dealt to BFK23 [Th]
|
|
|
|
#Dealt to cutiepr1nnymaid [8c]
|
|
|
|
#Dealt to PokerAscetic [7c 8s] [3h]
|
|
|
|
#..."
|
|
|
|
#
|
|
|
|
#"*** 4TH STREET ***
|
|
|
|
#Dealt to cutiepr1nnymaid [8c] [2s]
|
|
|
|
#Dealt to PokerAscetic [7c 8s 3h] [5s]
|
|
|
|
#..."
|
|
|
|
#Note that hero's first two holecards are only reported at 3rd street as 'old' cards.
|
|
|
|
logging.debug("readStudPlayerCards")
|
|
|
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
2009-02-25 11:32:12 +01:00
|
|
|
for player in m:
|
2009-03-04 17:46:01 +01:00
|
|
|
logging.debug(player.groupdict())
|
2009-03-02 22:48:30 +01:00
|
|
|
(pname, oldcards, newcards) = (player.group('PNAME'), player.group('OLDCARDS'), player.group('NEWCARDS'))
|
|
|
|
if oldcards:
|
|
|
|
oldcards = [c.strip() for c in oldcards.split(' ')]
|
|
|
|
if newcards:
|
|
|
|
newcards = [c.strip() for c in newcards.split(' ')]
|
|
|
|
# options here:
|
|
|
|
# (1) we trust the hand will know what to do -- probably check that the old cards match what it already knows, and add the newcards to this street.
|
|
|
|
# (2) we're the experts at this particular history format and we know how we're going to be called (once for each street in Hand.streetList)
|
|
|
|
# so call addPlayerCards with the appropriate information.
|
|
|
|
# I favour (2) here but I'm afraid it is rather stud7-specific.
|
|
|
|
# in the following, the final list of cards will be in 'newcards' whilst if the first list exists (most of the time it does) it will be in 'oldcards'
|
|
|
|
if street=='ANTES':
|
|
|
|
return
|
|
|
|
elif street=='THIRD':
|
|
|
|
# we'll have observed hero holecards in CARDS and thirdstreet open cards in 'NEWCARDS'
|
|
|
|
# hero: [xx][o]
|
|
|
|
# others: [o]
|
|
|
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = oldcards, open = newcards)
|
|
|
|
elif street in ('FOURTH', 'FIFTH', 'SIXTH'):
|
|
|
|
# 4th:
|
|
|
|
# hero: [xxo] [o]
|
|
|
|
# others: [o] [o]
|
|
|
|
# 5th:
|
|
|
|
# hero: [xxoo] [o]
|
|
|
|
# others: [oo] [o]
|
|
|
|
# 6th:
|
|
|
|
# hero: [xxooo] [o]
|
|
|
|
# others: [ooo] [o]
|
|
|
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, open = newcards)
|
|
|
|
# we may additionally want to check the earlier streets tally with what we have but lets trust it for now.
|
|
|
|
elif street=='SEVENTH' and newcards:
|
|
|
|
# hero: [xxoooo] [x]
|
|
|
|
# others: not reported.
|
|
|
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = newcards)
|
2009-02-25 11:32:12 +01:00
|
|
|
|
2008-12-16 15:45:58 +01:00
|
|
|
def readAction(self, hand, street):
|
2009-03-07 15:35:52 +01:00
|
|
|
m = self.re_Action.finditer(hand.streets[street])
|
2008-12-16 15:45:58 +01:00
|
|
|
for action in m:
|
|
|
|
if action.group('ATYPE') == ' raises to':
|
|
|
|
hand.addRaiseTo( street, action.group('PNAME'), action.group('BET') )
|
2009-03-12 02:49:16 +01:00
|
|
|
elif action.group('ATYPE') == ' completes it to':
|
2009-03-11 17:51:58 +01:00
|
|
|
hand.addComplete( street, action.group('PNAME'), action.group('BET') )
|
2008-12-16 15:45:58 +01:00
|
|
|
elif action.group('ATYPE') == ' calls':
|
|
|
|
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
|
|
|
elif action.group('ATYPE') == ' bets':
|
|
|
|
hand.addBet( street, action.group('PNAME'), action.group('BET') )
|
|
|
|
elif action.group('ATYPE') == ' folds':
|
|
|
|
hand.addFold( street, action.group('PNAME'))
|
|
|
|
elif action.group('ATYPE') == ' checks':
|
|
|
|
hand.addCheck( street, action.group('PNAME'))
|
|
|
|
else:
|
2009-03-12 02:49:16 +01:00
|
|
|
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
2008-12-16 18:26:58 +01:00
|
|
|
|
2008-12-16 15:45:58 +01:00
|
|
|
|
|
|
|
def readShowdownActions(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
2008-12-16 15:45:58 +01:00
|
|
|
cards = shows.group('CARDS')
|
2009-03-02 16:10:15 +01:00
|
|
|
cards = cards.split(' ')
|
2008-12-16 15:45:58 +01:00
|
|
|
hand.addShownCards(cards, shows.group('PNAME'))
|
|
|
|
|
|
|
|
def readCollectPot(self,hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
for m in self.re_CollectPot.finditer(hand.handText):
|
2008-12-16 18:26:58 +01:00
|
|
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
|
|
|
|
|
|
|
def readShownCards(self,hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
for m in self.re_ShownCards.finditer(hand.handText):
|
2008-12-16 15:45:58 +01:00
|
|
|
if m.group('CARDS') is not None:
|
|
|
|
cards = m.group('CARDS')
|
2009-03-02 16:10:15 +01:00
|
|
|
cards = cards.split(' ')
|
2008-12-16 18:26:58 +01:00
|
|
|
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
2008-12-16 15:45:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2009-03-02 22:48:30 +01:00
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/fulltilt/razz/FT20090223 Danville - $0.50-$1 Ante $0.10 - Limit Razz.txt")
|
|
|
|
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
|
|
|
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
|
|
|
parser.add_option("-q", "--quiet",
|
|
|
|
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
|
|
|
parser.add_option("-v", "--verbose",
|
|
|
|
action="store_const", const=logging.INFO, dest="verbosity")
|
|
|
|
parser.add_option("--vv",
|
|
|
|
action="store_const", const=logging.DEBUG, dest="verbosity")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
LOG_FILENAME = './logging.out'
|
|
|
|
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
|
|
|
|
2009-03-13 21:00:12 +01:00
|
|
|
e = Fulltilt(in_path = options.ipath, out_path = options.opath, follow = options.follow)
|