From 740fe92914065960e00b55229f50a5a65fb2bddb Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 5 Mar 2009 00:10:08 +0900 Subject: [PATCH] rename hand.string to hand.handText Few other minor updates to match monkeyfutz --- pyfpdb/EverleafToFpdb.py | 43 +++++++++++++++++----------------- pyfpdb/FulltiltToFpdb.py | 32 ++++++++++++------------- pyfpdb/GuiBulkImport.py | 2 +- pyfpdb/Hand.py | 4 ++-- pyfpdb/HandHistoryConverter.py | 4 ++-- 5 files changed, 42 insertions(+), 43 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index 76c9cadd..4b0b4402 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -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.*?\n\*\*)?( Dealing Flop \*\* \[ (?P\S\S), (?P\S\S), (?P\S\S) \])?(?P.*?\*\*)?( Dealing Turn \*\* \[ (?P\S\S) \])?(?P.*?\*\*)?( Dealing River \*\* \[ (?P\S\S) \])?(?P.*)', hand.string,re.DOTALL) + #m = re.search('(\*\* Dealing down cards \*\*\n)(?P.*?\n\*\*)?( Dealing Flop \*\* \[ (?P\S\S), (?P\S\S), (?P\S\S) \])?(?P.*?\*\*)?( Dealing Turn \*\* \[ (?P\S\S) \])?(?P.*?\*\*)?( Dealing River \*\* \[ (?P\S\S) \])?(?P.*)', hand.handText,re.DOTALL) m = re.search(r"\*\* Dealing down cards \*\*(?P.+(?=\*\* Dealing Flop \*\*)|.+)" r"(\*\* Dealing Flop \*\*(?P \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?" r"(\*\* Dealing Turn \*\*(?P \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?" - r"(\*\* Dealing River \*\*(?P \[ \S\S \].+))?", hand.string,re.DOTALL) + r"(\*\* Dealing River \*\*(?P \[ \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(', ') diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index e64e9ced..cec2fd4a 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -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.+(?=\*\*\* FLOP \*\*\*)|.+)" r"(\*\*\* FLOP \*\*\*(?P \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?" r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?" - r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P\[\S\S\].+))?", hand.string,re.DOTALL) + r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P\[\S\S\].+))?", hand.handText,re.DOTALL) elif self.gametype[1] == "razz": m = re.search(r"(?P.+(?=\*\*\* 3RD STREET \*\*\*)|.+)" r"(\*\*\* 3RD STREET \*\*\*(?P.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?" r"(\*\*\* 4TH STREET \*\*\*(?P.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?" r"(\*\*\* 5TH STREET \*\*\*(?P.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?" r"(\*\*\* 6TH STREET \*\*\*(?P.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?" - r"(\*\*\* 7TH STREET \*\*\*(?P.+))?", hand.string,re.DOTALL) + r"(\*\*\* 7TH STREET \*\*\*(?P.+))?", 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(' ') diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 9e5fb30f..c4f3bbe5 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -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() diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 1b2e8cfe..3d6fa7c2 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -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 diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 3ed2f4c9..b8102c06 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -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) @@ -272,7 +272,7 @@ class HandHistoryConverter: list = self.re_SplitHands.split(self.obs) list.pop() #Last entry is empty for l in list: -# print "'" + l + "'" +# print "'" + l + "'" hands = hands + [Hand.Hand(self.sitename, self.gametype, l)] return hands