diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-09-06 19:37:14 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-09-07 11:14:02 +0200 |
commit | d39200c7f461d3dc97f50a01d396112bdfa5bd07 (patch) | |
tree | aadc2d8a815ac36f5e9a440eb150b49f4543c1a0 | |
parent | 55493f2011d5e6e1189f5d1d3b1fc350c554a643 (diff) | |
download | node-new-d39200c7f461d3dc97f50a01d396112bdfa5bd07.tar.gz |
tools: make utils.SearchFiles Python2-compatible
PR-URL: https://github.com/nodejs/node/pull/40020
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
-rw-r--r-- | tools/utils.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/utils.py b/tools/utils.py index e9b38c87b0..b8963e0b52 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -26,7 +26,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import glob +import os import platform import re import sys @@ -111,7 +111,11 @@ def IsWindows(): def SearchFiles(dir, ext): - list = glob.glob(dir+ '/**/*.' + ext, recursive=True) + matching_files = [] + for path, dirs, files in os.walk(dir): + for file in files: + if file.endswith('.' + ext): + matching_files.append(path + '/' + file) if sys.platform == 'win32': - list = [ x.replace('\\', '/')for x in list] - return list + matching_files = [x.replace('\\', '/') for x in matching_files] + return matching_files |