summaryrefslogtreecommitdiff
path: root/winbuild
diff options
context:
space:
mode:
authorwinbuild <winbuild@example.com>2020-01-28 11:32:13 -0500
committerwinbuild <winbuild@example.com>2020-01-28 11:32:13 -0500
commitbc65d18565150a943b63f27d7b1e6bd9a65612f2 (patch)
tree7b1885da4eb2261caefcacaa1d428901d4b2a02d /winbuild
parent804adb6b9840c3aae744037b4a56292d32ff48d7 (diff)
downloadpycurl-bc65d18565150a943b63f27d7b1e6bd9a65612f2.tar.gz
Allow picking different matching files
Diffstat (limited to 'winbuild')
-rw-r--r--winbuild/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/winbuild/utils.py b/winbuild/utils.py
index e6ffe8b..8f1dfde 100644
--- a/winbuild/utils.py
+++ b/winbuild/utils.py
@@ -78,7 +78,7 @@ def fix_slashes(path):
# Returns the first path matching the pattern, where pattern is anything the
# standard library glob module recognizes plus {a,b,c} alterations.
# Raises an exception if no paths matched the pattern.
-def glob_first(pattern):
+def glob_first(pattern, selector=None):
# python's glob does not support {}
final_patterns = []
pattern_queue = [pattern]
@@ -93,5 +93,8 @@ def glob_first(pattern):
for pattern in final_patterns:
paths = glob.glob(pattern)
if paths:
- return paths[0]
+ if selector:
+ return selector(paths)
+ else:
+ return paths[0]
raise Exception("Not found: %s" % pattern)