From 560cb1a543b481415764b88448210b7d5b0562ac Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 25 Feb 2009 22:44:03 -0500 Subject: [PATCH] fpdb_import runUpdated() will now remove files that were found to be newly missing on it's most recent pass from it's list of files to check --- pyfpdb/fpdb_import.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ca9167e8..aa40b218 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -61,6 +61,7 @@ class Importer: self.filelist = {} self.dirlist = {} self.addToDirList = {} + self.removeFromFileList = {} # to remove deleted files self.monitor = False self.updated = {} #Time last import was run {file:mtime} self.lines = None @@ -187,8 +188,12 @@ class Importer: for dir in self.addToDirList: self.addImportDirectory(dir, True, self.addToDirList[dir][0], self.addToDirList[dir][1]) + + for file in self.removeFromFileList: + del self.filelist[file] self.addToDirList = {} + self.removeFromFileList = {} # This is now an internal function that should not be called directly. def import_file_dict(self, file, site, filter): @@ -235,10 +240,15 @@ class Importer: if (file=="stdin"): inputFile=sys.stdin else: + if os.path.exists(file): + inputFile = open(file, "rU") + else: + self.removeFromFileList['file'] = True + return try: - inputFile=open(file, "rU") loc = self.pos_in_file[file] - except: pass + except: + pass # Read input file into class and close file inputFile.seek(loc)