From a37adde67e8e248f32fb480b8e5b91e8348bf504 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 6 Aug 2009 11:30:21 +0800 Subject: [PATCH] Catch up to Eric - fix markStreets regex --- pyfpdb/AbsoluteToFpdb.py | 21 ++++++++++++++------- pyfpdb/HandHistoryConverter.py | 2 +- pyfpdb/fpdb_import.py | 3 +++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pyfpdb/AbsoluteToFpdb.py b/pyfpdb/AbsoluteToFpdb.py index 4b3aea2a..3fc42665 100644 --- a/pyfpdb/AbsoluteToFpdb.py +++ b/pyfpdb/AbsoluteToFpdb.py @@ -181,9 +181,9 @@ or None if we fail to get the info """ #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) if hand.gametype['base'] == 'hold': m = re.search(r"\*\*\* POCKET CARDS \*\*\*(?P.+(?=\*\*\* FLOP \*\*\*)|.+)" - r"\*\*\* FLOP \*\*\*(?P.+(?=\*\*\* TURN \*\*\*)|.+)" - r"\*\*\* TURN \*\*\*(?P.+(?=\*\*\* RIVER \*\*\*)|.+)" - r"\*\*\* RIVER \*\*\*(?P.+)", hand.handText, re.DOTALL) + r"(\*\*\* FLOP \*\*\*(?P.+(?=\*\*\* TURN \*\*\*)|.+))?" + r"(\*\*\* TURN \*\*\*(?P.+(?=\*\*\* RIVER \*\*\*)|.+))?" + r"(\*\*\* RIVER \*\*\*(?P.+))?", hand.handText, re.DOTALL) elif hand.gametype['base'] == 'stud': # TODO: Not implemented yet m = re.search(r"(?P.+(?=\*\* Dealing down cards \*\*)|.+)" @@ -201,7 +201,7 @@ or None if we fail to get the info """ logging.debug("readCommunityCards (%s)" % street) m = self.re_Board.search(hand.streets[street]) cards = m.group('CARDS') - cards = [card.strip() for card in cards.split(',')] + cards = [validCard(card) for card in cards.split(' ')] hand.setCommunityCards(street=street, cards=cards) def readAntes(self, hand): @@ -241,7 +241,7 @@ or None if we fail to get the info """ # "2c, qh" -> ["2c","qc"] # Also works with Omaha hands. cards = m.group('CARDS') - cards = [card.strip() for card in cards.split(',')] + cards = [validCard(card) for card in cards.split(' ')] # hand.addHoleCards(cards, m.group('PNAME')) hand.addHoleCards('PREFLOP', hand.hero, closed=cards, shown=False, mucked=False, dealt=True) @@ -283,7 +283,7 @@ or None if we fail to get the info """ logging.debug("readShowdownActions") for shows in self.re_ShowdownAction.finditer(hand.handText): cards = shows.group('CARDS') - cards = cards.split(', ') + cards = [validCard(card) for card in cards.split(' ')] logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME'))) hand.addShownCards(cards, shows.group('PNAME')) @@ -298,7 +298,7 @@ or None if we fail to get the info """ try: if m.group('CARDS') is not None: cards = m.group('CARDS') - cards = cards.split(', ') + cards = [validCard(card) for card in cards.split(' ')] player = m.group('PNAME') logging.debug("readShownCards %s cards=%s" % (player, cards)) # hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards) @@ -306,6 +306,13 @@ or None if we fail to get the info """ except IndexError: pass # there's no "PLAYER - Mucks" at AP that I can see +def validCard(card): + card = card.strip() + if card == '10s': card = 'Ts' + if card == '10h': card = 'Th' + if card == '10d': card = 'Td' + if card == '10c': card = 'Tc' + return card if __name__ == "__main__": parser = OptionParser() diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 3c89f819..bb30e705 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -60,7 +60,7 @@ class HandHistoryConverter(): out_dir = os.path.dirname(self.out_path) if not os.path.isdir(out_dir): logging.info("Creatin directory '%s'" % out_dir) -# os.makedirs(out_dir) + os.makedirs(out_dir) self.out_fh = open(self.out_path, 'w') self.sitename = sitename diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 8341bff5..159de588 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -130,6 +130,9 @@ class Importer: # self.updated = time() def clearFileList(self): + self.updatedsize = {} + self.updatetime = {} + self.pos_in_file = {} self.filelist = {} def closeDBs(self):