From ee205c3b29f72d57566099c83628e9ce94db9af0 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 4 Dec 2009 17:56:56 +0800 Subject: [PATCH] [NEWIMPORT] Partially fix number of hands parsed reporting --- pyfpdb/HandHistoryConverter.py | 16 +++++++++------- pyfpdb/fpdb_import.py | 4 ++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 41b7b3d0..27bb9b1a 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -71,6 +71,8 @@ follow : whether to tail -f the input""" self.out_path = out_path self.processedHands = [] + self.numHands = 0 + self.numErrors = 0 # Tourney object used to store TourneyInfo when called to deal with a Summary file self.tourney = None @@ -135,17 +137,17 @@ Otherwise, finish at EOF. return try: - numHands = 0 - numErrors = 0 + self.numHands = 0 + self.numErrors = 0 if self.follow: #TODO: See how summary files can be handled on the fly (here they should be rejected as before) log.info("Tailing '%s'" % self.in_path) for handText in self.tailHands(): try: self.processHand(handText) - numHands += 1 + self.numHands += 1 except FpdbParseError, e: - numErrors += 1 + self.numErrors += 1 log.warning("Failed to convert hand %s" % e.hid) log.warning("Exception msg: '%s'" % str(e)) log.debug(handText) @@ -160,13 +162,13 @@ Otherwise, finish at EOF. try: self.processedHands.append(self.processHand(handText)) except FpdbParseError, e: - numErrors += 1 + self.numErrors += 1 log.warning("Failed to convert hand %s" % e.hid) log.warning("Exception msg: '%s'" % str(e)) log.debug(handText) - numHands = len(handsList) + self.numHands = len(handsList) endtime = time.time() - log.info("Read %d hands (%d failed) in %.3f seconds" % (numHands, numErrors, endtime - starttime)) + log.info("Read %d hands (%d failed) in %.3f seconds" % (self.numHands, self.numErrors, endtime - starttime)) else: self.parsedObjectType = "Summary" summaryParsingStatus = self.readSummaryInfo(handsList) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 19bf18d1..5b5ddca0 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -427,8 +427,12 @@ class Importer: self.pos_in_file[file] = hhc.getLastCharacterRead() for hand in handlist: + #try, except duplicates here? #hand.prepInsert() hand.insert(self.database) + + errors = getattr(hhc, 'numErrors') + stored = getattr(hhc, 'numHands') else: # conversion didn't work # TODO: appropriate response?