From 315d01031132faae4fb7b165054a17d7e4a3c3e7 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 5 Feb 2009 18:28:18 +0900 Subject: [PATCH] Make Everleaf converter actually function. Makes HandHistoryConverter actually write out a file to $hhArchiveBase/sitename/ Adds code in importer call the functions in EverleafToFpdb --- pyfpdb/HandHistoryConverter.py | 13 +++++++++++-- pyfpdb/fpdb_import.py | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 7dea7731..8d7df813 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -88,7 +88,7 @@ class HandHistoryConverter: self.hhbase = os.path.expanduser(self.hhbase) self.hhdir = os.path.join(self.hhbase,sitename) self.gametype = [] -# self.ofile = os.path.join(self.hhdir,file) + self.ofile = os.path.join(self.hhdir,file) self.rexx = FpdbRegex.FpdbRegex() def __str__(self): @@ -110,6 +110,7 @@ class HandHistoryConverter: print "Cowardly refusing to continue after failed sanity check" return self.readFile(self.file) + outfile = open(self.ofile, 'w') self.gametype = self.determineGameType() self.hands = self.splitFileIntoHands() for hand in self.hands: @@ -137,13 +138,14 @@ class HandHistoryConverter: hand.totalPot() self.getRake(hand) - hand.writeHand(sys.stderr) + hand.writeHand(outfile) #if(hand.involved == True): #self.writeHand("output file", hand) #hand.printHand() #else: #pass #Don't write out observed hands + outfile.close() endtime = time.time() print "Processed %d hands in %d seconds" % (len(self.hands), endtime-starttime) @@ -259,3 +261,10 @@ class HandHistoryConverter: result*=100 return result #end def float2int + + def getStatus(self): + #TODO: Return a status of true if file processed ok + return True + + def getProcessedFile(self): + return self.ofile diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index aa68c94f..09a26665 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -39,6 +39,7 @@ import re import fpdb_db import fpdb_simple import fpdb_parse_logic +import EverleafToFpdb from time import time class Importer: @@ -156,8 +157,18 @@ class Importer: if(filter == "passthrough"): (stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(file, site) else: - # TODO: Load filter, and run filtered file though main importer - (stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(file, site) + conv = None + # Load filter, process file, pass returned filename to import_fpdb_file + if(filter == "EverleafToFpdb"): + conv = EverleafToFpdb(self.config, file) + + conv.readSupportedGames() # Should this be done by HHC on init? + conv.determineGameType() + conv.processFile() + if(conv.getStatus()): + (stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(conv.getProcessedFile(ofile), site) + + #This will barf if conv.getStatus != True return (stored, duplicates, partial, errors, ttime)