Browse code

fix os.walk() exclusions for new upstream code

Matt Domsch authored on 2012/02/28 06:07:30
Showing 1 changed files
... ...
@@ -27,13 +27,15 @@ def _fswalk_follow_symlinks(path):
27 27
         assert os.path.isdir(path) # only designed for directory argument
28 28
         walkdirs = [path]
29 29
         for dirpath, dirnames, filenames in os.walk(path):
30
+ 		handle_exclude_include_walk(dirpath, dirnames, [])
30 31
                 for dirname in dirnames:
31 32
                         current = os.path.join(dirpath, dirname)
32 33
                         if os.path.islink(current):
33 34
 				walkdirs.append(current)
34 35
         for walkdir in walkdirs:
35
-                for value in os.walk(walkdir):
36
-                        yield value
36
+		for dirpath, dirnames, filenames in os.walk(walkdir):
37
+			handle_exclude_include_walk(dirpath, dirnames, [])
38
+                        yield (dirpath, dirnames, filenames)
37 39
 
38 40
 def _fswalk(path, follow_symlinks):
39 41
         '''
... ...
@@ -44,8 +46,10 @@ def _fswalk(path, follow_symlinks):
44 44
         follow_symlinks (bool) indicates whether to descend into symbolically linked directories
45 45
         '''
46 46
         if follow_symlinks:
47
-                return _fswalk_follow_symlinks(path)
48
-        return os.walk(path)
47
+                yield _fswalk_follow_symlinks(path)
48
+	for dirpath, dirnames, filenames in os.walk(path):
49
+		handle_exclude_include_walk(dirpath, dirnames, filenames)
50
+		yield (dirpath, dirnames, filenames)
49 51
 
50 52
 def filter_exclude_include(src_list):
51 53
     info(u"Applying --exclude/--include")
... ...
@@ -147,7 +151,6 @@ def fetch_local_list(args, recursive = None):
147 147
             single_file = True
148 148
         loc_list = SortedDict(ignore_case = False)
149 149
         for root, dirs, files in filelist:
150
-	    handle_exclude_include_walk(root, dirs, files)
151 150
             rel_root = root.replace(local_path, local_base, 1)
152 151
             for f in files:
153 152
                 full_name = os.path.join(root, f)