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): ...@@ -74,8 +74,7 @@ def cython_compile(path_pattern, options):
if os.path.isdir(path): if os.path.isdir(path):
# recursively compiling a package # recursively compiling a package
paths = [os.path.join(path, '**', '*.%s' % ext) paths = [os.path.join(path, '**', '*.{py,pyx}')]
for ext in ('py', 'pyx')]
else: else:
# assume it's a file(-like thing) # assume it's a file(-like thing)
paths = [path] paths = [path]
......
...@@ -65,6 +65,14 @@ else: ...@@ -65,6 +65,14 @@ else:
basestring = str basestring = str
def extended_iglob(pattern): 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: if '**/' in pattern:
seen = set() seen = set()
first, rest = pattern.split('**/', 1) first, rest = pattern.split('**/', 1)
...@@ -85,6 +93,14 @@ def extended_iglob(pattern): ...@@ -85,6 +93,14 @@ def extended_iglob(pattern):
for path in iglob(pattern): for path in iglob(pattern):
yield path 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 @cached_function
def file_hash(filename): def file_hash(filename):
path = os.path.normpath(filename.encode("UTF-8")) path = os.path.normpath(filename.encode("UTF-8"))
...@@ -627,7 +643,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa ...@@ -627,7 +643,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
else: else:
raise TypeError(pattern) 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: if os.path.abspath(file) in to_exclude:
continue continue
pkg = deps.package(file) 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