summaryrefslogtreecommitdiff
path: root/tools/util.py
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-07-23 12:44:27 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-07-24 12:29:54 -0400
commit7baf8a0fd1ed1590ea00c4ab1412f29535cd68a5 (patch)
treed132394b199151fc5b3a5c7be51f3072169c5311 /tools/util.py
parent1de16af1f3916c94b46e28fb22584dc1e7c17958 (diff)
Fix recursive globbing in tools/format.py
And use third_party/depot_tools/gn.
Diffstat (limited to 'tools/util.py')
-rw-r--r--tools/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/util.py b/tools/util.py
index 4141396df..4938c5157 100644
--- a/tools/util.py
+++ b/tools/util.py
@@ -55,3 +55,16 @@ def touch(fname):
os.utime(fname, None)
else:
open(fname, 'a').close()
+
+
+# Recursive search for files of certain extensions.
+# (Recursive glob doesn't exist in python 2.7.)
+def find_exts(directory, *extensions):
+ 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
+ return matches