Merge branch 'master' of git://github.com/grindi/fpdb-grindi
This commit is contained in:
commit
ec8cd9f785
|
@ -40,24 +40,48 @@ class Absolute(HandHistoryConverter):
|
|||
# Static regexes
|
||||
re_SplitHands = 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)
|
||||
#Table: TORONTO AVE (Real Money) Seat #6 is the dealer
|
||||
#Seat 6 - FETS63 ($0.75 in chips)
|
||||
#Board [10s 5d Kh Qh 8c]
|
||||
#Stage #1571362962: Holdem No Limit $0.02 - 2009-08-05 15:24:06 (ET)
|
||||
#Table: TORONTO AVE (Real Money) Seat #6 is the dealer
|
||||
#Seat 6 - FETS63 ($0.75 in chips)
|
||||
#Board [10s 5d Kh Qh 8c]
|
||||
|
||||
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?
|
||||
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]+)?
|
||||
""", 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)
|
||||
\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)
|
||||
|
||||
|
||||
|
@ -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*
|
||||
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)
|
||||
# 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_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_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_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):
|
||||
return [["ring", "hold", "nl"],
|
||||
["ring", "hold", "pl"],
|
||||
["ring", "hold", "fl"],
|
||||
["ring", "studhi", "fl"],
|
||||
["ring", "omahahi", "pl"]
|
||||
["ring", "omahahi", "pl"],
|
||||
["tour", "hold", "nl"],
|
||||
]
|
||||
|
||||
def determineGameType(self, handText):
|
||||
|
@ -102,7 +118,9 @@ class Absolute(HandHistoryConverter):
|
|||
'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')
|
||||
'category' in ('holdem', 'omahahi', omahahilo', 'razz',
|
||||
'studhi', 'studhilo', 'fivedraw', '27_1draw',
|
||||
'27_3draw', 'badugi')
|
||||
'hilo' in ('h','l','s')
|
||||
'smallBlind' int?
|
||||
'bigBlind' int?
|
||||
|
@ -149,44 +167,61 @@ class Absolute(HandHistoryConverter):
|
|||
(info['base'], info['category']) = games[mg['GAME']]
|
||||
if 'LIMIT' in mg:
|
||||
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:
|
||||
info['currency'] = currencies[mg['CURRENCY']]
|
||||
if info['currency'] == 'T$':
|
||||
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.
|
||||
if info['bb'] is None:
|
||||
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
|
||||
|
||||
#print info;
|
||||
|
||||
return info
|
||||
|
||||
|
||||
def readHandInfo(self, hand):
|
||||
is_trny = hand.gametype['type']=='tour'
|
||||
|
||||
m = self.re_HandInfo.search(hand.handText)
|
||||
if(m == None):
|
||||
fname_re = self.re_TrnyInfoFromFilename if is_trny \
|
||||
else self.re_RingInfoFromFilename
|
||||
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
|
||||
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||
hand.handid = m.group('HID')
|
||||
if m.group('TABLE'):
|
||||
hand.tablename = m.group('TABLE')
|
||||
else:
|
||||
t = self.re_TableFromFilename.search(self.in_path)
|
||||
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.tablename = fname_info.group('TABLE')
|
||||
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
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:
|
||||
hand.maxseats = 8
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
||||
return
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
|
@ -196,7 +231,8 @@ class Absolute(HandHistoryConverter):
|
|||
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
||||
if seatnum > 6:
|
||||
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):
|
||||
|
@ -218,10 +254,12 @@ class Absolute(HandHistoryConverter):
|
|||
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||
hand.addStreets(m)
|
||||
|
||||
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
||||
# 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)
|
||||
def readCommunityCards(self, hand, street):
|
||||
# street has been matched by markStreets, so exists in this hand
|
||||
# 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)
|
||||
logging.debug("readCommunityCards (%s)" % street)
|
||||
m = self.re_Board.search(hand.streets[street])
|
||||
cards = m.group('CARDS')
|
||||
|
|
|
@ -24,6 +24,7 @@ _ = L10n.get_translation()
|
|||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
from Configuration import LOCALE_ENCODING
|
||||
from Exceptions import FpdbParseError
|
||||
from HandHistoryConverter import *
|
||||
|
||||
|
@ -41,7 +42,7 @@ class FpdbParseError(FpdbParseError):
|
|||
|
||||
class PartyPoker(HandHistoryConverter):
|
||||
sitename = "PartyPoker"
|
||||
codepage = "cp1252"
|
||||
codepage = "utf8"
|
||||
siteId = 9
|
||||
filetype = "text"
|
||||
sym = {'USD': "\$", }
|
||||
|
@ -55,7 +56,7 @@ class PartyPoker(HandHistoryConverter):
|
|||
(?P<GAME>(Texas\ Hold\'em|Omaha|7 Card Stud Hi-Lo))
|
||||
\s*\-\s*
|
||||
(?P<DATETIME>.+)
|
||||
""", re.VERBOSE)
|
||||
""", re.VERBOSE | re.UNICODE)
|
||||
re_GameInfoTrny = re.compile("""
|
||||
(?P<LIMIT>(NL|PL|))\s*
|
||||
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
||||
|
@ -69,7 +70,7 @@ class PartyPoker(HandHistoryConverter):
|
|||
\)
|
||||
\s*\-\s*
|
||||
(?P<DATETIME>.+)
|
||||
""", re.VERBOSE)
|
||||
""", re.VERBOSE | re.UNICODE)
|
||||
re_Hid = re.compile("^Game \#(?P<HID>\d+) starts.")
|
||||
|
||||
re_PlayerInfo = re.compile("""
|
||||
|
@ -180,6 +181,10 @@ class PartyPoker(HandHistoryConverter):
|
|||
return self._gameType
|
||||
return self._gameType
|
||||
|
||||
@staticmethod
|
||||
def decode_hand_text(handText):
|
||||
return handText.encode("latin1").decode(LOCALE_ENCODING)
|
||||
|
||||
def determineGameType(self, handText):
|
||||
"""inspect the handText and return the gametype dict
|
||||
|
||||
|
@ -187,6 +192,7 @@ class PartyPoker(HandHistoryConverter):
|
|||
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
||||
|
||||
info = {}
|
||||
handText = self.decode_hand_text(handText)
|
||||
m = self._getGameType(handText)
|
||||
m_20BBmin = self.re_20BBmin.search(handText)
|
||||
if m is None:
|
||||
|
@ -247,6 +253,10 @@ class PartyPoker(HandHistoryConverter):
|
|||
|
||||
|
||||
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 = {}
|
||||
try:
|
||||
info.update(self.re_Hid.search(hand.handText).groupdict())
|
||||
|
@ -295,10 +305,15 @@ class PartyPoker(HandHistoryConverter):
|
|||
#Saturday, July 25, 07:53:52 EDT 2009
|
||||
#Thursday, July 30, 21:40:41 MSKS 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])
|
||||
# we cant use '%B' due to locale problems
|
||||
m2 = re.search(
|
||||
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',
|
||||
'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
|
||||
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")
|
||||
|
@ -547,7 +562,6 @@ class PartyPoker(HandHistoryConverter):
|
|||
else:
|
||||
return "%s.+Table\s#%s" % (TableName[0], table_number)
|
||||
else:
|
||||
print 'party', 'getTableTitleRe', table_number
|
||||
return table_name
|
||||
|
||||
def clearMoneyString(money):
|
||||
|
|
Loading…
Reference in New Issue
Block a user