Merge branch 'master' of git://github.com/grindi/fpdb-grindi
This commit is contained in:
commit
ec8cd9f785
|
@ -2,12 +2,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright 2008-2010, Carl Gherardi
|
# Copyright 2008-2010, Carl Gherardi
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -36,31 +36,55 @@ class Absolute(HandHistoryConverter):
|
||||||
codepage = "cp1252"
|
codepage = "cp1252"
|
||||||
siteid = 8
|
siteid = 8
|
||||||
HORSEHand = False
|
HORSEHand = False
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_SplitHands = re.compile(r"\n\n\n+")
|
re_SplitHands = re.compile(r"\n\n\n+")
|
||||||
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
||||||
#Stage #1571362962: Holdem No Limit $0.02 - 2009-08-05 15:24:06 (ET)
|
#Stage #1571362962: Holdem No Limit $0.02 - 2009-08-05 15:24:06 (ET)
|
||||||
#Table: TORONTO AVE (Real Money) Seat #6 is the dealer
|
#Table: TORONTO AVE (Real Money) Seat #6 is the dealer
|
||||||
#Seat 6 - FETS63 ($0.75 in chips)
|
#Seat 6 - FETS63 ($0.75 in chips)
|
||||||
#Board [10s 5d Kh Qh 8c]
|
#Board [10s 5d Kh Qh 8c]
|
||||||
|
|
||||||
|
re_GameInfo = re.compile( ur"""
|
||||||
|
^Stage\s+\#C?(?P<HID>[0-9]+):?\s+
|
||||||
|
(?:Tourney\ ID\ (?P<TRNY_ID>\d+)\s+)?
|
||||||
|
(?P<GAME>Holdem|Seven\ Card\ Hi\/L|HORSE)\s+
|
||||||
|
(?P<TRNY_TYPE>\(1\son\s1\)|Single\ Tournament|)\s*
|
||||||
|
(?P<LIMIT>No\ Limit|Pot\ Limit|Normal|)\s?
|
||||||
|
(?P<CURRENCY>\$|\s€|)
|
||||||
|
(?P<SB>[.0-9]+)/?(?:\$|\s€|)(?P<BB>[.0-9]+)?
|
||||||
|
\s+-\s+
|
||||||
|
(?P<DATETIME>\d\d\d\d-\d\d-\d\d\ \d\d:\d\d:\d\d)\s+
|
||||||
|
(?: \( (?P<TZ>[A-Z]+) \)\s+ )?
|
||||||
|
.*?
|
||||||
|
(Table:\ (?P<TABLE>.*?)\ \(Real\ Money\))?
|
||||||
|
""", re.MULTILINE|re.VERBOSE|re.DOTALL)
|
||||||
|
|
||||||
|
re_HorseGameInfo = re.compile(
|
||||||
|
ur"^Game Type: (?P<LIMIT>Limit) (?P<GAME>Holdem)",
|
||||||
|
re.MULTILINE)
|
||||||
|
|
||||||
|
re_HandInfo = re_GameInfo
|
||||||
|
|
||||||
|
# on HORSE STUD games, the table name isn't in the hand info!
|
||||||
|
re_RingInfoFromFilename = re.compile(ur".*IHH([0-9]+) (?P<TABLE>.*) -")
|
||||||
|
re_TrnyInfoFromFilename = re.compile(
|
||||||
|
ur".*IHH ([0-9]+) (?P<TRNY_NAME>.*) "\
|
||||||
|
"ID (?P<TRNY_ID>\d+) \((?P<TABLE>\d+)\) .* "\
|
||||||
|
"(?:\$|\s€|)(?P<BUYIN>[0-9.]+)\s*\+\s*(?:\$|\s€|)(?P<FEE>[0-9.]+)"
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: that's not the right way to match for "dead" dealer is it?
|
||||||
|
re_Button = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE)
|
||||||
|
|
||||||
|
re_PlayerInfo = re.compile(
|
||||||
|
ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) "\
|
||||||
|
"\((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)",
|
||||||
|
re.MULTILINE)
|
||||||
|
|
||||||
|
re_Board = re.compile(ur"\[(?P<CARDS>[^\]]*)\]? *$", re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
re_GameInfo = re.compile(ur"""^Stage #(C?[0-9]+):\s+
|
|
||||||
(?P<GAME>Holdem|Seven\sCard\sHi\/L|HORSE)
|
|
||||||
(?:\s\(1\son\s1\)|)?\s+?
|
|
||||||
(?P<LIMIT>No Limit|Pot\sLimit|Normal|)?\s?
|
|
||||||
(?P<CURRENCY>\$|\s€|)
|
|
||||||
(?P<SB>[.0-9]+)/?(?:\$|\s€|)(?P<BB>[.0-9]+)?
|
|
||||||
""", re.MULTILINE|re.VERBOSE)
|
|
||||||
re_HorseGameInfo = re.compile(ur"^Game Type: (?P<LIMIT>Limit) (?P<GAME>Holdem)", re.MULTILINE)
|
|
||||||
# TODO: can set max seats via (1 on 1) to a known 2 ..
|
|
||||||
re_HandInfo = re.compile(ur"^Stage #C?(?P<HID>[0-9]+): .*(?P<DATETIME>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\n(Table: (?P<TABLE>.*) \(Real Money\))?", re.MULTILINE)
|
|
||||||
re_TableFromFilename = re.compile(ur".*IHH([0-9]+) (?P<TABLE>.*) -") # on HORSE STUD games, the table name isn't in the hand info!
|
|
||||||
re_Button = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE) # TODO: that's not the right way to match for "dead" dealer is it?
|
|
||||||
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) \((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)", re.MULTILINE)
|
|
||||||
re_Board = re.compile(ur"\[(?P<CARDS>[^\]]*)\]? *$", re.MULTILINE)
|
|
||||||
|
|
||||||
|
|
||||||
def compilePlayerRegexs(self, hand):
|
def compilePlayerRegexs(self, hand):
|
||||||
players = set([player[1] for player in hand.players])
|
players = set([player[1] for player in hand.players])
|
||||||
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
@ -74,27 +98,19 @@ class Absolute(HandHistoryConverter):
|
||||||
# TODO: Absolute posting when coming in new: %s - Posts $0.02 .. should that be a new Post line? where do we need to add support for that? *confused*
|
# TODO: Absolute posting when coming in new: %s - Posts $0.02 .. should that be a new Post line? where do we need to add support for that? *confused*
|
||||||
self.re_PostBoth = re.compile(ur"^%s - Posts dead (?:\$| €|)(?P<SBBB>[0-9]*[.0-9]+)" % player_re, re.MULTILINE)
|
self.re_PostBoth = re.compile(ur"^%s - Posts dead (?:\$| €|)(?P<SBBB>[0-9]*[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
self.re_Action = re.compile(ur"^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re, re.MULTILINE)
|
self.re_Action = re.compile(ur"^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re, re.MULTILINE)
|
||||||
# print "^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re
|
|
||||||
self.re_ShowdownAction = re.compile(ur"^%s - Shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
self.re_ShowdownAction = re.compile(ur"^%s - Shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
self.re_CollectPot = re.compile(ur"^Seat [0-9]: %s(?: \(dealer\)|)(?: \(big blind\)| \(small blind\)|) (?:won|collected) Total \((?:\$| €|)(?P<POT>[0-9]*[.0-9]+)\)" % player_re, re.MULTILINE)
|
self.re_CollectPot = re.compile(ur"^Seat [0-9]: %s(?: \(dealer\)|)(?: \(big blind\)| \(small blind\)|) (?:won|collected) Total \((?:\$| €|)(?P<POT>[0-9]*[.0-9]+)\)" % player_re, re.MULTILINE)
|
||||||
#self.re_PostSB = re.compile(ur"^%s: posts small blind \[(?:\$| €|) (?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
||||||
#self.re_PostBB = re.compile(ur"^%s: posts big blind \[(?:\$| €|) (?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
||||||
#self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[(?:\$| €|) (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
||||||
self.re_Antes = re.compile(ur"^%s - Ante \[(?:\$| €|)(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
self.re_Antes = re.compile(ur"^%s - Ante \[(?:\$| €|)(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
|
#self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
|
||||||
self.re_HeroCards = re.compile(ur"^Dealt to %s \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
self.re_HeroCards = re.compile(ur"^Dealt to %s \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
#self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.\d]+) (USD|EUR|)\])?" % player_re, re.MULTILINE)
|
|
||||||
#self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds| complete to)(\s\[?(?:\$| €|) ?(?P<BET>\d+\.?\d*)\.?\s?(USD|EUR|)\]?)?" % player_re, re.MULTILINE)
|
|
||||||
#self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
|
||||||
#self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P<POT>[.\d]+) (USD|EUR|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
|
||||||
#self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE)
|
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
return [["ring", "hold", "nl"],
|
return [["ring", "hold", "nl"],
|
||||||
["ring", "hold", "pl"],
|
["ring", "hold", "pl"],
|
||||||
["ring", "hold", "fl"],
|
["ring", "hold", "fl"],
|
||||||
["ring", "studhi", "fl"],
|
["ring", "studhi", "fl"],
|
||||||
["ring", "omahahi", "pl"]
|
["ring", "omahahi", "pl"],
|
||||||
|
["tour", "hold", "nl"],
|
||||||
]
|
]
|
||||||
|
|
||||||
def determineGameType(self, handText):
|
def determineGameType(self, handText):
|
||||||
|
@ -102,7 +118,9 @@ class Absolute(HandHistoryConverter):
|
||||||
'type' in ('ring', 'tour')
|
'type' in ('ring', 'tour')
|
||||||
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
||||||
'base' in ('hold', 'stud', 'draw')
|
'base' in ('hold', 'stud', 'draw')
|
||||||
'category' in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
|
'category' in ('holdem', 'omahahi', omahahilo', 'razz',
|
||||||
|
'studhi', 'studhilo', 'fivedraw', '27_1draw',
|
||||||
|
'27_3draw', 'badugi')
|
||||||
'hilo' in ('h','l','s')
|
'hilo' in ('h','l','s')
|
||||||
'smallBlind' int?
|
'smallBlind' int?
|
||||||
'bigBlind' int?
|
'bigBlind' int?
|
||||||
|
@ -112,7 +130,7 @@ class Absolute(HandHistoryConverter):
|
||||||
|
|
||||||
or None if we fail to get the info """
|
or None if we fail to get the info """
|
||||||
info = {'type':'ring'}
|
info = {'type':'ring'}
|
||||||
|
|
||||||
m = self.re_GameInfo.search(handText)
|
m = self.re_GameInfo.search(handText)
|
||||||
if not m:
|
if not m:
|
||||||
tmp = handText[0:100]
|
tmp = handText[0:100]
|
||||||
|
@ -120,15 +138,15 @@ class Absolute(HandHistoryConverter):
|
||||||
log.error(_("determineGameType: Raising FpdbParseError"))
|
log.error(_("determineGameType: Raising FpdbParseError"))
|
||||||
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
|
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
|
||||||
|
|
||||||
|
|
||||||
mg = m.groupdict()
|
mg = m.groupdict()
|
||||||
|
|
||||||
# translations from captured groups to our info strings
|
# translations from captured groups to our info strings
|
||||||
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Normal':'fl', 'Limit':'fl'}
|
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Normal':'fl', 'Limit':'fl'}
|
||||||
games = { # base, category
|
games = { # base, category
|
||||||
"Holdem" : ('hold','holdem'),
|
"Holdem" : ('hold','holdem'),
|
||||||
'Omaha' : ('hold','omahahi'),
|
'Omaha' : ('hold','omahahi'),
|
||||||
'Razz' : ('stud','razz'),
|
'Razz' : ('stud','razz'),
|
||||||
'Seven Card Hi/L' : ('stud','studhilo'),
|
'Seven Card Hi/L' : ('stud','studhilo'),
|
||||||
'7 Card Stud' : ('stud','studhi')
|
'7 Card Stud' : ('stud','studhi')
|
||||||
}
|
}
|
||||||
|
@ -148,45 +166,62 @@ class Absolute(HandHistoryConverter):
|
||||||
if 'GAME' in mg:
|
if 'GAME' in mg:
|
||||||
(info['base'], info['category']) = games[mg['GAME']]
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
if 'LIMIT' in mg:
|
if 'LIMIT' in mg:
|
||||||
info['limitType'] = limits[mg['LIMIT']]
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
if 'SB' in mg:
|
|
||||||
info['sb'] = mg['SB']
|
|
||||||
else:
|
|
||||||
info['sb'] = str(float(mg['BB']) * 0.5) # TODO: Apparently AP doesn't provide small blind info!? must search to see if it's posted, I guess
|
|
||||||
if 'BB' in mg:
|
|
||||||
info['bb'] = mg['BB']
|
|
||||||
if 'CURRENCY' in mg:
|
if 'CURRENCY' in mg:
|
||||||
info['currency'] = currencies[mg['CURRENCY']]
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
if info['currency'] == 'T$':
|
if info['currency'] == 'T$':
|
||||||
info['type'] = 'tour'
|
info['type'] = 'tour'
|
||||||
|
if 'SB' in mg:
|
||||||
|
info['sb'] = mg['SB']
|
||||||
|
if 'BB' in mg:
|
||||||
|
info['bb'] = mg['BB']
|
||||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
if info['bb'] is None:
|
if info['bb'] is None:
|
||||||
info['bb'] = mg['SB']
|
info['bb'] = mg['SB']
|
||||||
info['sb'] = str(float(mg['SB']) * 0.5) # TODO: AP does provide Small BET for Limit .. I think? at least 1-on-1 limit they do.. sigh
|
info['sb'] = str(float(mg['SB']) * 0.5) # TODO: AP does provide Small BET for Limit .. I think? at least 1-on-1 limit they do.. sigh
|
||||||
|
|
||||||
#print info;
|
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
|
is_trny = hand.gametype['type']=='tour'
|
||||||
|
|
||||||
m = self.re_HandInfo.search(hand.handText)
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
if(m == None):
|
fname_re = self.re_TrnyInfoFromFilename if is_trny \
|
||||||
logging.info(_("Didn't match re_HandInfo"))
|
else self.re_RingInfoFromFilename
|
||||||
logging.info(hand.handText)
|
fname_info = fname_re.search(self.in_path)
|
||||||
|
|
||||||
|
if m is None or fname_info is None:
|
||||||
|
if m is None:
|
||||||
|
logging.info(_("Didn't match re_HandInfo"))
|
||||||
|
logging.info(hand.handText)
|
||||||
|
elif fname_info is None:
|
||||||
|
logging.info(_("File name didn't match re_*InfoFromFilename"))
|
||||||
|
logging.info(_("File name: %s") % self.in_path)
|
||||||
return None
|
return None
|
||||||
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
if m.group('TABLE'):
|
if m.group('TABLE'):
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
else:
|
else:
|
||||||
t = self.re_TableFromFilename.search(self.in_path)
|
hand.tablename = fname_info.group('TABLE')
|
||||||
hand.tablename = t.group('TABLE')
|
|
||||||
hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since absolute doesn't give seat max info
|
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
||||||
# TODO: (1-on-1) does have that info in the game type line
|
|
||||||
|
if is_trny:
|
||||||
|
hand.fee = fname_info.group('FEE')
|
||||||
|
hand.buyin = fname_info.group('BUYIN')
|
||||||
|
hand.tourNo = m.group('TRNY_ID')
|
||||||
|
hand.tourneyComment = fname_info.group('TRNY_NAME')
|
||||||
|
|
||||||
|
# assume 6-max unless we have proof it's a larger/smaller game,
|
||||||
|
#since absolute doesn't give seat max info
|
||||||
|
# TODO: (1-on-1) does have that info in the game type line
|
||||||
|
hand.maxseats = 6
|
||||||
|
|
||||||
if self.HORSEHand:
|
if self.HORSEHand:
|
||||||
hand.maxseats = 8
|
hand.maxseats = 8
|
||||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
|
@ -195,10 +230,11 @@ class Absolute(HandHistoryConverter):
|
||||||
seatnum = int(a.group('SEAT'))
|
seatnum = int(a.group('SEAT'))
|
||||||
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
||||||
if seatnum > 6:
|
if seatnum > 6:
|
||||||
hand.maxseats = 10 # absolute does 2/4/6/8/10 games
|
hand.maxseats = 10 # absolute does 2/4/6/8/10 games
|
||||||
# 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?
|
# 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?
|
||||||
|
|
||||||
|
|
||||||
def markStreets(self, hand):
|
def markStreets(self, hand):
|
||||||
# PREFLOP = ** Dealing down cards **
|
# PREFLOP = ** Dealing down cards **
|
||||||
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
||||||
|
@ -208,7 +244,7 @@ class Absolute(HandHistoryConverter):
|
||||||
r"(\*\*\* FLOP \*\*\*(?P<FLOP>.+(?=\*\*\* TURN \*\*\*)|.+))?"
|
r"(\*\*\* FLOP \*\*\*(?P<FLOP>.+(?=\*\*\* TURN \*\*\*)|.+))?"
|
||||||
r"(\*\*\* TURN \*\*\*(?P<TURN>.+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
r"(\*\*\* TURN \*\*\*(?P<TURN>.+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
||||||
r"(\*\*\* RIVER \*\*\*(?P<RIVER>.+))?", hand.handText, re.DOTALL)
|
r"(\*\*\* RIVER \*\*\*(?P<RIVER>.+))?", hand.handText, re.DOTALL)
|
||||||
|
|
||||||
elif hand.gametype['base'] == 'stud': # TODO: Not implemented yet
|
elif hand.gametype['base'] == 'stud': # TODO: Not implemented yet
|
||||||
m = re.search(r"(?P<ANTES>.+(?=\*\* Dealing down cards \*\*)|.+)"
|
m = re.search(r"(?P<ANTES>.+(?=\*\* Dealing down cards \*\*)|.+)"
|
||||||
r"(\*\* Dealing down cards \*\*(?P<THIRD>.+(?=\*\*\*\* dealing 4th street \*\*\*\*)|.+))?"
|
r"(\*\* Dealing down cards \*\*(?P<THIRD>.+(?=\*\*\*\* dealing 4th street \*\*\*\*)|.+))?"
|
||||||
|
@ -218,10 +254,12 @@ class Absolute(HandHistoryConverter):
|
||||||
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
def readCommunityCards(self, hand, street):
|
||||||
# If this has been called, street is a street which gets dealt community cards by type hand
|
# street has been matched by markStreets, so exists in this hand
|
||||||
# but it might be worth checking somehow.
|
# If this has been called, street is a street which gets dealt
|
||||||
# if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
# 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)
|
||||||
logging.debug("readCommunityCards (%s)" % street)
|
logging.debug("readCommunityCards (%s)" % street)
|
||||||
m = self.re_Board.search(hand.streets[street])
|
m = self.re_Board.search(hand.streets[street])
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
|
@ -272,7 +310,7 @@ class Absolute(HandHistoryConverter):
|
||||||
else:
|
else:
|
||||||
#Not involved in hand
|
#Not involved in hand
|
||||||
hand.involved = False
|
hand.involved = False
|
||||||
|
|
||||||
def readStudPlayerCards(self, hand, street):
|
def readStudPlayerCards(self, hand, street):
|
||||||
# lol. see Plymouth.txt
|
# lol. see Plymouth.txt
|
||||||
logging.warning(_("Absolute readStudPlayerCards is only a stub."))
|
logging.warning(_("Absolute readStudPlayerCards is only a stub."))
|
||||||
|
@ -306,7 +344,7 @@ class Absolute(HandHistoryConverter):
|
||||||
logging.debug("readShowdownActions")
|
logging.debug("readShowdownActions")
|
||||||
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
cards = shows.group('CARDS')
|
cards = shows.group('CARDS')
|
||||||
cards = [validCard(card) for card in cards.split(' ')]
|
cards = [validCard(card) for card in cards.split(' ')]
|
||||||
logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME')))
|
logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME')))
|
||||||
hand.addShownCards(cards, shows.group('PNAME'))
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ _ = L10n.get_translation()
|
||||||
import sys
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from Configuration import LOCALE_ENCODING
|
||||||
from Exceptions import FpdbParseError
|
from Exceptions import FpdbParseError
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ class FpdbParseError(FpdbParseError):
|
||||||
|
|
||||||
class PartyPoker(HandHistoryConverter):
|
class PartyPoker(HandHistoryConverter):
|
||||||
sitename = "PartyPoker"
|
sitename = "PartyPoker"
|
||||||
codepage = "cp1252"
|
codepage = "utf8"
|
||||||
siteId = 9
|
siteId = 9
|
||||||
filetype = "text"
|
filetype = "text"
|
||||||
sym = {'USD': "\$", }
|
sym = {'USD': "\$", }
|
||||||
|
@ -55,7 +56,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
(?P<GAME>(Texas\ Hold\'em|Omaha|7 Card Stud Hi-Lo))
|
(?P<GAME>(Texas\ Hold\'em|Omaha|7 Card Stud Hi-Lo))
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
""", re.VERBOSE)
|
""", re.VERBOSE | re.UNICODE)
|
||||||
re_GameInfoTrny = re.compile("""
|
re_GameInfoTrny = re.compile("""
|
||||||
(?P<LIMIT>(NL|PL|))\s*
|
(?P<LIMIT>(NL|PL|))\s*
|
||||||
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
||||||
|
@ -69,7 +70,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
\)
|
\)
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
""", re.VERBOSE)
|
""", re.VERBOSE | re.UNICODE)
|
||||||
re_Hid = re.compile("^Game \#(?P<HID>\d+) starts.")
|
re_Hid = re.compile("^Game \#(?P<HID>\d+) starts.")
|
||||||
|
|
||||||
re_PlayerInfo = re.compile("""
|
re_PlayerInfo = re.compile("""
|
||||||
|
@ -180,6 +181,10 @@ class PartyPoker(HandHistoryConverter):
|
||||||
return self._gameType
|
return self._gameType
|
||||||
return self._gameType
|
return self._gameType
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def decode_hand_text(handText):
|
||||||
|
return handText.encode("latin1").decode(LOCALE_ENCODING)
|
||||||
|
|
||||||
def determineGameType(self, handText):
|
def determineGameType(self, handText):
|
||||||
"""inspect the handText and return the gametype dict
|
"""inspect the handText and return the gametype dict
|
||||||
|
|
||||||
|
@ -187,6 +192,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
|
handText = self.decode_hand_text(handText)
|
||||||
m = self._getGameType(handText)
|
m = self._getGameType(handText)
|
||||||
m_20BBmin = self.re_20BBmin.search(handText)
|
m_20BBmin = self.re_20BBmin.search(handText)
|
||||||
if m is None:
|
if m is None:
|
||||||
|
@ -247,6 +253,10 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
|
# we should redecode handtext here (as it imposible to it above)
|
||||||
|
# if you know more accurate way to do it - tell me
|
||||||
|
hand.handText = self.decode_hand_text(hand.handText)
|
||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
try:
|
try:
|
||||||
info.update(self.re_Hid.search(hand.handText).groupdict())
|
info.update(self.re_Hid.search(hand.handText).groupdict())
|
||||||
|
@ -295,10 +305,15 @@ class PartyPoker(HandHistoryConverter):
|
||||||
#Saturday, July 25, 07:53:52 EDT 2009
|
#Saturday, July 25, 07:53:52 EDT 2009
|
||||||
#Thursday, July 30, 21:40:41 MSKS 2009
|
#Thursday, July 30, 21:40:41 MSKS 2009
|
||||||
#Sunday, October 25, 13:39:07 MSK 2009
|
#Sunday, October 25, 13:39:07 MSK 2009
|
||||||
m2 = re.search("\w+, (?P<M>\w+) (?P<D>\d+), (?P<H>\d+):(?P<MIN>\d+):(?P<S>\d+) (?P<TZ>[A-Z]+) (?P<Y>\d+)", info[key])
|
m2 = re.search(
|
||||||
# we cant use '%B' due to locale problems
|
r"\w+,\s+(?P<M>\w+)\s+(?P<D>\d+),\s+(?P<H>\d+):(?P<MIN>\d+):(?P<S>\d+)\s+(?P<TZ>[A-Z]+)\s+(?P<Y>\d+)",
|
||||||
|
info[key],
|
||||||
|
re.UNICODE
|
||||||
|
)
|
||||||
months = ['January', 'February', 'March', 'April','May', 'June',
|
months = ['January', 'February', 'March', 'April','May', 'June',
|
||||||
'July','August','September','October','November','December']
|
'July','August','September','October','November','December']
|
||||||
|
if m2.group('M') not in months:
|
||||||
|
raise FpdbParseError("Only english hh is supported", hid=info["HID"])
|
||||||
month = months.index(m2.group('M')) + 1
|
month = months.index(m2.group('M')) + 1
|
||||||
datetimestr = "%s/%s/%s %s:%s:%s" % (m2.group('Y'), month,m2.group('D'),m2.group('H'),m2.group('MIN'),m2.group('S'))
|
datetimestr = "%s/%s/%s %s:%s:%s" % (m2.group('Y'), month,m2.group('D'),m2.group('H'),m2.group('MIN'),m2.group('S'))
|
||||||
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
|
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
|
||||||
|
@ -547,7 +562,6 @@ class PartyPoker(HandHistoryConverter):
|
||||||
else:
|
else:
|
||||||
return "%s.+Table\s#%s" % (TableName[0], table_number)
|
return "%s.+Table\s#%s" % (TableName[0], table_number)
|
||||||
else:
|
else:
|
||||||
print 'party', 'getTableTitleRe', table_number
|
|
||||||
return table_name
|
return table_name
|
||||||
|
|
||||||
def clearMoneyString(money):
|
def clearMoneyString(money):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user