From d39200c7f461d3dc97f50a01d396112bdfa5bd07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 6 Sep 2021 19:37:14 +0200 Subject: [PATCH] tools: make utils.SearchFiles Python2-compatible PR-URL: https://github.com/nodejs/node/pull/40020 Reviewed-By: Christian Clauss Reviewed-By: Richard Lau --- tools/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/utils.py b/tools/utils.py index e9b38c87b04b70..b8963e0b5240b9 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