diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 19e62038..3e0ca3dd 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -194,6 +194,15 @@ class Aux_window: temp = temp + "%s" % self.layout[layout] return temp +class HHC: + def __init__(self, node): + self.site = node.getAttribute("site") + self.converter = node.getAttribute("converter") + + def __str__(self): + return "%s:\t%s" % (self.site, self.converter) + + class Popup: def __init__(self, node): self.name = node.getAttribute("pu_name") @@ -273,6 +282,7 @@ class Config: self.supported_games = {} self.supported_databases = {} self.aux_windows = {} + self.hhcs = {} self.popup_windows = {} # s_sites = doc.getElementsByTagName("supported_sites") @@ -295,6 +305,11 @@ class Config: aw = Aux_window(node = aw_node) self.aux_windows[aw.name] = aw +# s_dbs = doc.getElementsByTagName("mucked_windows") + for hhc_node in doc.getElementsByTagName("hhc"): + hhc = HHC(node = hhc_node) + self.hhcs[hhc.site] = hhc + # s_dbs = doc.getElementsByTagName("popup_windows") for pu_node in doc.getElementsByTagName("pu"): pu = Popup(node = pu_node) @@ -696,6 +711,11 @@ if __name__== "__main__": for w in c.aux_windows.keys(): print c.aux_windows[w] print "----------- END AUX WINDOW FORMATS -----------" + + print "\n----------- HAND HISTORY CONVERTERS -----------" + for w in c.hhcs.keys(): + print c.hhcs[w] + print "----------- END HAND HISTORY CONVERTERS -----------" print "\n----------- POPUP WINDOW FORMATS -----------" for w in c.popup_windows.keys(): diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 1a62a37d..35563fe3 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -66,10 +66,10 @@ class GuiBulkImport(): self.importer.setDropIndexes(cb_model[cb_index][0]) else: self.importer.setDropIndexes("auto") - hhc=self.cbfilter.get_model()[self.cbfilter.get_active()][0] + sitename = self.cbfilter.get_model()[self.cbfilter.get_active()][0] self.lab_info.set_text("Importing") - self.importer.addBulkImportImportFileOrDir(self.inputFile,filter=hhc) + self.importer.addBulkImportImportFileOrDir(self.inputFile, site = sitename) self.importer.setCallHud(False) starttime = time() (stored, dups, partial, errs, ttime) = self.importer.runImport() @@ -175,11 +175,9 @@ class GuiBulkImport(): # ComboBox - filter self.cbfilter = gtk.combo_box_new_text() - self.cbfilter.append_text("passthrough") - self.cbfilter.append_text("BetfairToFpdb") - self.cbfilter.append_text("EverleafToFpdb") - self.cbfilter.append_text("FulltiltToFpdb") - self.cbfilter.append_text("PokerStarsToFpdb") + for w in self.config.hhcs: + print w + self.cbfilter.append_text(w) self.cbfilter.set_active(0) self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK) self.cbfilter.show() @@ -223,7 +221,7 @@ def main(argv=None): parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui; deprecated (just give a filename with -f).") parser.add_option("-c", "--convert", dest="filtername", default="passthrough", metavar="FILTER", - help="Conversion filter (*passthrough, FullTiltToFpdb, PokerStarsToFpdb, EverleafToFpdb)") + help="Conversion filter (*Full Tilt Poker, PokerStars, Everleaf)") parser.add_option("-x", "--failOnError", action="store_true", default=False, help="If this option is passed it quits when it encounters any error") parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int", @@ -258,7 +256,7 @@ def main(argv=None): importer = fpdb_import.Importer(False,settings, config) importer.setDropIndexes("auto") importer.setFailOnError(options.failOnError) - importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), filter=options.filtername) + importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), site=options.filtername) importer.setCallHud(False) importer.runImport() importer.clearFileList() diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example index f7351526..ad7d440b 100644 --- a/pyfpdb/HUD_config.xml.example +++ b/pyfpdb/HUD_config.xml.example @@ -2,7 +2,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -84,7 +84,7 @@ - + @@ -198,6 +198,11 @@ + + + + + diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 5ce23928..68373fb0 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -126,18 +126,18 @@ class Importer: # Called from GuiBulkImport to add a file or directory. - def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"): + def addBulkImportImportFileOrDir(self, inputPath, site = "PokerStars"): """Add a file or directory for bulk import""" - + filter = self.config.hhcs[site].converter # Bulk import never monitors # if directory, add all files in it. Otherwise add single file. # TODO: only add sane files? if os.path.isdir(inputPath): for subdir in os.walk(inputPath): for file in subdir[2]: - self.addImportFile(os.path.join(inputPath, subdir[0], file), site="default", filter=filter) + self.addImportFile(os.path.join(inputPath, subdir[0], file), site=site, filter=filter) else: - self.addImportFile(inputPath, site="default", filter=filter) + self.addImportFile(inputPath, site=site, filter=filter) #Add a directory of files to filelist #Only one import directory per site supported. #dirlist is a hash of lists: diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index 0badbb82..750b1512 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -60,7 +60,7 @@ def mainParser(backend, db, cursor, siteID, category, hand, config): fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo) - hand=fpdb_simple.filterCrap(site, hand, isTourney) + hand=fpdb_simple.filterCrap(hand, isTourney) #part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets)