Skip to content

Commit d39200c

Browse files
committed
tools: make utils.SearchFiles Python2-compatible
PR-URL: #40020 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 55493f2 commit d39200c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tools/utils.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

2828

29-
import glob
29+
import os
3030
import platform
3131
import re
3232
import sys
@@ -111,7 +111,11 @@ def IsWindows():
111111

112112

113113
def SearchFiles(dir, ext):
114-
list = glob.glob(dir+ '/**/*.' + ext, recursive=True)
114+
matching_files = []
115+
for path, dirs, files in os.walk(dir):
116+
for file in files:
117+
if file.endswith('.' + ext):
118+
matching_files.append(path + '/' + file)
115119
if sys.platform == 'win32':
116-
list = [ x.replace('\\', '/')for x in list]
117-
return list
120+
matching_files = [x.replace('\\', '/') for x in matching_files]
121+
return matching_files

0 commit comments

Comments
 (0)