Change the filelist and dirlist type to be a hash of lists, delete postgres sql schema
dirlist is in the form:
{'Site': [ "/path/to/dir", "filter" ] }
Where filter will be the plugin to convert to stars/fpdb hand history file.
filelist is in the form:
{'file': [ "site", "filter" ] }
This commit is contained in:
+13
-20
@@ -47,8 +47,8 @@ class Importer:
|
||||
self.caller=caller
|
||||
self.db = None
|
||||
self.cursor = None
|
||||
self.filelist = []
|
||||
self.dirlist = []
|
||||
self.filelist = {}
|
||||
self.dirlist = {}
|
||||
self.monitor = False
|
||||
self.updated = {} #Time last import was run {file:mtime}
|
||||
self.callHud = False
|
||||
@@ -100,29 +100,25 @@ class Importer:
|
||||
# self.updated = time()
|
||||
|
||||
def clearFileList(self):
|
||||
self.filelist = []
|
||||
self.filelist = {}
|
||||
|
||||
#Add an individual file to filelist
|
||||
def addImportFile(self, filename):
|
||||
def addImportFile(self, filename, site = "default", filter = "passthrough"):
|
||||
#TODO: test it is a valid file
|
||||
self.filelist = self.filelist + [filename]
|
||||
#Remove duplicates
|
||||
self.filelist = list(set(self.filelist))
|
||||
self.filelist[filename] = [site] + [filter]
|
||||
|
||||
#Add a directory of files to filelist
|
||||
def addImportDirectory(self,dir,monitor = False, filter = "passthrough"):
|
||||
#Only one import directory per site supported.
|
||||
#dirlist is a hash of lists:
|
||||
#dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] }
|
||||
def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"):
|
||||
if os.path.isdir(dir):
|
||||
if monitor == True:
|
||||
self.monitor = True
|
||||
self.dirlist = self.dirlist + [dir]
|
||||
self.dirlist[site] = [dir] + [filter]
|
||||
|
||||
for file in os.listdir(dir):
|
||||
if os.path.isdir(file):
|
||||
print "BulkImport is not recursive - please select the final directory in which the history files are"
|
||||
else:
|
||||
self.filelist = self.filelist + [os.path.join(dir, file)]
|
||||
#Remove duplicates
|
||||
self.filelist = list(set(self.filelist))
|
||||
self.addImportFile(os.path.join(dir, file), site, filter)
|
||||
else:
|
||||
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
|
||||
|
||||
@@ -136,11 +132,8 @@ class Importer:
|
||||
#Check for new files in directory
|
||||
#todo: make efficient - always checks for new file, should be able to use mtime of directory
|
||||
# ^^ May not work on windows
|
||||
for dir in self.dirlist:
|
||||
for file in os.listdir(dir):
|
||||
self.filelist = self.filelist + [os.path.join(dir, file)]
|
||||
|
||||
self.filelist = list(set(self.filelist))
|
||||
for site in self.dirlist:
|
||||
self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
|
||||
|
||||
for file in self.filelist:
|
||||
stat_info = os.stat(file)
|
||||
|
||||
Reference in New Issue
Block a user