[CMF-checkins] SVN: CMF/trunk/CMFCore/DirectoryView.py Forward-port fix from collector #367 from the 1.5 branch.

Tres Seaver tseaver at palladion.com
Thu Jul 21 13:39:33 EDT 2005


Log message for revision 37370:
  Forward-port fix from collector #367 from the 1.5 branch.

Changed:
  U   CMF/trunk/CMFCore/DirectoryView.py

-=-
Modified: CMF/trunk/CMFCore/DirectoryView.py
===================================================================
--- CMF/trunk/CMFCore/DirectoryView.py	2005-07-21 17:07:53 UTC (rev 37369)
+++ CMF/trunk/CMFCore/DirectoryView.py	2005-07-21 17:39:33 UTC (rev 37370)
@@ -59,14 +59,19 @@
 
 class _walker:
     def __init__(self, ignore=ignore):
-        self.ignore = ignore
+        # make a dict for faster lookup
+        self.ignore = dict([(x, None) for x in ignore])
 
     def __call__(self, listdir, dirname, names):
-        names = [ (name, stat(path.join(dirname,name))[8])
-                  for name
-                  in names
-                  if name not in self.ignore and not ignore_re.match(name) ]
-        listdir.extend(names)
+        # filter names inplace, so filtered directories don't get visited
+        names[:] = [ name
+                     for name
+                     in names
+                     if name not in self.ignore and not ignore_re.match(name) ]
+        # append with stat info
+        results = [ (name, stat(path.join(dirname,name))[8])
+                    for name in names ]
+        listdir.extend(results)
 
 class DirectoryInformation:
     data = None



More information about the CMF-checkins mailing list