From 58a7d5c595a74e266d63fd5e621329ba24d4e75e Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Tue, 20 Apr 2010 13:28:27 +0000 Subject: Fix the updated code that uses os.walk() to remove matched directories. Also remove any .svn directories we find. --- src/test_strings.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test_strings.py b/src/test_strings.py index 16b0b9a..c6b1179 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -88,15 +88,19 @@ class Checker: def find_missing(self): result = [] for dirpath, dirnames, filenames in os.walk(self.directory): + if '.svn' in dirnames: + dirnames.remove('.svn') + for dname in dirnames[:]: + dpath = os.path.join(dirpath, dname) + if self.remove_this(dname, dpath): + dirnames.remove(dname) for fname in filenames: fpath = os.path.join(dirpath, fname) - if self.remove_this(fname, fpath): - result.remove(fname) - elif self.search_this(fpath): - body = open(path, 'r').read() + if self.search_this(fpath) and not self.remove_this(fname, fpath): + body = open(fpath, 'r').read() for expr in self.expressions: if not expr.search(body): - msg = '%s: missing %s' % (path, repr(expr.pattern)) + msg = '%s: missing %s' % (fpath, repr(expr.pattern)) result.append(msg) return result -- cgit v0.12