cleaning / pep8

This commit is contained in:
David Halter
2012-05-19 12:14:32 +02:00
parent 21a5825e6e
commit 7ac17aa036
4 changed files with 17 additions and 16 deletions

View File

@@ -8,6 +8,7 @@ try:
next = next
except NameError:
_raiseStopIteration = object()
def next(iterator, default=_raiseStopIteration):
if not hasattr(iterator, 'next'):
raise TypeError("not an iterator")

View File

@@ -36,10 +36,6 @@ class CachedModule(object):
def _load_module(self):
source = self._get_source()
self._parser = parsing.PyFuzzyParser(source, self.path or self.name)
#except:
# debug.warning('not possible to resolve', self.name, source)
#open('builtin_fail', 'w').write(code)
# raise
p_time = None if not self.path else os.path.getmtime(self.path)
self.cache[self.path or self.name] = p_time, self._parser
@@ -163,10 +159,10 @@ class Parser(CachedModule):
try:
try:
path = scope.__file__
except:
except AttributeError:
path = '?'
code += '# Generated module %s from %s\n' % (scope.__name__, path)
except:
except AttributeError:
pass
code += '"""\n%s\n"""\n' % scope.__doc__
@@ -189,7 +185,7 @@ class Parser(CachedModule):
doc_str = parsing.indent_block('"""\n%s\n"""\n' % func.__doc__)
try:
mixin = self.mixin_funcs[name]
except:
except KeyError:
# normal code generation
code += 'def %s(%s):\n' % (name, params)
code += doc_str

View File

@@ -251,7 +251,7 @@ class Instance(Executable):
"""
try:
return func.params[0].used_vars[0].names[0]
except:
except IndexError:
return None
def get_defined_names(self):
@@ -414,7 +414,7 @@ class Execution(Executable):
Get the return vars of a function.
"""
stmts = []
#print '\n\n', self.var_args, self.var_args.values, self.var_args.parent_stmt
#a = self.var_args; print '\n\n', a, a.values, a.parent_stmt
if isinstance(self.base, Class):
# there maybe executions of executions
stmts = [Instance(self.base, self.var_args)]
@@ -442,8 +442,8 @@ class Execution(Executable):
# TODO how can we deactivate this again?
#self.base.param_cb = None
# func could have changed because of decorators, so clear them
# again
# func could have changed because of decorators, so clear
# them again
self.base.is_decorated = False
else:
debug.warning("no execution possible", func)
@@ -488,6 +488,7 @@ class Generator(object):
def __repr__(self):
return "<%s of %s>" % (self.__class__.__name__, self.func)
class Array(object):
"""
Used as a mirror to parsing.Array, if needed. It defines some getter

View File

@@ -107,6 +107,7 @@ class Definition(object):
def __repr__(self):
return "<%s %s>" % (self.__class__.__name__, self)
def get_completion_parts(path):
"""
Returns the parts for the completion
@@ -133,7 +134,8 @@ def complete(source, row, column, source_path):
:rtype: list
"""
try:
scopes, path, dot, like = prepare_goto(source, row, column, source_path, True)
scopes, path, dot, like = prepare_goto(source, row, column,
source_path, True)
except NotFoundError:
# normally this would be used like this: `NotFoundError as exc`, but
# this guarantues backwards compatibility with Python2.5.
@@ -200,6 +202,7 @@ def prepare_goto(source, row, column, source_path, is_like_search):
else:
return scopes
def get_definitions(source, row, column, source_path):
"""
Returns the definitions of a the path under the cursor.