From d546557ef7cacef4113d5570da22ab3f6db00e53 Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 19 Jul 2009 15:45:18 +0800 Subject: [PATCH] Make new db insert code "usable" Next step, make the players insert. Function doesn't exist at the moment and crashes when NEWIMPROT set to true --- pyfpdb/HandHistoryConverter.py | 9 ++++++++- pyfpdb/fpdb_import.py | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 712260f9..889544b0 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -47,6 +47,8 @@ class HandHistoryConverter(): self.in_path = in_path self.out_path = out_path + + self.processedHands = [] if in_path == '-': self.in_fh = sys.stdin @@ -90,7 +92,7 @@ Otherwise, finish at eof. handsList = self.allHandsAsList() logging.info("Parsing %d hands" % len(handsList)) for handText in handsList: - self.processHand(handText) + self.processedHands.append(self.processHand(handText)) numHands= len(handsList) endtime = time.time() print "read %d hands in %.3f seconds" % (numHands, endtime - starttime) @@ -200,6 +202,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. if hand: # print hand hand.writeHand(self.out_fh) + return hand else: logging.info("Unsupported game type: %s" % gametype) # TODO: pity we don't know the HID at this stage. Log the entire hand? @@ -310,6 +313,7 @@ or None if we fail to get the info """ self.filetype = filetype self.codepage = codepage + #This function doesn't appear to be used def splitFileIntoHands(self): hands = [] self.obs = self.obs.strip() @@ -347,6 +351,9 @@ or None if we fail to get the info """ #TODO: Return a status of true if file processed ok return True + def getProcessedHands(self): + return self.processedHands + def getProcessedFile(self): return self.out_path diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index e5029750..ca9c7680 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -317,12 +317,12 @@ class Importer: (stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(out_path, site) elif (conv.getStatus() and self.NEWIMPORT == True): #This code doesn't do anything yet - handlist = hhc.getProcessedHands() - self.pos_in_file[file] = hhc.getLastCharacterRead() + handlist = conv.getProcessedHands() + self.pos_in_file[file] = conv.getLastCharacterRead() for hand in handlist: - hand.prepInsert() - hand.insert() + hand.prepInsert(self.fdb) + hand.insert(self.fdb) else: # conversion didn't work # TODO: appropriate response?