From 14bd76760337669ec6c47f99e36724180c2b8e80 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 17 Sep 2010 11:44:58 +0800 Subject: [PATCH] Carbon/Merge: Fix blind reading The new Merge network format has a timestamp in the blind line Also made some of the error reporting more consistent with other parsers --- pyfpdb/CarbonToFpdb.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pyfpdb/CarbonToFpdb.py b/pyfpdb/CarbonToFpdb.py index 4d4e0aa1..abb29e30 100644 --- a/pyfpdb/CarbonToFpdb.py +++ b/pyfpdb/CarbonToFpdb.py @@ -85,8 +85,8 @@ class Carbon(HandHistoryConverter): # The following are also static regexes: there is no need to call # compilePlayerRegexes (which does nothing), since players are identified # not by name but by seat number - re_PostSB = re.compile(r'', re.MULTILINE) - re_PostBB = re.compile(r'', re.MULTILINE) + re_PostSB = re.compile(r'timestamp="[0-9]+" )?player="(?P[0-9])" amount="(?P[.0-9]+)"/>', re.MULTILINE) + re_PostBB = re.compile(r'timestamp="[0-9]+" )?player="(?P[0-9])" amount="(?P[.0-9]+)"/>', re.MULTILINE) re_PostBoth = re.compile(r'', re.MULTILINE) #re_Antes = ??? #re_BringIn = ??? @@ -170,7 +170,7 @@ or None if we fail to get the info """ if m is None: logging.info(_("Didn't match re_HandInfo")) logging.info(hand.handText) - return None + raise FpdbParseError("No match in readHandInfo.") logging.debug("HID %s-%s, Table %s" % (m.group('HID1'), m.group('HID2'), m.group('TABLE')[:-1])) hand.handid = m.group('HID1') + m.group('HID2') @@ -181,7 +181,7 @@ or None if we fail to get the info """ # Check that the hand is complete up to the awarding of the pot; if # not, the hand is unparseable if self.re_EndOfHand.search(hand.handText) is None: - raise FpdbParseError(hid=m.group('HID1') + "-" + m.group('HID2')) + raise FpdbParseError("readHandInfo failed: HID: '%s' HID2: '%s'" %(m.group('HID1'), m.group('HID2'))) def readPlayerStacks(self, hand): m = self.re_PlayerInfo.finditer(hand.handText) @@ -221,15 +221,13 @@ or None if we fail to get the info """ pass # ??? def readBlinds(self, hand): - try: - m = self.re_PostSB.search(hand.handText) - hand.addBlind(self.playerNameFromSeatNo(m.group('PSEAT'), hand), - 'small blind', m.group('SB')) - except: # no small blind - hand.addBlind(None, None, None) + for a in self.re_PostSB.finditer(hand.handText): + #print "DEBUG: found sb: '%s' '%s'" %(self.playerNameFromSeatNo(a.group('PSEAT'), hand), a.group('SB')) + hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand),'small blind', a.group('SB')) + for a in self.re_PostBB.finditer(hand.handText): - hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand), - 'big blind', a.group('BB')) + #print "DEBUG: found bb: '%s' '%s'" %(self.playerNameFromSeatNo(a.group('PSEAT'), hand), a.group('BB')) + hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand), 'big blind', a.group('BB')) for a in self.re_PostBoth.finditer(hand.handText): bb = Decimal(self.info['bb']) amount = Decimal(a.group('SBBB'))