summaryrefslogtreecommitdiff
path: root/tools/util.py
diff options
context:
space:
mode:
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