Commit 4c21a8f1 authored by Stefan Behnel's avatar Stefan Behnel

clean up some code

parent 06f75b80
...@@ -64,6 +64,7 @@ else: ...@@ -64,6 +64,7 @@ else:
return filename return filename
basestring = str basestring = str
def extended_iglob(pattern): def extended_iglob(pattern):
if '{' in pattern: if '{' in pattern:
m = re.match('(.*){([^}]+)}(.*)', pattern) m = re.match('(.*){([^}]+)}(.*)', pattern)
...@@ -118,6 +119,7 @@ def file_hash(filename): ...@@ -118,6 +119,7 @@ def file_hash(filename):
f.close() f.close()
return m.hexdigest() return m.hexdigest()
def parse_list(s): def parse_list(s):
""" """
>>> parse_list("a b c") >>> parse_list("a b c")
...@@ -143,6 +145,7 @@ def parse_list(s): ...@@ -143,6 +145,7 @@ def parse_list(s):
return literal return literal
return [unquote(item) for item in s.split(delimiter) if item.strip()] return [unquote(item) for item in s.split(delimiter) if item.strip()]
transitive_str = object() transitive_str = object()
transitive_list = object() transitive_list = object()
...@@ -163,6 +166,7 @@ distutils_settings = { ...@@ -163,6 +166,7 @@ distutils_settings = {
'language': transitive_str, 'language': transitive_str,
} }
@cython.locals(start=cython.Py_ssize_t, end=cython.Py_ssize_t) @cython.locals(start=cython.Py_ssize_t, end=cython.Py_ssize_t)
def line_iter(source): def line_iter(source):
if isinstance(source, basestring): if isinstance(source, basestring):
...@@ -178,6 +182,7 @@ def line_iter(source): ...@@ -178,6 +182,7 @@ def line_iter(source):
for line in source: for line in source:
yield line yield line
class DistutilsInfo(object): class DistutilsInfo(object):
def __init__(self, source=None, exn=None): def __init__(self, source=None, exn=None):
...@@ -254,6 +259,7 @@ class DistutilsInfo(object): ...@@ -254,6 +259,7 @@ class DistutilsInfo(object):
value = getattr(extension, key) + list(value) value = getattr(extension, key) + list(value)
setattr(extension, key, value) setattr(extension, key, value)
@cython.locals(start=cython.Py_ssize_t, q=cython.Py_ssize_t, @cython.locals(start=cython.Py_ssize_t, q=cython.Py_ssize_t,
single_q=cython.Py_ssize_t, double_q=cython.Py_ssize_t, single_q=cython.Py_ssize_t, double_q=cython.Py_ssize_t,
hash_mark=cython.Py_ssize_t, end=cython.Py_ssize_t, hash_mark=cython.Py_ssize_t, end=cython.Py_ssize_t,
...@@ -349,9 +355,11 @@ dependency_regex = re.compile(r"(?:^from +([0-9a-zA-Z_.]+) +cimport)|" ...@@ -349,9 +355,11 @@ dependency_regex = re.compile(r"(?:^from +([0-9a-zA-Z_.]+) +cimport)|"
r"(?:^cdef +extern +from +['\"]([^'\"]+)['\"])|" r"(?:^cdef +extern +from +['\"]([^'\"]+)['\"])|"
r"(?:^include +['\"]([^'\"]+)['\"])", re.M) r"(?:^include +['\"]([^'\"]+)['\"])", re.M)
def normalize_existing(base_path, rel_paths): def normalize_existing(base_path, rel_paths):
return normalize_existing0(os.path.dirname(base_path), tuple(set(rel_paths))) return normalize_existing0(os.path.dirname(base_path), tuple(set(rel_paths)))
@cached_function @cached_function
def normalize_existing0(base_dir, rel_paths): def normalize_existing0(base_dir, rel_paths):
normalized = [] normalized = []
...@@ -363,6 +371,7 @@ def normalize_existing0(base_dir, rel_paths): ...@@ -363,6 +371,7 @@ def normalize_existing0(base_dir, rel_paths):
normalized.append(rel) normalized.append(rel)
return normalized return normalized
def resolve_depends(depends, include_dirs): def resolve_depends(depends, include_dirs):
include_dirs = tuple(include_dirs) include_dirs = tuple(include_dirs)
resolved = [] resolved = []
...@@ -372,6 +381,7 @@ def resolve_depends(depends, include_dirs): ...@@ -372,6 +381,7 @@ def resolve_depends(depends, include_dirs):
resolved.append(path) resolved.append(path)
return resolved return resolved
@cached_function @cached_function
def resolve_depend(depend, include_dirs): def resolve_depend(depend, include_dirs):
if depend[0] == '<' and depend[-1] == '>': if depend[0] == '<' and depend[-1] == '>':
...@@ -382,6 +392,7 @@ def resolve_depend(depend, include_dirs): ...@@ -382,6 +392,7 @@ def resolve_depend(depend, include_dirs):
return os.path.normpath(path) return os.path.normpath(path)
return None return None
@cached_function @cached_function
def package(filename): def package(filename):
dir = os.path.dirname(os.path.abspath(str(filename))) dir = os.path.dirname(os.path.abspath(str(filename)))
...@@ -390,6 +401,7 @@ def package(filename): ...@@ -390,6 +401,7 @@ def package(filename):
else: else:
return () return ()
@cached_function @cached_function
def fully_qualified_name(filename): def fully_qualified_name(filename):
module = os.path.splitext(os.path.basename(filename))[0] module = os.path.splitext(os.path.basename(filename))[0]
...@@ -600,7 +612,9 @@ class DependencyTree(object): ...@@ -600,7 +612,9 @@ class DependencyTree(object):
finally: finally:
del stack[node] del stack[node]
_dep_tree = None _dep_tree = None
def create_dependency_tree(ctx=None, quiet=False): def create_dependency_tree(ctx=None, quiet=False):
global _dep_tree global _dep_tree
if _dep_tree is None: if _dep_tree is None:
...@@ -937,7 +951,9 @@ if os.environ.get('XML_RESULTS'): ...@@ -937,7 +951,9 @@ if os.environ.get('XML_RESULTS'):
output.close() output.close()
return with_record return with_record
else: else:
record_results = lambda x: x def record_results(func):
return func
# TODO: Share context? Issue: pyx processing leaks into pxd module # TODO: Share context? Issue: pyx processing leaks into pxd module
@record_results @record_results
......
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