rename hand.string to hand.handText

Few other minor updates to match monkeyfutz
This commit is contained in:
Worros 2009-03-05 00:10:08 +09:00
parent e8552023da
commit 740fe92914
5 changed files with 42 additions and 43 deletions

View File

@ -65,7 +65,7 @@ class Everleaf(HandHistoryConverter):
["ring", "omahahi", "pl"]
]
def determineGameType(self):
def determineGameType(self, handText):
# Cheating with this regex, only support nlhe at the moment
# 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
@ -80,7 +80,7 @@ class Everleaf(HandHistoryConverter):
structure = "" # nl, pl, cn, cp, fl
game = ""
m = self.re_GameInfo.search(self.obs)
m = self.re_GameInfo.search(handText)
if m == None:
return None
if m.group('LTYPE') == "NL":
@ -102,9 +102,9 @@ class Everleaf(HandHistoryConverter):
return gametype
def readHandInfo(self, hand):
m = self.re_HandInfo.search(hand.string)
m = self.re_HandInfo.search(hand.handText)
if(m == None):
print "DEBUG: re_HandInfo.search failed: '%s'" %(hand.string)
print "DEBUG: re_HandInfo.search failed: '%s'" %(hand.handText)
hand.handid = m.group('HID')
hand.tablename = m.group('TABLE')
hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
@ -120,7 +120,7 @@ class Everleaf(HandHistoryConverter):
return
def readPlayerStacks(self, hand):
m = self.re_PlayerInfo.finditer(hand.string)
m = self.re_PlayerInfo.finditer(hand.handText)
for a in m:
seatnum = int(a.group('SEAT'))
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
@ -132,12 +132,12 @@ class Everleaf(HandHistoryConverter):
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)
#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)
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.string,re.DOTALL)
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.handText,re.DOTALL)
hand.addStreets(m)
@ -150,32 +150,31 @@ class Everleaf(HandHistoryConverter):
hand.setCommunityCards(street, m.group('CARDS').split(', '))
def readBlinds(self, hand):
try:
m = self.re_PostSB.search(hand.string)
m = self.re_PostSB.search(hand.handText)
if m is not None:
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
except Exception, e: # no small blind
#print e
else:
hand.addBlind(None, None, None)
for a in self.re_PostBB.finditer(hand.string):
for a in self.re_PostBB.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
for a in self.re_PostBoth.finditer(hand.string):
for a in self.re_PostBoth.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'both', a.group('SBBB'))
def readButton(self, hand):
hand.buttonpos = int(self.re_Button.search(hand.string).group('BUTTON'))
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
def readHeroCards(self, hand):
m = self.re_HeroCards.search(hand.string)
if(m == None):
#Not involved in hand
hand.involved = False
else:
m = self.re_HeroCards.search(hand.handText)
if m:
hand.hero = m.group('PNAME')
# "2c, qh" -> ["2c","qc"]
# Also works with Omaha hands.
cards = m.group('CARDS')
cards = cards.split(', ')
hand.addHoleCards(cards, m.group('PNAME'))
else:
#Not involved in hand
hand.involved = False
def readAction(self, hand, street):
m = self.re_Action.finditer(hand.streets.group(street))
@ -196,18 +195,18 @@ class Everleaf(HandHistoryConverter):
def readShowdownActions(self, hand):
"""Reads lines where holecards are reported in a showdown"""
for shows in self.re_ShowdownAction.finditer(hand.string):
for shows in self.re_ShowdownAction.finditer(hand.handText):
cards = shows.group('CARDS')
cards = cards.split(', ')
hand.addShownCards(cards, shows.group('PNAME'))
def readCollectPot(self,hand):
for m in self.re_CollectPot.finditer(hand.string):
for m in self.re_CollectPot.finditer(hand.handText):
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
def readShownCards(self,hand):
"""Reads lines where hole & board cards are mixed to form a hand (summary lines)"""
for m in self.re_CollectPot.finditer(hand.string):
for m in self.re_CollectPot.finditer(hand.handText):
if m.group('CARDS') is not None:
cards = m.group('CARDS')
cards = cards.split(', ')

View File

@ -61,7 +61,7 @@ class FullTilt(HandHistoryConverter):
["ring", "omaha", "pl"]
]
def determineGameType(self):
def determineGameType(self, handText):
# Cheating with this regex, only support nlhe at the moment
# 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
@ -71,7 +71,7 @@ class FullTilt(HandHistoryConverter):
game = ""
m = self.re_GameInfo.search(self.obs)
m = self.re_GameInfo.search(handText)
if m.group('LTYPE') == "No ":
structure = "nl"
elif m.group('LTYPE') == "Pot ":
@ -93,7 +93,7 @@ class FullTilt(HandHistoryConverter):
return gametype
def readHandInfo(self, hand):
m = self.re_HandInfo.search(hand.string,re.DOTALL)
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
#print m.groups()
hand.handid = m.group('HID')
hand.tablename = m.group('TABLE')
@ -114,7 +114,7 @@ class FullTilt(HandHistoryConverter):
#FIXME: hand.buttonpos = int(m.group('BUTTON'))
def readPlayerStacks(self, hand):
m = self.re_PlayerInfo.finditer(hand.string)
m = self.re_PlayerInfo.finditer(hand.handText)
players = []
for a in m:
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
@ -127,14 +127,14 @@ class FullTilt(HandHistoryConverter):
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.string,re.DOTALL)
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.handText,re.DOTALL)
elif self.gametype[1] == "razz":
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 \*\*\*)|.+))?"
r"(\*\*\* 7TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.string,re.DOTALL)
r"(\*\*\* 7TH STREET \*\*\*(?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
@ -146,18 +146,18 @@ class FullTilt(HandHistoryConverter):
def readBlinds(self, hand):
try:
m = self.re_PostSB.search(hand.string)
m = self.re_PostSB.search(hand.handText)
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
except: # no small blind
hand.addBlind(None, None, None)
for a in self.re_PostBB.finditer(hand.string):
for a in self.re_PostBB.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
for a in self.re_PostBoth.finditer(hand.string):
for a in self.re_PostBoth.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
def readAntes(self, hand):
print "DEBUG: reading antes"
m = self.re_Antes.finditer(hand.string)
m = self.re_Antes.finditer(hand.handText)
for player in m:
print "DEBUG: hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE'))
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
@ -165,15 +165,15 @@ class FullTilt(HandHistoryConverter):
def readBringIn(self, hand):
print "DEBUG: reading bring in"
# print hand.string
m = self.re_BringIn.search(hand.string,re.DOTALL)
m = self.re_BringIn.search(hand.handText,re.DOTALL)
print "DEBUG: Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
def readButton(self, hand):
hand.buttonpos = int(self.re_Button.search(hand.string).group('BUTTON'))
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
def readHeroCards(self, hand):
m = self.re_HeroCards.search(hand.string)
m = self.re_HeroCards.search(hand.handText)
if(m == None):
#Not involved in hand
hand.involved = False
@ -217,17 +217,17 @@ class FullTilt(HandHistoryConverter):
def readShowdownActions(self, hand):
for shows in self.re_ShowdownAction.finditer(hand.string):
for shows in self.re_ShowdownAction.finditer(hand.handText):
cards = shows.group('CARDS')
cards = cards.split(' ')
hand.addShownCards(cards, shows.group('PNAME'))
def readCollectPot(self,hand):
for m in self.re_CollectPot.finditer(hand.string):
for m in self.re_CollectPot.finditer(hand.handText):
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
def readShownCards(self,hand):
for m in self.re_ShownCards.finditer(hand.string):
for m in self.re_ShownCards.finditer(hand.handText):
if m.group('CARDS') is not None:
cards = m.group('CARDS')
cards = cards.split(' ')

View File

@ -73,7 +73,7 @@ class GuiBulkImport():
self.importer.setCallHud(False)
starttime = time()
(stored, dups, partial, errs, ttime) = self.importer.runImport()
print 'GuiBulkImport.import_dir done: Stored: %d Duplicates: %d Partial: %d Errors: %d in %s seconds - %d/sec'\
print 'GuiBulkImport.import_dir done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %d/sec'\
% (stored, dups, partial, errs, ttime, stored / ttime)
self.importer.clearFileList()

View File

@ -34,10 +34,10 @@ class Hand:
# def __init__(self, sitename, gametype, sb, bb, string):
UPS = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K', 'S':'s', 'C':'c', 'H':'h', 'D':'d'}
def __init__(self, sitename, gametype, string):
def __init__(self, sitename, gametype, handText):
self.sitename = sitename
self.gametype = gametype
self.string = string
self.handText = handText
if gametype[1] == "hold" or self.gametype[1] == "omahahi":
self.streetList = ['PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order

View File

@ -124,7 +124,7 @@ class HandHistoryConverter:
self.hands = self.splitFileIntoHands()
outfile = open(self.ofile, 'w')
for hand in self.hands:
#print "\nDEBUG: Input:\n"+hand.string
#print "\nDEBUG: Input:\n"+hand.handText
self.readHandInfo(hand)
self.readPlayerStacks(hand)