diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index 41c3c4ff..d5deeeb8 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -43,6 +43,7 @@ out_path (default '-' = sys.stdout) follow : whether to tail -f the input autostart: whether to run the thread (or you can call start() yourself) debugging: if False, pass on partially supported game types. If true, have a go and error...""" + print "DEBUG: XXXXXXXXXXXXXXX" HandHistoryConverter.__init__(self, in_path, out_path, sitename="Everleaf", follow=follow) logging.info("Initialising Everleaf converter class") self.filetype = "text" diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index 4455961a..fb2bf6ea 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -22,9 +22,9 @@ import sys import logging from HandHistoryConverter import * -# FullTilt HH Format converter +# Fulltilt HH Format converter -class FullTilt(HandHistoryConverter): +class Fulltilt(HandHistoryConverter): # Static regexes re_GameInfo = re.compile('- (?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+) (Ante \$(?P[.0-9]+) )?- (?P(No Limit|Pot Limit|Limit))? (?P(Hold\'em|Omaha Hi|Razz))') @@ -39,8 +39,8 @@ class FullTilt(HandHistoryConverter): in_path (default '-' = sys.stdin) out_path (default '-' = sys.stdout) follow : whether to tail -f the input""" - HandHistoryConverter.__init__(self, in_path, out_path, sitename="FullTilt", follow=follow) - logging.info("Initialising FullTilt converter class") + HandHistoryConverter.__init__(self, in_path, out_path, sitename="Fulltilt", follow=follow) + logging.info("Initialising Fulltilt converter class") self.filetype = "text" self.codepage = "cp1252" if autostart: @@ -314,4 +314,4 @@ if __name__ == "__main__": LOG_FILENAME = './logging.out' logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity) - e = FullTilt(in_path = options.ipath, out_path = options.opath, follow = options.follow) + e = Fulltilt(in_path = options.ipath, out_path = options.opath, follow = options.follow) diff --git a/pyfpdb/Utils.py b/pyfpdb/Utils.py deleted file mode 100644 index f7827451..00000000 --- a/pyfpdb/Utils.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright 2009, Carl Gherardi -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -######################################################################## - -def importName(module_name, name): - """Import a named object 'name' from module 'module_name'.""" -# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!! - try: - module = __import__(module_name, globals(), locals(), [name]) - except: - return None - return(getattr(module, name)) - diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 2b4a2d88..8c4bd0f9 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -33,8 +33,6 @@ import fpdb_simple import fpdb_db import fpdb_parse_logic import Configuration -import EverleafToFpdb -import FulltiltToFpdb # database interface modules try: @@ -238,21 +236,22 @@ class Importer: except: out_path = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file)) - # someone can just create their own python module for it - if filter in ("EverleafToFpdb","Everleaf"): - conv = EverleafToFpdb.Everleaf(in_path = file, out_path = out_path) - elif filter == "FulltiltToFpdb": - conv = FulltiltToFpdb.FullTilt(in_path = file, out_path = out_path) + filter_name = filter.replace("ToFpdb", "") + + mod = __import__(filter) + obj = getattr(mod, filter_name, None) + if callable(obj): + conv = obj(in_path = file, out_path = out_path) + if(conv.getStatus()): + (stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(out_path, site) + else: + # conversion didn't work + # TODO: appropriate response? + return (0, 0, 0, 1, 0) else: - print "Unknown filter ", filter + print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter) return - if(conv.getStatus()): - (stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(out_path, site) - else: - # conversion didn't work - # TODO: appropriate response? - return (0, 0, 0, 1, 0) #This will barf if conv.getStatus != True return (stored, duplicates, partial, errors, ttime)