From 0b02b05f6768735d2577c042dfdc98e071c479fd Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 20 Dec 2010 14:00:09 +0800 Subject: [PATCH] HHC, Party: Move clearMoneyString into HHC Make clearMoneyString available to all parsers and fix all calls within Party --- pyfpdb/HandHistoryConverter.py | 5 +++++ pyfpdb/PartyPokerToFpdb.py | 20 ++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 62383beb..34760664 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -675,6 +675,11 @@ or None if we fail to get the info """ # PokerStars: WCOOP 2nd Chance 02: $1,050 NLHE - Tournament 307521826 Table 1 - Blinds $30/$60 return "%s.+Table (\d+)" % (tournament, ) + @staticmethod + def clearMoneyString(money): + "Renders 'numbers' like '1 200' and '2,000'" + return money.replace(' ', '').replace(',', '') + def getTableTitleRe(config, sitename, *args, **kwargs): "Returns string to search in windows titles for current site" return getSiteHhc(config, sitename).getTableTitleRe(*args, **kwargs) diff --git a/pyfpdb/PartyPokerToFpdb.py b/pyfpdb/PartyPokerToFpdb.py index a9321c63..c1f33295 100755 --- a/pyfpdb/PartyPokerToFpdb.py +++ b/pyfpdb/PartyPokerToFpdb.py @@ -240,8 +240,8 @@ class PartyPoker(HandHistoryConverter): info['sb'] = "%.2f" % (sb) info['currency'] = self.currencies[mg['CURRENCY']] else: - info['sb'] = clearMoneyString(mg['SB']) - info['bb'] = clearMoneyString(mg['BB']) + info['sb'] = self.clearMoneyString(mg['SB']) + info['bb'] = self.clearMoneyString(mg['BB']) info['currency'] = 'T$' return info @@ -361,10 +361,10 @@ class PartyPoker(HandHistoryConverter): if a.group('CASH') > '0': #record max known stack for use with players with unknown stack maxKnownStack = max(a.group('CASH'),maxKnownStack) - hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), clearMoneyString(a.group('CASH'))) + hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), self.clearMoneyString(a.group('CASH'))) else: #zero stacked players are added later - zeroStackPlayers.append([int(a.group('SEAT')), a.group('PNAME'), clearMoneyString(a.group('CASH'))]) + zeroStackPlayers.append([int(a.group('SEAT')), a.group('PNAME'), self.clearMoneyString(a.group('CASH'))]) if hand.gametype['type'] == 'ring': #finds first vacant seat after an exact seat def findFirstEmptySeat(startSeat): @@ -384,7 +384,7 @@ class PartyPoker(HandHistoryConverter): #if a zero stacked player is just joined the table in this very hand then set his stack to maxKnownStack for p in zeroStackPlayers: if p[1] in match_JoiningPlayers: - p[2] = clearMoneyString(maxKnownStack) + p[2] = self.clearMoneyString(maxKnownStack) hand.addPlayer(p[0],p[1],p[2]) seatedPlayers = list([(f[1]) for f in hand.players]) @@ -401,7 +401,7 @@ class PartyPoker(HandHistoryConverter): occupiedSeats = list([(f[0]) for f in hand.players]) occupiedSeats.sort() newPlayerSeat = findFirstEmptySeat(previousBBPosterSeat) - hand.addPlayer(newPlayerSeat,player,clearMoneyString(maxKnownStack)) + hand.addPlayer(newPlayerSeat,player,self.clearMoneyString(maxKnownStack)) def markStreets(self, hand): m = re.search( @@ -491,7 +491,7 @@ class PartyPoker(HandHistoryConverter): for action in m: acts = action.groupdict() playerName = action.group('PNAME') - amount = clearMoneyString(action.group('BET')) if action.group('BET') else None + amount = self.clearMoneyString(action.group('BET')) if action.group('BET') else None actionType = action.group('ATYPE') if actionType == 'is all-In': @@ -530,7 +530,7 @@ class PartyPoker(HandHistoryConverter): def readCollectPot(self,hand): for m in self.re_CollectPot.finditer(hand.handText): - hand.addCollectPot(player=m.group('PNAME'),pot=clearMoneyString(m.group('POT'))) + hand.addCollectPot(player=m.group('PNAME'),pot=self.clearMoneyString(m.group('POT'))) def readShownCards(self,hand): for m in self.re_ShownCards.finditer(hand.handText): @@ -554,10 +554,6 @@ class PartyPoker(HandHistoryConverter): else: return table_name -def clearMoneyString(money): - "Renders 'numbers' like '1 200' and '2,000'" - return money.replace(' ', '').replace(',', '') - def renderCards(string): "Splits strings like ' Js, 4d '" cards = string.strip().split(' ')