Skip to content

Commit

Permalink
Remove trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb committed Dec 13, 2010
1 parent 671e6a5 commit f6762fa
Show file tree
Hide file tree
Showing 235 changed files with 2,969 additions and 2,969 deletions.
4 changes: 2 additions & 2 deletions COPYING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ redistribute, modify and distribute modified versions."
------------------

Cython, which derives from Pyrex, is licensed under the Python
Software Foundation License. More precisely, all modifications
Software Foundation License. More precisely, all modifications
made to go from Pyrex to Cython are so licensed.

See LICENSE.txt for more details.


50 changes: 25 additions & 25 deletions Cython/Build/Dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def unquote(literal):
return literals[literal[1:-1]]
else:
return literal

return [unquote(item) for item in s.split(delimiter)]

transitive_str = object()
Expand Down Expand Up @@ -70,7 +70,7 @@ def line_iter(source):
start = end+1

class DistutilsInfo(object):

def __init__(self, source=None, exn=None):
self.values = {}
if source is not None:
Expand All @@ -97,7 +97,7 @@ def __init__(self, source=None, exn=None):
value = getattr(exn, key, None)
if value:
self.values[key] = value

def merge(self, other):
if other is None:
return self
Expand All @@ -114,7 +114,7 @@ def merge(self, other):
else:
self.values[key] = value
return self

def subs(self, aliases):
if aliases is None:
return self
Expand All @@ -140,9 +140,9 @@ def subs(self, aliases):

def strip_string_literals(code, prefix='__Pyx_L'):
"""
Normalizes every string literal to be of the form '__Pyx_Lxxx',
Normalizes every string literal to be of the form '__Pyx_Lxxx',
returning the normalized code and a mapping of labels to
string literals.
string literals.
"""
new_code = []
literals = {}
Expand All @@ -156,7 +156,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
double_q = code.find('"', q)
q = min(single_q, double_q)
if q == -1: q = max(single_q, double_q)

# We're done.
if q == -1 and hash_mark == -1:
new_code.append(code[start:])
Expand All @@ -181,7 +181,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
start = q
else:
q += 1

# Process comment.
elif -1 != hash_mark and (hash_mark < q or q == -1):
end = code.find('\n', hash_mark)
Expand Down Expand Up @@ -212,7 +212,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
new_code.append(code[start:end])
start = q
q += len(in_quote)

return "".join(new_code), literals


Expand Down Expand Up @@ -245,16 +245,16 @@ def parse_dependencies(source_filename):


class DependencyTree(object):

def __init__(self, context):
self.context = context
self._transitive_cache = {}

#@cached_method
def parse_dependencies(self, source_filename):
return parse_dependencies(source_filename)
parse_dependencies = cached_method(parse_dependencies)

#@cached_method
def cimports_and_externs(self, filename):
cimports, includes, externs = self.parse_dependencies(filename)[:3]
Expand All @@ -272,10 +272,10 @@ def cimports_and_externs(self, filename):
print("Unable to locate '%s' referenced from '%s'" % (filename, include))
return tuple(cimports), tuple(externs)
cimports_and_externs = cached_method(cimports_and_externs)

def cimports(self, filename):
return self.cimports_and_externs(filename)[0]

#@cached_method
def package(self, filename):
dir = os.path.dirname(filename)
Expand All @@ -284,13 +284,13 @@ def package(self, filename):
else:
return ()
package = cached_method(package)

#@cached_method
def fully_qualifeid_name(self, filename):
module = os.path.splitext(os.path.basename(filename))[0]
return '.'.join(self.package(filename) + (module,))
fully_qualifeid_name = cached_method(fully_qualifeid_name)

def find_pxd(self, module, filename=None):
if module[0] == '.':
raise NotImplementedError("New relative imports.")
Expand All @@ -301,7 +301,7 @@ def find_pxd(self, module, filename=None):
return pxd
return self.context.find_pxd_file(module, None)
find_pxd = cached_method(find_pxd)

#@cached_method
def cimported_files(self, filename):
if filename[-4:] == '.pyx' and os.path.exists(filename[:-4] + '.pxd'):
Expand All @@ -316,41 +316,41 @@ def cimported_files(self, filename):
print("\n\t".join(b))
return tuple(self_pxd + filter(None, [self.find_pxd(m, filename) for m in self.cimports(filename)]))
cimported_files = cached_method(cimported_files)

def immediate_dependencies(self, filename):
all = list(self.cimported_files(filename))
for extern in sum(self.cimports_and_externs(filename), ()):
all.append(os.path.normpath(os.path.join(os.path.dirname(filename), extern)))
return tuple(all)

#@cached_method
def timestamp(self, filename):
return os.path.getmtime(filename)
timestamp = cached_method(timestamp)

def extract_timestamp(self, filename):
# TODO: .h files from extern blocks
return self.timestamp(filename), filename

def newest_dependency(self, filename):
return self.transitive_merge(filename, self.extract_timestamp, max)

def distutils_info0(self, filename):
return self.parse_dependencies(filename)[3]

def distutils_info(self, filename, aliases=None, base=None):
return (self.transitive_merge(filename, self.distutils_info0, DistutilsInfo.merge)
.subs(aliases)
.merge(base))

def transitive_merge(self, node, extract, merge):
try:
seen = self._transitive_cache[extract, merge]
except KeyError:
seen = self._transitive_cache[extract, merge] = {}
return self.transitive_merge_helper(
node, extract, merge, seen, {}, self.cimported_files)[0]

def transitive_merge_helper(self, node, extract, merge, seen, stack, outgoing):
if node in seen:
return seen[node], None
Expand Down
6 changes: 3 additions & 3 deletions Cython/Build/Inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def safe_type(arg, context=None):
return '%s.%s' % (base_type.__module__, base_type.__name__)
return 'object'

def cython_inline(code,
def cython_inline(code,
get_type=unsafe_type,
lib_dir=os.path.expanduser('~/.cython/inline'),
cython_include_dirs=['.'],
Expand Down Expand Up @@ -252,14 +252,14 @@ def get_body(source):
else:
return source[ix+1:]

# Lots to be done here... It would be especially cool if compiled functions
# Lots to be done here... It would be especially cool if compiled functions
# could invoke each other quickly.
class RuntimeCompiledFunction(object):

def __init__(self, f):
self._f = f
self._body = get_body(inspect.getsource(f))

def __call__(self, *args, **kwds):
all = getcallargs(self._f, *args, **kwds)
return cython_inline(self._body, locals=self._f.func_globals, globals=self._f.func_globals, **all)
2 changes: 1 addition & 1 deletion Cython/Build/Tests/TestInline.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_globals(self):
self.assertEquals(inline("return global_value + 1", **test_kwds), global_value + 1)

if has_numpy:

def test_numpy(self):
import numpy
a = numpy.ndarray((10, 20))
Expand Down
Loading

0 comments on commit f6762fa

Please sign in to comment.