From de9c0d9ba6ce52524cbde3015a316e22dff5a3e7 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 27 Aug 2010 14:44:19 +0800 Subject: [PATCH] Stars: Minor refactor to readHandInfo Make the readHandInfo function throw an exception if either of the regexes used fails to match --- pyfpdb/PokerStarsToFpdb.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 39347f73..4fbe9dfd 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -224,14 +224,15 @@ class PokerStars(HandHistoryConverter): def readHandInfo(self, hand): info = {} - m = self.re_HandInfo.search(hand.handText,re.DOTALL) - if m: - info.update(m.groupdict()) - else: - pass # throw an exception here, eh? - m = self.re_GameInfo.search(hand.handText) - if m: - info.update(m.groupdict()) + m = self.re_HandInfo.search(hand.handText,re.DOTALL) + m2 = self.re_GameInfo.search(hand.handText) + if m is None or m2 is None: + logging.info("Didn't match re_HandInfo") + logging.info(hand.handText) + raise FpdbParseError("No match in readHandInfo.") + + info.update(m.groupdict()) + info.update(m2.groupdict()) log.debug("readHandInfo: %s" % info) for key in info: