From e5489056ff86fd113e385752dc519743ab83e99b Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Wed, 25 Feb 2009 14:59:11 +0000 Subject: [PATCH] less broken, please check sanity --- pyfpdb/GuiBulkImport.py | 2 +- pyfpdb/fpdb_import.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 376ceb47..46ac3f0f 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -55,7 +55,7 @@ class GuiBulkImport(): hhc=self.cbfilter.get_model()[self.cbfilter.get_active()][0] self.lab_info.set_text("Importing") - self.importer.addImportFile(self.inputFile,filter=hhc) + self.importer.addBulkImportImportFileOrDir(self.inputFile,filter=hhc) self.importer.setCallHud(False) starttime = time() (stored, dups, partial, errs, ttime) = self.importer.runImport() diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 49657762..607cf96a 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -113,6 +113,20 @@ class Importer: #TODO: test it is a valid file -> put that in config!! self.filelist[filename] = [site] + [filter] + # Called from GuiBulkImport to add a file or directory. + def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"): + """Add a file or directory for bulk import""" + # 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, file), site="default", filter=filter) + else: + self.addImportFile(inputPath, site="default", filter=filter) + #Add a directory of files to filelist #Only one import directory per site supported. #dirlist is a hash of lists: