Fix TODO item - detect if directory passed in is a valid directory
This commit is contained in:
parent
87af99847b
commit
9bb8e229e4
|
@ -104,25 +104,27 @@ class Importer:
|
||||||
|
|
||||||
#Add an individual file to filelist
|
#Add an individual file to filelist
|
||||||
def addImportFile(self, filename):
|
def addImportFile(self, filename):
|
||||||
#todo: test it is a valid file
|
#TODO: test it is a valid file
|
||||||
self.filelist = self.filelist + [filename]
|
self.filelist = self.filelist + [filename]
|
||||||
#Remove duplicates
|
#Remove duplicates
|
||||||
self.filelist = list(set(self.filelist))
|
self.filelist = list(set(self.filelist))
|
||||||
|
|
||||||
#Add a directory of files to filelist
|
#Add a directory of files to filelist
|
||||||
def addImportDirectory(self,dir,monitor = False):
|
def addImportDirectory(self,dir,monitor = False):
|
||||||
#todo: test it is a valid directory
|
if os.path.isdir(dir):
|
||||||
if monitor == True:
|
if monitor == True:
|
||||||
self.monitor = True
|
self.monitor = True
|
||||||
self.dirlist = self.dirlist + [dir]
|
self.dirlist = self.dirlist + [dir]
|
||||||
|
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if os.path.isdir(file):
|
if os.path.isdir(file):
|
||||||
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.filelist = self.filelist + [os.path.join(dir, file)]
|
self.filelist = self.filelist + [os.path.join(dir, file)]
|
||||||
#Remove duplicates
|
#Remove duplicates
|
||||||
self.filelist = list(set(self.filelist))
|
self.filelist = list(set(self.filelist))
|
||||||
|
else:
|
||||||
|
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
|
||||||
|
|
||||||
#Run full import on filelist
|
#Run full import on filelist
|
||||||
def runImport(self):
|
def runImport(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user