2010-10-29 01:52:33 +02:00
|
|
|
|
#!/usr/bin/env python
|
2009-03-06 19:10:04 +01:00
|
|
|
|
# -*- coding: utf-8 -*-
|
2009-03-10 00:03:17 +01:00
|
|
|
|
#
|
2011-03-10 06:16:31 +01:00
|
|
|
|
# Copyright 2008-2011, Carl Gherardi
|
2010-01-29 23:44:58 +01:00
|
|
|
|
#
|
2008-11-07 09:47:00 +01:00
|
|
|
|
# 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.
|
2010-01-29 23:44:58 +01:00
|
|
|
|
#
|
2008-11-07 09:47:00 +01:00
|
|
|
|
# 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.
|
2009-03-08 06:09:16 +01:00
|
|
|
|
#
|
2008-11-07 09:47:00 +01:00
|
|
|
|
# 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
|
|
|
|
|
########################################################################
|
|
|
|
|
|
2010-09-22 18:10:32 +02:00
|
|
|
|
import L10n
|
|
|
|
|
_ = L10n.get_translation()
|
|
|
|
|
|
2008-11-11 09:54:24 +01:00
|
|
|
|
import sys
|
2009-03-04 17:46:01 +01:00
|
|
|
|
import logging
|
2008-11-09 12:57:58 +01:00
|
|
|
|
from HandHistoryConverter import *
|
|
|
|
|
|
2009-02-22 10:07:11 +01:00
|
|
|
|
# Class for converting Everleaf HH format.
|
2008-11-09 12:57:58 +01:00
|
|
|
|
|
2008-11-07 11:19:18 +01:00
|
|
|
|
class Everleaf(HandHistoryConverter):
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-08-09 16:19:43 +02:00
|
|
|
|
sitename = 'Everleaf'
|
|
|
|
|
filetype = "text"
|
|
|
|
|
codepage = "cp1252"
|
|
|
|
|
siteId = 3 # Needs to match id entry in Sites database
|
|
|
|
|
|
2009-02-25 15:35:28 +01:00
|
|
|
|
# Static regexes
|
2009-03-31 08:44:19 +02:00
|
|
|
|
re_SplitHands = re.compile(r"\n\n\n+")
|
|
|
|
|
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
2010-07-31 18:25:01 +02:00
|
|
|
|
re_GameInfo = re.compile(ur"^(Blinds )?(?P<CURRENCY>[$€]?)(?P<SB>[.0-9]+)/[$€]?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
2010-07-29 23:52:19 +02:00
|
|
|
|
#re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
|
|
|
|
re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?P<CURRENCY>[$€])?(?P<SB>[.0-9]+)/(?:[$€])?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
|
2010-07-31 23:24:06 +02:00
|
|
|
|
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button$", re.MULTILINE)
|
|
|
|
|
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+([$€]? (?P<CASH>[.0-9]+) (USD|EURO|Chips)|new player|All-in) \)$", re.MULTILINE)
|
2009-03-10 00:03:17 +01:00
|
|
|
|
re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
|
2010-02-01 14:51:06 +01:00
|
|
|
|
re_TourneyInfoFromFilename = re.compile(ur".*TID_(?P<TOURNO>[0-9]+)-(?P<TABLE>[0-9]+)\.txt")
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
|
|
|
|
|
2009-03-08 06:09:16 +01:00
|
|
|
|
def compilePlayerRegexs(self, hand):
|
2009-03-06 19:10:04 +01:00
|
|
|
|
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)
|
2010-07-31 23:24:06 +02:00
|
|
|
|
self.re_PostSB = re.compile(ur"^%s: posts small blind \[[$€]? (?P<SB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
|
|
|
|
self.re_PostBB = re.compile(ur"^%s: posts big blind \[[$€]? (?P<BB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
|
|
|
|
self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[[$€]? (?P<SBBB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
|
|
|
|
self.re_Antes = re.compile(ur"^%s: posts ante \[[$€]? (?P<ANTE>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
2010-07-31 18:25:01 +02:00
|
|
|
|
self.re_BringIn = re.compile(ur"^%s posts bring-in [$€]? (?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
|
2010-07-31 23:24:06 +02:00
|
|
|
|
self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P<CARDS>.*) \]$" % player_re, re.MULTILINE)
|
2010-07-29 23:52:19 +02:00
|
|
|
|
# ^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.,\d]+) (USD|EURO|Chips)\])?
|
|
|
|
|
self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:[$€]?) (?P<BET>[.,\d]+)\s?(USD|EURO|Chips|)\])?" % player_re, re.MULTILINE)
|
2010-08-02 22:47:32 +02:00
|
|
|
|
self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
2010-07-29 23:52:19 +02:00
|
|
|
|
self.re_CollectPot = re.compile(ur"^%s wins (?:[$€]?)\s?(?P<POT>[.\d]+) (USD|EURO|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
2009-03-10 17:52:18 +01:00
|
|
|
|
self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE)
|
2008-12-06 15:15:41 +01:00
|
|
|
|
|
|
|
|
|
def readSupportedGames(self):
|
2010-10-07 14:34:36 +02:00
|
|
|
|
return [
|
|
|
|
|
["ring", "hold", "nl"],
|
2009-02-23 13:56:33 +01:00
|
|
|
|
["ring", "hold", "pl"],
|
2009-03-02 16:10:15 +01:00
|
|
|
|
["ring", "hold", "fl"],
|
2010-10-07 14:34:36 +02:00
|
|
|
|
["ring", "stud", "fl"],
|
|
|
|
|
#["ring", "omahahi", "pl"],
|
|
|
|
|
#["ring", "omahahilo", "pl"],
|
2010-10-07 14:13:21 +02:00
|
|
|
|
["tour", "hold", "nl"],
|
2010-10-07 14:34:36 +02:00
|
|
|
|
["tour", "hold", "fl"],
|
|
|
|
|
["tour", "hold", "pl"]
|
2009-02-22 10:21:49 +01:00
|
|
|
|
]
|
2008-12-06 15:15:41 +01:00
|
|
|
|
|
2009-03-04 16:10:08 +01:00
|
|
|
|
def determineGameType(self, handText):
|
2009-03-10 00:03:17 +01:00
|
|
|
|
"""return dict with keys/values:
|
|
|
|
|
'type' in ('ring', 'tour')
|
|
|
|
|
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
|
|
|
|
'base' in ('hold', 'stud', 'draw')
|
|
|
|
|
'category' in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
|
|
|
|
|
'hilo' in ('h','l','s')
|
|
|
|
|
'smallBlind' int?
|
|
|
|
|
'bigBlind' int?
|
|
|
|
|
'smallBet'
|
|
|
|
|
'bigBet'
|
|
|
|
|
'currency' in ('USD', 'EUR', 'T$', <countrycode>)
|
|
|
|
|
or None if we fail to get the info """
|
|
|
|
|
#(TODO: which parts are optional/required?)
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
|
# Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
|
|
|
|
# Blinds $0.05/$0.10 NL Hold'em - 2009/02/21 - 11:21:57
|
|
|
|
|
# $0.25/$0.50 7 Card Stud - 2008/12/05 - 21:43:59
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
|
# Tourney:
|
|
|
|
|
# Everleaf Gaming Game #75065769
|
|
|
|
|
# ***** Hand history for game #75065769 *****
|
|
|
|
|
# Blinds 10/20 NL Hold'em - 2009/02/25 - 17:30:32
|
|
|
|
|
# Table 2
|
|
|
|
|
info = {'type':'ring'}
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-03-06 19:10:04 +01:00
|
|
|
|
m = self.re_GameInfo.search(handText)
|
2009-03-11 15:05:38 +01:00
|
|
|
|
if not m:
|
2010-12-10 10:53:59 +01:00
|
|
|
|
tmp = handText[0:100]
|
2011-03-10 04:29:16 +01:00
|
|
|
|
log.error(_("Unable to recognise gametype from: '%s'") % tmp)
|
2010-12-10 10:53:59 +01:00
|
|
|
|
log.error(_("determineGameType: Raising FpdbParseError"))
|
|
|
|
|
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
|
mg = m.groupdict()
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-03-10 00:03:17 +01:00
|
|
|
|
# translations from captured groups to our info strings
|
2009-03-11 15:05:38 +01:00
|
|
|
|
limits = { 'NL':'nl', 'PL':'pl', '':'fl' }
|
2009-03-10 00:03:17 +01:00
|
|
|
|
games = { # base, category
|
2010-01-29 23:44:58 +01:00
|
|
|
|
"Hold'em" : ('hold','holdem'),
|
|
|
|
|
'Omaha' : ('hold','omahahi'),
|
|
|
|
|
'Razz' : ('stud','razz'),
|
2009-03-10 00:03:17 +01:00
|
|
|
|
'7 Card Stud' : ('stud','studhi')
|
|
|
|
|
}
|
2010-07-29 23:52:19 +02:00
|
|
|
|
currencies = { u'€':'EUR', '$':'USD', '':'T$'}
|
2009-03-10 00:03:17 +01:00
|
|
|
|
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']]
|
2009-03-13 10:45:15 +01:00
|
|
|
|
if info['currency'] == 'T$':
|
|
|
|
|
info['type'] = 'tour'
|
2009-03-10 00:03:17 +01:00
|
|
|
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2009-03-06 19:10:04 +01:00
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
2008-12-06 15:15:41 +01:00
|
|
|
|
def readHandInfo(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
|
m = self.re_HandInfo.search(hand.handText)
|
2009-02-21 14:31:57 +01:00
|
|
|
|
if(m == None):
|
2011-03-12 21:47:14 +01:00
|
|
|
|
logging.info(_("No match in readHandInfo: '%s'") % hand.handText[0:100])
|
2009-03-06 19:10:04 +01:00
|
|
|
|
logging.info(hand.handText)
|
2009-03-04 17:46:01 +01:00
|
|
|
|
return None
|
|
|
|
|
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
2009-03-04 15:29:13 +01:00
|
|
|
|
hand.handid = m.group('HID')
|
2008-12-06 15:15:41 +01:00
|
|
|
|
hand.tablename = m.group('TABLE')
|
2010-11-08 02:12:21 +01:00
|
|
|
|
hand.maxseats = 4 # assume 4-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
|
2010-07-29 23:52:19 +02:00
|
|
|
|
|
|
|
|
|
currencies = { u'€':'EUR', '$':'USD', '':'T$', None:'T$' }
|
|
|
|
|
mg = m.groupdict()
|
|
|
|
|
hand.gametype['currency'] = currencies[mg['CURRENCY']]
|
|
|
|
|
|
2009-03-04 15:29:13 +01:00
|
|
|
|
|
2010-02-01 14:51:06 +01:00
|
|
|
|
t = self.re_TourneyInfoFromFilename.search(self.in_path)
|
|
|
|
|
if t:
|
|
|
|
|
tourno = t.group('TOURNO')
|
|
|
|
|
hand.tourNo = tourno
|
|
|
|
|
hand.tablename = t.group('TABLE')
|
2010-07-23 04:03:35 +02:00
|
|
|
|
#TODO we should fetch info including buyincurrency, buyin and fee from URL:
|
|
|
|
|
# https://www.poker4ever.com/tourney/%TOURNEY_NUMBER%
|
2010-02-01 14:51:06 +01:00
|
|
|
|
|
2009-03-04 15:29:13 +01:00
|
|
|
|
# Believe Everleaf time is GMT/UTC, no transation necessary
|
|
|
|
|
# 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: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
2010-07-08 17:30:02 +02:00
|
|
|
|
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
2009-03-04 15:29:13 +01:00
|
|
|
|
return
|
2008-11-10 14:02:56 +01:00
|
|
|
|
|
2008-12-06 15:15:41 +01:00
|
|
|
|
def readPlayerStacks(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
2008-12-06 15:15:41 +01:00
|
|
|
|
for a in m:
|
2009-02-25 12:01:44 +01:00
|
|
|
|
seatnum = int(a.group('SEAT'))
|
|
|
|
|
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
2010-10-29 01:52:33 +02:00
|
|
|
|
if seatnum > 8:
|
|
|
|
|
hand.maxseats = 10 # they added 8-seat games now
|
|
|
|
|
elif seatnum > 6:
|
|
|
|
|
hand.maxseats = 8 # everleaf currently does 2/6/10 games, so if seats > 6 are in use, it must be 10-max.
|
2009-02-25 12:01:44 +01:00
|
|
|
|
# TODO: implement lookup list by table-name to determine maxes, then fall back to 6 default/10 here, if there's no entry in the list?
|
2010-11-08 02:08:56 +01:00
|
|
|
|
elif seatnum > 4:
|
|
|
|
|
hand.maxseats = 6 # they added 4-seat games too!
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
|
|
|
|
|
2008-12-06 15:15:41 +01:00
|
|
|
|
def markStreets(self, hand):
|
|
|
|
|
# PREFLOP = ** Dealing down cards **
|
2008-12-10 00:30:58 +01:00
|
|
|
|
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
2009-03-04 16:10:08 +01:00
|
|
|
|
#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.handText,re.DOTALL)
|
2009-03-10 18:25:49 +01:00
|
|
|
|
if hand.gametype['base'] == 'hold':
|
|
|
|
|
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
2008-12-16 18:14:37 +01:00
|
|
|
|
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
|
|
|
|
|
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
|
2009-03-04 16:10:08 +01:00
|
|
|
|
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.handText,re.DOTALL)
|
2009-03-10 18:25:49 +01:00
|
|
|
|
elif hand.gametype['base'] == 'stud':
|
|
|
|
|
m = re.search(r"(?P<ANTES>.+(?=\*\* Dealing down cards \*\*)|.+)"
|
|
|
|
|
r"(\*\* Dealing down 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)
|
2008-12-14 23:05:51 +01:00
|
|
|
|
hand.addStreets(m)
|
2009-03-04 15:29:13 +01:00
|
|
|
|
|
2008-12-16 18:14:37 +01:00
|
|
|
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
2009-03-02 00:22:47 +01:00
|
|
|
|
# If this has been called, street is a street which gets dealt community cards by type hand
|
|
|
|
|
# but it might be worth checking somehow.
|
|
|
|
|
# if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
2009-03-03 19:45:02 +01:00
|
|
|
|
logging.debug("readCommunityCards (%s)" % street)
|
2009-03-02 00:22:47 +01:00
|
|
|
|
m = self.re_Board.search(hand.streets[street])
|
|
|
|
|
cards = m.group('CARDS')
|
|
|
|
|
cards = [card.strip() for card in cards.split(',')]
|
2009-03-03 19:45:02 +01:00
|
|
|
|
hand.setCommunityCards(street=street, cards=cards)
|
2008-12-08 07:23:50 +01:00
|
|
|
|
|
2009-03-10 18:25:49 +01:00
|
|
|
|
def readAntes(self, hand):
|
2010-08-29 21:22:34 +02:00
|
|
|
|
logging.debug(_("reading antes"))
|
2009-03-10 18:25:49 +01:00
|
|
|
|
m = self.re_Antes.finditer(hand.handText)
|
|
|
|
|
for player in m:
|
|
|
|
|
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
|
|
|
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
|
|
|
|
|
|
|
|
|
def readBringIn(self, hand):
|
|
|
|
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
|
|
|
|
if m:
|
2010-01-29 23:44:58 +01:00
|
|
|
|
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
2009-03-10 18:25:49 +01:00
|
|
|
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
|
|
|
|
else:
|
2010-08-29 21:22:34 +02:00
|
|
|
|
logging.warning(_("No bringin found."))
|
2009-03-10 18:25:49 +01:00
|
|
|
|
|
2008-12-06 15:15:41 +01:00
|
|
|
|
def readBlinds(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
|
m = self.re_PostSB.search(hand.handText)
|
|
|
|
|
if m is not None:
|
2008-12-14 23:05:51 +01:00
|
|
|
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
2009-03-04 16:10:08 +01:00
|
|
|
|
else:
|
2010-08-29 21:22:34 +02:00
|
|
|
|
logging.debug(_("No small blind"))
|
2008-12-14 23:05:51 +01:00
|
|
|
|
hand.addBlind(None, None, None)
|
2009-03-04 16:10:08 +01:00
|
|
|
|
for a in self.re_PostBB.finditer(hand.handText):
|
2008-12-14 23:05:51 +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):
|
2009-02-21 15:26:37 +01:00
|
|
|
|
hand.addBlind(a.group('PNAME'), 'both', a.group('SBBB'))
|
2008-12-06 15:15:41 +01:00
|
|
|
|
|
2009-02-25 15:35:28 +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-25 15:35:28 +01:00
|
|
|
|
|
2008-12-06 15:15:41 +01:00
|
|
|
|
def readHeroCards(self, hand):
|
2009-03-04 16:10:08 +01:00
|
|
|
|
m = self.re_HeroCards.search(hand.handText)
|
|
|
|
|
if m:
|
2008-12-06 15:15:41 +01:00
|
|
|
|
hand.hero = m.group('PNAME')
|
2009-03-04 15:29:13 +01:00
|
|
|
|
# "2c, qh" -> ["2c","qc"]
|
2008-12-16 00:56:19 +01:00
|
|
|
|
# Also works with Omaha hands.
|
|
|
|
|
cards = m.group('CARDS')
|
2009-03-07 15:35:52 +01:00
|
|
|
|
cards = [card.strip() for card in cards.split(',')]
|
2009-07-25 17:34:13 +02:00
|
|
|
|
# hand.addHoleCards(cards, m.group('PNAME'))
|
|
|
|
|
hand.addHoleCards('PREFLOP', hand.hero, closed=cards, shown=False, mucked=False, dealt=True)
|
|
|
|
|
|
2009-03-04 16:10:08 +01:00
|
|
|
|
else:
|
|
|
|
|
#Not involved in hand
|
|
|
|
|
hand.involved = False
|
2008-12-06 15:15:41 +01:00
|
|
|
|
|
2009-07-25 17:34:13 +02:00
|
|
|
|
|
2009-03-10 18:25:49 +01:00
|
|
|
|
def readStudPlayerCards(self, hand, street):
|
|
|
|
|
# lol. see Plymouth.txt
|
2010-08-29 21:22:34 +02:00
|
|
|
|
logging.warning(_("Everleaf readStudPlayerCards is only a stub."))
|
2009-03-10 18:25:49 +01:00
|
|
|
|
#~ if street in ('THIRD', 'FOURTH', 'FIFTH', 'SIXTH'):
|
|
|
|
|
#~ hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = [], open = [])
|
|
|
|
|
|
2008-12-06 15:15:41 +01:00
|
|
|
|
|
|
|
|
|
def readAction(self, hand, street):
|
2009-03-04 17:46:01 +01:00
|
|
|
|
logging.debug("readAction (%s)" % street)
|
2009-03-07 15:35:52 +01:00
|
|
|
|
m = self.re_Action.finditer(hand.streets[street])
|
2008-12-06 15:15:41 +01:00
|
|
|
|
for action in m:
|
2009-03-10 19:20:14 +01:00
|
|
|
|
logging.debug("%s %s" % (action.group('ATYPE'), action.groupdict()))
|
2008-12-10 01:48:45 +01:00
|
|
|
|
if action.group('ATYPE') == ' raises':
|
2008-12-17 12:57:06 +01:00
|
|
|
|
hand.addCallandRaise( street, action.group('PNAME'), action.group('BET') )
|
2008-12-10 01:48:45 +01:00
|
|
|
|
elif action.group('ATYPE') == ' calls':
|
2008-12-06 15:15:41 +01:00
|
|
|
|
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
2008-12-10 01:48:45 +01:00
|
|
|
|
elif action.group('ATYPE') == ': bets':
|
2008-12-06 15:15:41 +01:00
|
|
|
|
hand.addBet( street, action.group('PNAME'), action.group('BET') )
|
2008-12-10 01:48:45 +01:00
|
|
|
|
elif action.group('ATYPE') == ' folds':
|
|
|
|
|
hand.addFold( street, action.group('PNAME'))
|
|
|
|
|
elif action.group('ATYPE') == ' checks':
|
|
|
|
|
hand.addCheck( street, action.group('PNAME'))
|
2009-03-10 19:20:14 +01:00
|
|
|
|
elif action.group('ATYPE') == ' complete to':
|
2009-03-11 19:40:17 +01:00
|
|
|
|
hand.addComplete( street, action.group('PNAME'), action.group('BET'))
|
2008-12-06 15:15:41 +01:00
|
|
|
|
else:
|
2011-03-10 04:15:53 +01:00
|
|
|
|
logging.debug(_("Unimplemented readAction: %s %s") % (action.group('PNAME'),action.group('ATYPE')))
|
2008-12-06 15:15:41 +01:00
|
|
|
|
|
|
|
|
|
|
2008-12-08 07:23:50 +01:00
|
|
|
|
def readShowdownActions(self, hand):
|
2009-02-26 17:04:08 +01:00
|
|
|
|
"""Reads lines where holecards are reported in a showdown"""
|
2009-03-04 17:46:01 +01:00
|
|
|
|
logging.debug("readShowdownActions")
|
2009-03-04 16:10:08 +01:00
|
|
|
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
2008-12-16 00:56:19 +01:00
|
|
|
|
cards = shows.group('CARDS')
|
2009-02-26 17:04:08 +01:00
|
|
|
|
cards = cards.split(', ')
|
2011-03-10 04:15:53 +01:00
|
|
|
|
logging.debug(_("readShowdownActions %s %s") % (cards, shows.group('PNAME')))
|
2008-12-10 17:30:57 +01:00
|
|
|
|
hand.addShownCards(cards, shows.group('PNAME'))
|
|
|
|
|
|
2009-03-03 19:45:02 +01:00
|
|
|
|
|
2008-12-09 16:32:37 +01:00
|
|
|
|
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:14:37 +01:00
|
|
|
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
|
|
|
|
|
|
|
|
|
def readShownCards(self,hand):
|
2009-02-26 17:04:08 +01:00
|
|
|
|
"""Reads lines where hole & board cards are mixed to form a hand (summary lines)"""
|
2009-03-04 16:10:08 +01:00
|
|
|
|
for m in self.re_CollectPot.finditer(hand.handText):
|
2008-12-16 00:56:19 +01:00
|
|
|
|
if m.group('CARDS') is not None:
|
|
|
|
|
cards = m.group('CARDS')
|
2009-02-26 17:04:08 +01:00
|
|
|
|
cards = cards.split(', ')
|
2009-03-04 17:46:01 +01:00
|
|
|
|
player = m.group('PNAME')
|
|
|
|
|
logging.debug("readShownCards %s cards=%s" % (player, cards))
|
2009-07-25 17:34:13 +02:00
|
|
|
|
# hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
|
|
|
|
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
2008-12-16 18:14:37 +01:00
|
|
|
|
|
2010-01-29 23:44:58 +01:00
|
|
|
|
@staticmethod
|
|
|
|
|
def getTableTitleRe(type, table_name=None, tournament = None, table_number=None):
|
2010-02-01 14:51:06 +01:00
|
|
|
|
if tournament:
|
|
|
|
|
return "%s - Tournament ID: %s -" % (table_number, tournament)
|
|
|
|
|
return "%s -" % (table_name)
|
2010-01-29 23:44:58 +01:00
|
|
|
|
|
2008-12-14 20:25:04 +01:00
|
|
|
|
|
2008-12-08 07:23:50 +01:00
|
|
|
|
|
2008-11-07 11:19:18 +01:00
|
|
|
|
if __name__ == "__main__":
|
2009-02-26 01:59:36 +01:00
|
|
|
|
parser = OptionParser()
|
2010-08-29 21:22:34 +02:00
|
|
|
|
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="-")
|
|
|
|
|
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)
|
2009-02-26 01:59:36 +01:00
|
|
|
|
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-10-29 09:37:33 +01:00
|
|
|
|
e = Everleaf(in_path = options.ipath, out_path = options.opath, follow = options.follow, autostart=True)
|