Commit 1fdd0ca7 authored by Robert Bradshaw's avatar Robert Bradshaw

Print error on non-matching glob source input.

Also extend glob to support bash {a,b,c} notation (needed for Cythonize script).
parent 84f02068
......@@ -74,8 +74,7 @@ def cython_compile(path_pattern, options):
if os.path.isdir(path):
# recursively compiling a package
paths = [os.path.join(path, '**', '*.%s' % ext)
for ext in ('py', 'pyx')]
paths = [os.path.join(path, '**', '*.{py,pyx}')]
else:
# assume it's a file(-like thing)
paths = [path]
......
......@@ -65,6 +65,14 @@ else:
basestring = str
def extended_iglob(pattern):
if '{' in pattern:
m = re.match('(.*){([^}]+)}(.*)', pattern)
if m:
before, switch, after = m.groups()
for case in switch.split(','):
for path in extended_iglob(before + case + after):
yield path
return
if '**/' in pattern:
seen = set()
first, rest = pattern.split('**/', 1)
......@@ -85,6 +93,14 @@ def extended_iglob(pattern):
for path in iglob(pattern):
yield path
def nonempty(iter, error_msg="expected non-empty iterator"):
any = False
for file in iter:
any = True
yield file
if not any:
raise ValueError(error_msg)
@cached_function
def file_hash(filename):
path = os.path.normpath(filename.encode("UTF-8"))
......@@ -627,7 +643,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
else:
raise TypeError(pattern)
for file in extended_iglob(filepattern):
for file in nonempty(extended_iglob(filepattern), "'%s' doesn't match any files" % filepattern):
if os.path.abspath(file) in to_exclude:
continue
pkg = deps.package(file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment