Turn fpdb_import functions into class Importer
Fix all callers of fpdb_import
This commit is contained in:
parent
79651706f6
commit
98b556f42c
|
@ -57,7 +57,7 @@ class GuiAutoImport (threading.Thread):
|
||||||
self.inputFile = os.path.join(self.path, file)
|
self.inputFile = os.path.join(self.path, file)
|
||||||
stat_info = os.stat(self.inputFile)
|
stat_info = os.stat(self.inputFile)
|
||||||
if not self.import_files.has_key(self.inputFile) or stat_info.st_mtime > self.import_files[self.inputFile]:
|
if not self.import_files.has_key(self.inputFile) or stat_info.st_mtime > self.import_files[self.inputFile]:
|
||||||
fpdb_import.import_file_dict(self, self.settings, callHud = True)
|
self.importer.import_file_dict(self, self.settings, callHud = True)
|
||||||
self.import_files[self.inputFile] = stat_info.st_mtime
|
self.import_files[self.inputFile] = stat_info.st_mtime
|
||||||
|
|
||||||
print "GuiAutoImport.import_dir done"
|
print "GuiAutoImport.import_dir done"
|
||||||
|
@ -121,6 +121,7 @@ class GuiAutoImport (threading.Thread):
|
||||||
def __init__(self, settings, debug=True):
|
def __init__(self, settings, debug=True):
|
||||||
"""Constructor for GuiAutoImport"""
|
"""Constructor for GuiAutoImport"""
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
|
self.importer = fpdb_import.Importer()
|
||||||
|
|
||||||
self.server=settings['db-host']
|
self.server=settings['db-host']
|
||||||
self.user=settings['db-user']
|
self.user=settings['db-user']
|
||||||
|
|
|
@ -32,7 +32,7 @@ class GuiBulkImport (threading.Thread):
|
||||||
print "BulkImport is not recursive - please select the final directory in which the history files are"
|
print "BulkImport is not recursive - please select the final directory in which the history files are"
|
||||||
else:
|
else:
|
||||||
self.inputFile=self.path+os.sep+file
|
self.inputFile=self.path+os.sep+file
|
||||||
fpdb_import.import_file_dict(self, self.settings, False)
|
self.importer.import_file_dict(self, self.settings, False)
|
||||||
print "GuiBulkImport.import_dir done"
|
print "GuiBulkImport.import_dir done"
|
||||||
|
|
||||||
def load_clicked(self, widget, data=None):
|
def load_clicked(self, widget, data=None):
|
||||||
|
@ -69,7 +69,7 @@ class GuiBulkImport (threading.Thread):
|
||||||
if os.path.isdir(self.inputFile):
|
if os.path.isdir(self.inputFile):
|
||||||
self.import_dir()
|
self.import_dir()
|
||||||
else:
|
else:
|
||||||
fpdb_import.import_file_dict(self, self.settings, False)
|
self.importer.import_file_dict(self, self.settings, False)
|
||||||
|
|
||||||
def get_vbox(self):
|
def get_vbox(self):
|
||||||
"""returns the vbox of this thread"""
|
"""returns the vbox of this thread"""
|
||||||
|
@ -83,6 +83,7 @@ class GuiBulkImport (threading.Thread):
|
||||||
def __init__(self, db, settings):
|
def __init__(self, db, settings):
|
||||||
self.db=db
|
self.db=db
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
|
self.importer = fpdb_import.Importer()
|
||||||
|
|
||||||
self.vbox=gtk.VBox(False,1)
|
self.vbox=gtk.VBox(False,1)
|
||||||
self.vbox.show()
|
self.vbox.show()
|
||||||
|
|
|
@ -255,8 +255,9 @@ class GuiTableViewer (threading.Thread):
|
||||||
self.failOnError=False
|
self.failOnError=False
|
||||||
self.minPrint=0
|
self.minPrint=0
|
||||||
self.handCount=0
|
self.handCount=0
|
||||||
|
self.importer = fpdb_import.Importer()
|
||||||
|
|
||||||
self.last_read_hand_id=fpdb_import.import_file_dict(self, self.settings, False)
|
self.last_read_hand_id=importer.import_file_dict(self, self.settings, False)
|
||||||
#end def table_viewer.import_clicked
|
#end def table_viewer.import_clicked
|
||||||
|
|
||||||
def all_clicked(self, widget, data):
|
def all_clicked(self, widget, data):
|
||||||
|
|
0
pyfpdb/HUD_main.py
Normal file → Executable file
0
pyfpdb/HUD_main.py
Normal file → Executable file
|
@ -32,6 +32,7 @@ import GuiBulkImport
|
||||||
import GuiTableViewer
|
import GuiTableViewer
|
||||||
import GuiAutoImport
|
import GuiAutoImport
|
||||||
import GuiGraphViewer
|
import GuiGraphViewer
|
||||||
|
import FpdbSQLQueries
|
||||||
|
|
||||||
class fpdb:
|
class fpdb:
|
||||||
def tab_clicked(self, widget, tab_name):
|
def tab_clicked(self, widget, tab_name):
|
||||||
|
|
|
@ -38,17 +38,22 @@ import fpdb_simple
|
||||||
import fpdb_parse_logic
|
import fpdb_parse_logic
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
class Importer:
|
||||||
|
|
||||||
def import_file(server, database, user, password, inputFile):
|
def __init__(self):
|
||||||
|
"""Constructor"""
|
||||||
|
|
||||||
|
|
||||||
|
def import_file(self, server, database, user, password, inputFile):
|
||||||
self.server=server
|
self.server=server
|
||||||
self.database=database
|
self.database=database
|
||||||
self.user=user
|
self.user=user
|
||||||
self.password=password
|
self.password=password
|
||||||
self.inputFile=inputFile
|
self.inputFile=inputFile
|
||||||
self.settings={'imp-callFpdbHud':False}
|
self.settings={'imp-callFpdbHud':False}
|
||||||
import_file_dict(self, settings)
|
self.import_file_dict(self, settings)
|
||||||
|
|
||||||
def import_file_dict(options, settings, callHud=False):
|
def import_file_dict(self, options, settings, callHud=False):
|
||||||
last_read_hand=0
|
last_read_hand=0
|
||||||
if (options.inputFile=="stdin"):
|
if (options.inputFile=="stdin"):
|
||||||
inputFile=sys.stdin
|
inputFile=sys.stdin
|
||||||
|
@ -225,4 +230,4 @@ if __name__ == "__main__":
|
||||||
(options, sys.argv) = parser.parse_args()
|
(options, sys.argv) = parser.parse_args()
|
||||||
|
|
||||||
settings={'imp-callFpdbHud':False, 'db-backend':2}
|
settings={'imp-callFpdbHud':False, 'db-backend':2}
|
||||||
import_file_dict(options, settings, False)
|
# import_file_dict(options, settings, False)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user