robcowie/SublimeTODO

Exception when pattern in folder_exclude_patterns not found

niecw opened this issue · 0 comments

When the folder_exclude_patterns is set with something that is not found, it will generate the following Traceback:

  File "./todo.py", line 289, in run
  File "./todo.py", line 226, in format
  File "./todo.py", line 169, in extract
  File "./todo.py", line 155, in filter_files
  File "./todo.py", line 143, in iter_files
ValueError: list.remove(x): x not in list

The following patch if applied to todo.py seems to "cure' it:

@@ -140,7 +140,7 @@
                 ## remove excluded dirs
                 for dir in [dir for dir in exclude_dirs if dir in dirnames]:
                     self.log.debug('Ignoring dir: {0}'.format(dir))
-                    dirnames.remove(dir)
+                    (dir in dirnames) and dirnames.remove(dir)

                 for filepath in filenames:
                     pth = path.join(dirpath, filepath)