diff options
author | Bert Belder <bertbelder@gmail.com> | 2018-10-23 18:51:06 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2018-10-23 18:51:06 +0200 |
commit | e9bf2064164df4f5712addca2cd4d18faf3e149a (patch) | |
tree | 96f477578e4b856568390a710a489df184854cc8 /tools/util.py | |
parent | 0dda87f962b2209be1734f4fe6bb1ba9f6c0e66b (diff) |
format: don't format files in third_party
It's annoying, and it also makes appveyor slow because it will re-upload
the third_party cache every time something changes in there.
Diffstat (limited to 'tools/util.py')
-rw-r--r-- | tools/util.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/util.py b/tools/util.py index 2cb22ed6a..306f2109f 100644 --- a/tools/util.py +++ b/tools/util.py @@ -131,15 +131,24 @@ def touch(fname): # Recursive search for files of certain extensions. -# (Recursive glob doesn't exist in python 2.7.) -def find_exts(directory, *extensions): +# * Recursive glob doesn't exist in python 2.7. +# * On windows, `os.walk()` unconditionally follows symlinks. +# The `skip` parameter should be used to avoid recursing through those. +def find_exts(directories, extensions, skip=[]): + assert isinstance(directories, list) + assert isinstance(extensions, list) + skip = [os.path.normpath(i) for i in skip] matches = [] - for root, dirnames, filenames in os.walk(directory): - for filename in filenames: - for ext in extensions: - if filename.endswith(ext): - matches.append(os.path.join(root, filename)) - break + for directory in directories: + for root, dirnames, filenames in os.walk(directory): + if root in skip: + dirnames[:] = [] # Don't recurse further into this directory. + continue + for filename in filenames: + for ext in extensions: + if filename.endswith(ext): + matches.append(os.path.join(root, filename)) + break return matches |