Commit 1030b3c6 authored by Reinout van Rees's avatar Reinout van Rees

In-place editing of os.walk results

The [:] is necessary to edit the os.walk results in-place. Otherwise the
filtering-out of .svn, CVS and so doesn't work as intended.
(Note: this regression I put in was caught by one of the tests! Good that
we've got such a large amount of tests!)
parent be8bc821
...@@ -1602,7 +1602,7 @@ def _open(base, filename, seen, dl_options, override, downloaded): ...@@ -1602,7 +1602,7 @@ def _open(base, filename, seen, dl_options, override, downloaded):
return result return result
ignore_directories = u'.svn', u'CVS', u'__pycache__' ignore_directories = '.svn', 'CVS', '__pycache__'
_dir_hashes = {} _dir_hashes = {}
def _dir_hash(dir): def _dir_hash(dir):
dir = fs_to_text(dir) dir = fs_to_text(dir)
...@@ -1613,13 +1613,13 @@ def _dir_hash(dir): ...@@ -1613,13 +1613,13 @@ def _dir_hash(dir):
return dir_hash return dir_hash
hash = md5() hash = md5()
for (dirpath, dirnames, filenames) in os.walk(dir): for (dirpath, dirnames, filenames) in os.walk(dir):
dirnames = [fs_to_text(dirname) for dirname in dirnames] dirnames[:] = [fs_to_text(dirname) for dirname in dirnames]
filenames = [fs_to_text(filename) for filename in filenames] filenames[:] = [fs_to_text(filename) for filename in filenames]
dirnames[:] = sorted(n for n in dirnames if n not in ignore_directories) dirnames[:] = sorted(n for n in dirnames if n not in ignore_directories)
filenames[:] = sorted(f for f in filenames filenames[:] = sorted(f for f in filenames
if (not (f.endswith('pyc') or f.endswith('pyo')) if (not (f.endswith('pyc') or f.endswith('pyo'))
and os.path.exists(os.path.join(dirpath, f))) and os.path.exists(os.path.join(dirpath, f)))
) )
hash.update(' '.join(dirnames).encode('utf-8')) hash.update(' '.join(dirnames).encode('utf-8'))
hash.update(' '.join(filenames).encode('utf-8')) hash.update(' '.join(filenames).encode('utf-8'))
for name in filenames: for name in filenames:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment