forked from VimPlug/jedi
debug.dbg and debug.warning now take a string and format args parameters to make debugging a little bit cleaner
This commit is contained in:
@@ -189,7 +189,7 @@ class Script(object):
|
|||||||
completions.append((c, scope))
|
completions.append((c, scope))
|
||||||
else:
|
else:
|
||||||
completions = []
|
completions = []
|
||||||
debug.dbg('possible scopes', scopes)
|
debug.dbg('possible completion scopes: %s', scopes)
|
||||||
for s in scopes:
|
for s in scopes:
|
||||||
if s.isinstance(er.Function):
|
if s.isinstance(er.Function):
|
||||||
names = s.get_magic_function_names()
|
names = s.get_magic_function_names()
|
||||||
@@ -229,7 +229,7 @@ class Script(object):
|
|||||||
Base for completions/goto. Basically it returns the resolved scopes
|
Base for completions/goto. Basically it returns the resolved scopes
|
||||||
under cursor.
|
under cursor.
|
||||||
"""
|
"""
|
||||||
debug.dbg('start: %s in %s' % (goto_path, self._parser.user_scope))
|
debug.dbg('start: %s in %s', goto_path, self._parser.user_scope)
|
||||||
|
|
||||||
user_stmt = self._user_stmt(is_completion)
|
user_stmt = self._user_stmt(is_completion)
|
||||||
if not user_stmt and len(goto_path.split('\n')) > 1:
|
if not user_stmt and len(goto_path.split('\n')) > 1:
|
||||||
|
|||||||
+1
-1
@@ -257,7 +257,7 @@ class ParserPickling(object):
|
|||||||
finally:
|
finally:
|
||||||
gc.enable()
|
gc.enable()
|
||||||
|
|
||||||
debug.dbg('pickle loaded', path)
|
debug.dbg('pickle loaded: %s', path)
|
||||||
parser_cache[path] = parser_cache_item
|
parser_cache[path] = parser_cache_item
|
||||||
return parser_cache_item.parser
|
return parser_cache_item.parser
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -49,20 +49,20 @@ def increase_indent(func):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def dbg(*args):
|
def dbg(message, *args):
|
||||||
""" Looks at the stack, to see if a debug message should be printed. """
|
""" Looks at the stack, to see if a debug message should be printed. """
|
||||||
if debug_function and enable_notice:
|
if debug_function and enable_notice:
|
||||||
frm = inspect.stack()[1]
|
frm = inspect.stack()[1]
|
||||||
mod = inspect.getmodule(frm[0])
|
mod = inspect.getmodule(frm[0])
|
||||||
if not (mod.__name__ in ignored_modules):
|
if not (mod.__name__ in ignored_modules):
|
||||||
i = ' ' * debug_indent
|
i = ' ' * debug_indent
|
||||||
debug_function(NOTICE, i + 'dbg: ' + ', '.join(u(a) for a in args))
|
debug_function(NOTICE, i + 'dbg: ' + message % args)
|
||||||
|
|
||||||
|
|
||||||
def warning(*args):
|
def warning(message, *args):
|
||||||
if debug_function and enable_warning:
|
if debug_function and enable_warning:
|
||||||
i = ' ' * debug_indent
|
i = ' ' * debug_indent
|
||||||
debug_function(WARNING, i + 'warning: ' + ', '.join(u(a) for a in args))
|
debug_function(WARNING, i + 'warning: ' + message % args)
|
||||||
|
|
||||||
|
|
||||||
def speed(name):
|
def speed(name):
|
||||||
|
|||||||
+10
-10
@@ -205,7 +205,7 @@ class Evaluator(object):
|
|||||||
|
|
||||||
:param stmt: A `pr.Statement`.
|
:param stmt: A `pr.Statement`.
|
||||||
"""
|
"""
|
||||||
debug.dbg('eval_statement %s (%s)' % (stmt, seek_name))
|
debug.dbg('eval_statement %s (%s)', stmt, seek_name)
|
||||||
expression_list = stmt.expression_list()
|
expression_list = stmt.expression_list()
|
||||||
|
|
||||||
result = self.eval_expression_list(expression_list)
|
result = self.eval_expression_list(expression_list)
|
||||||
@@ -242,7 +242,7 @@ class Evaluator(object):
|
|||||||
loop = evaluate_list_comprehension(nested_lc, loop)
|
loop = evaluate_list_comprehension(nested_lc, loop)
|
||||||
return loop
|
return loop
|
||||||
|
|
||||||
debug.dbg('eval_expression_list: %s' % expression_list)
|
debug.dbg('eval_expression_list: %s', expression_list)
|
||||||
result = []
|
result = []
|
||||||
calls_iterator = iter(expression_list)
|
calls_iterator = iter(expression_list)
|
||||||
for call in calls_iterator:
|
for call in calls_iterator:
|
||||||
@@ -354,7 +354,7 @@ class Evaluator(object):
|
|||||||
current = next(path)
|
current = next(path)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return None
|
return None
|
||||||
debug.dbg('_follow_path: %s in scope %s' % (current, typ))
|
debug.dbg('_follow_path: %s in scope %s', current, typ)
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
if isinstance(current, pr.Array):
|
if isinstance(current, pr.Array):
|
||||||
@@ -367,7 +367,7 @@ class Evaluator(object):
|
|||||||
result = self.execute(typ, current)
|
result = self.execute(typ, current)
|
||||||
else:
|
else:
|
||||||
# Curly braces are not allowed, because they make no sense.
|
# Curly braces are not allowed, because they make no sense.
|
||||||
debug.warning('strange function call with {}', current, typ)
|
debug.warning('strange function call with {} %s %s', current, typ)
|
||||||
else:
|
else:
|
||||||
# The function must not be decorated with something else.
|
# The function must not be decorated with something else.
|
||||||
if typ.isinstance(er.Function):
|
if typ.isinstance(er.Function):
|
||||||
@@ -385,7 +385,7 @@ class Evaluator(object):
|
|||||||
if obj.isinstance(er.Function):
|
if obj.isinstance(er.Function):
|
||||||
obj = obj.get_decorated_func()
|
obj = obj.get_decorated_func()
|
||||||
|
|
||||||
debug.dbg('execute:', obj, params)
|
debug.dbg('execute: %s %s', obj, params)
|
||||||
try:
|
try:
|
||||||
return stdlib.execute(self, obj, params)
|
return stdlib.execute(self, obj, params)
|
||||||
except stdlib.NotInStdLib:
|
except stdlib.NotInStdLib:
|
||||||
@@ -410,11 +410,11 @@ class Evaluator(object):
|
|||||||
try:
|
try:
|
||||||
stmts = obj.execute_subscope_by_name('__call__', params)
|
stmts = obj.execute_subscope_by_name('__call__', params)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
debug.warning("no __call__ func available", obj)
|
debug.warning("no __call__ func available %s", obj)
|
||||||
else:
|
else:
|
||||||
debug.warning("no execution possible", obj)
|
debug.warning("no execution possible %s", obj)
|
||||||
|
|
||||||
debug.dbg('execute result: %s in %s' % (stmts, obj))
|
debug.dbg('execute result: %s in %s', stmts, obj)
|
||||||
return imports.strip_imports(self, stmts)
|
return imports.strip_imports(self, stmts)
|
||||||
|
|
||||||
def goto(self, stmt, call_path=None):
|
def goto(self, stmt, call_path=None):
|
||||||
@@ -482,8 +482,8 @@ def _assign_tuples(tup, results, seek_name):
|
|||||||
try:
|
try:
|
||||||
func = r.get_exact_index_types
|
func = r.get_exact_index_types
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
debug.warning("invalid tuple lookup %s of result %s in %s"
|
debug.warning("invalid tuple lookup %s of result %s in %s",
|
||||||
% (tup, results, seek_name))
|
tup, results, seek_name)
|
||||||
else:
|
else:
|
||||||
with common.ignored(IndexError):
|
with common.ignored(IndexError):
|
||||||
types += func(index)
|
types += func(index)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class NameFinder(object):
|
|||||||
def find(self, scopes, resolve_decorator=True):
|
def find(self, scopes, resolve_decorator=True):
|
||||||
names = self.filter_name(scopes)
|
names = self.filter_name(scopes)
|
||||||
types = self._names_to_types(names, resolve_decorator)
|
types = self._names_to_types(names, resolve_decorator)
|
||||||
debug.dbg('_names_to_types: %s, old: %s' % (names, types))
|
debug.dbg('_names_to_types: %s, old: %s', names, types)
|
||||||
return self._resolve_descriptors(types)
|
return self._resolve_descriptors(types)
|
||||||
|
|
||||||
def scopes(self, search_global=False):
|
def scopes(self, search_global=False):
|
||||||
@@ -76,8 +76,8 @@ class NameFinder(object):
|
|||||||
new_name.parent = r
|
new_name.parent = r
|
||||||
result.append(new_name)
|
result.append(new_name)
|
||||||
|
|
||||||
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s'
|
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s', self.name_str,
|
||||||
% (self.name_str, self.scope, nscope, u(result), self.position))
|
self.scope, nscope, u(result), self.position)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _check_getattr(self, inst):
|
def _check_getattr(self, inst):
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class ImportPath(pr.Base):
|
|||||||
n = pr.Name(i._sub_module, names, zero, zero, self.import_stmt)
|
n = pr.Name(i._sub_module, names, zero, zero, self.import_stmt)
|
||||||
new = pr.Import(i._sub_module, zero, zero, n)
|
new = pr.Import(i._sub_module, zero, zero, n)
|
||||||
new.parent = parent
|
new.parent = parent
|
||||||
debug.dbg('Generated a nested import: %s' % new)
|
debug.dbg('Generated a nested import: %s', new)
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def get_defined_names(self, on_import_stmt=False):
|
def get_defined_names(self, on_import_stmt=False):
|
||||||
@@ -193,7 +193,7 @@ class ImportPath(pr.Base):
|
|||||||
try:
|
try:
|
||||||
scope, rest = self._follow_file_system()
|
scope, rest = self._follow_file_system()
|
||||||
except ModuleNotFound:
|
except ModuleNotFound:
|
||||||
debug.warning('Module not found: ' + str(self.import_stmt))
|
debug.warning('Module not found: %s', self.import_stmt)
|
||||||
self._evaluator.recursion_detector.pop_stmt()
|
self._evaluator.recursion_detector.pop_stmt()
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ class ImportPath(pr.Base):
|
|||||||
scopes.append(self._get_nested_import(scope))
|
scopes.append(self._get_nested_import(scope))
|
||||||
else:
|
else:
|
||||||
scopes = [ImportPath.GlobalNamespace]
|
scopes = [ImportPath.GlobalNamespace]
|
||||||
debug.dbg('after import', scopes)
|
debug.dbg('after import: %s', scopes)
|
||||||
|
|
||||||
self._evaluator.recursion_detector.pop_stmt()
|
self._evaluator.recursion_detector.pop_stmt()
|
||||||
return scopes
|
return scopes
|
||||||
@@ -295,7 +295,7 @@ class ImportPath(pr.Base):
|
|||||||
Find a module with a path (of the module, like usb.backend.libusb10).
|
Find a module with a path (of the module, like usb.backend.libusb10).
|
||||||
"""
|
"""
|
||||||
def follow_str(ns_path, string):
|
def follow_str(ns_path, string):
|
||||||
debug.dbg('follow_module', ns_path, string)
|
debug.dbg('follow_module %s %s', ns_path, string)
|
||||||
path = None
|
path = None
|
||||||
if ns_path:
|
if ns_path:
|
||||||
path = ns_path
|
path = ns_path
|
||||||
@@ -305,7 +305,7 @@ class ImportPath(pr.Base):
|
|||||||
if path is not None:
|
if path is not None:
|
||||||
importing = find_module(string, [path])
|
importing = find_module(string, [path])
|
||||||
else:
|
else:
|
||||||
debug.dbg('search_module', string, self.file_path)
|
debug.dbg('search_module %s %s', string, self.file_path)
|
||||||
# Override the sys.path. It works only good that way.
|
# Override the sys.path. It works only good that way.
|
||||||
# Injecting the path directly into `find_module` did not work.
|
# Injecting the path directly into `find_module` did not work.
|
||||||
sys.path, temp = sys_path, sys.path
|
sys.path, temp = sys_path, sys.path
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Generator(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
for n in ('close', 'throw') + executes_generator:
|
for n in ('close', 'throw') + executes_generator:
|
||||||
parent = self if n in executes_generator else compiled.builtin
|
parent = self if n in executes_generator else compiled.builtin
|
||||||
names.append(helpers.FakeName(n, parent))
|
names.append(helpers.FakeName(n, parent))
|
||||||
debug.dbg('generator names', names)
|
debug.dbg('generator names: %s', names)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def iter_content(self):
|
def iter_content(self):
|
||||||
@@ -36,7 +36,7 @@ class Generator(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
return self._evaluator.execute(self.func, self.var_args, True)
|
return self._evaluator.execute(self.func, self.var_args, True)
|
||||||
|
|
||||||
def get_index_types(self, index=None):
|
def get_index_types(self, index=None):
|
||||||
debug.warning('Tried to get array access on a generator', self)
|
debug.warning('Tried to get array access on a generator: %s', self)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
@@ -183,7 +183,7 @@ def get_iterator_types(inputs):
|
|||||||
iterators.append(it)
|
iterators.append(it)
|
||||||
else:
|
else:
|
||||||
if not hasattr(it, 'execute_subscope_by_name'):
|
if not hasattr(it, 'execute_subscope_by_name'):
|
||||||
debug.warning('iterator/for loop input wrong', it)
|
debug.warning('iterator/for loop input wrong: %s', it)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
iterators += it.execute_subscope_by_name('__iter__')
|
iterators += it.execute_subscope_by_name('__iter__')
|
||||||
@@ -204,7 +204,7 @@ def get_iterator_types(inputs):
|
|||||||
try:
|
try:
|
||||||
result += gen.execute_subscope_by_name(name)
|
result += gen.execute_subscope_by_name(name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
debug.warning('Instance has no __next__ function', gen)
|
debug.warning('Instance has no __next__ function in %s.', gen)
|
||||||
else:
|
else:
|
||||||
# is a generator
|
# is a generator
|
||||||
result += gen.iter_content()
|
result += gen.iter_content()
|
||||||
@@ -363,9 +363,7 @@ class ArrayInstance(pr.Base):
|
|||||||
if self.var_args.start_pos != array.var_args.start_pos:
|
if self.var_args.start_pos != array.var_args.start_pos:
|
||||||
items += array.iter_content()
|
items += array.iter_content()
|
||||||
else:
|
else:
|
||||||
debug.warning(
|
debug.warning('ArrayInstance recursion %s', self.var_args)
|
||||||
'ArrayInstance recursion',
|
|
||||||
self.var_args)
|
|
||||||
continue
|
continue
|
||||||
items += get_iterator_types([typ])
|
items += get_iterator_types([typ])
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class RecursionDetector(object):
|
|||||||
self.current = _RecursionNode(stmt, self.current)
|
self.current = _RecursionNode(stmt, self.current)
|
||||||
check = self._check_recursion()
|
check = self._check_recursion()
|
||||||
if check: # TODO remove False!!!!
|
if check: # TODO remove False!!!!
|
||||||
debug.warning('catched stmt recursion: %s against %s @%s'
|
debug.warning('catched stmt recursion: %s against %s @%s', stmt,
|
||||||
% (stmt, check.stmt, stmt.start_pos))
|
check.stmt, stmt.start_pos)
|
||||||
self.pop_stmt()
|
self.pop_stmt()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -121,7 +121,7 @@ class ExecutionRecursionDetector(object):
|
|||||||
self.execution_count = 0
|
self.execution_count = 0
|
||||||
|
|
||||||
def __call__(self, execution, evaluate_generator=False):
|
def __call__(self, execution, evaluate_generator=False):
|
||||||
debug.dbg('Execution recursions: %s' % execution, self.recursion_level,
|
debug.dbg('Execution recursions: %s', execution, self.recursion_level,
|
||||||
self.execution_count, len(self.execution_funcs))
|
self.execution_count, len(self.execution_funcs))
|
||||||
if self.check_recursion(execution, evaluate_generator):
|
if self.check_recursion(execution, evaluate_generator):
|
||||||
result = []
|
result = []
|
||||||
|
|||||||
@@ -334,16 +334,15 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
# Only enter it, if has not already been processed.
|
# Only enter it, if has not already been processed.
|
||||||
if not self.is_decorated:
|
if not self.is_decorated:
|
||||||
for dec in reversed(self.base_func.decorators):
|
for dec in reversed(self.base_func.decorators):
|
||||||
debug.dbg('decorator:', dec, f)
|
debug.dbg('decorator: %s %s', dec, f)
|
||||||
dec_results = set(self._evaluator.eval_statement(dec))
|
dec_results = set(self._evaluator.eval_statement(dec))
|
||||||
if not len(dec_results):
|
if not len(dec_results):
|
||||||
debug.warning('decorator not found: %s on %s' %
|
debug.warning('decorator not found: %s on %s', dec, self.base_func)
|
||||||
(dec, self.base_func))
|
|
||||||
return None
|
return None
|
||||||
decorator = dec_results.pop()
|
decorator = dec_results.pop()
|
||||||
if dec_results:
|
if dec_results:
|
||||||
debug.warning('multiple decorators found', self.base_func,
|
debug.warning('multiple decorators found %s %s',
|
||||||
dec_results)
|
self.base_func, dec_results)
|
||||||
# Create param array.
|
# Create param array.
|
||||||
old_func = Function(self._evaluator, f, is_decorated=True)
|
old_func = Function(self._evaluator, f, is_decorated=True)
|
||||||
if instance is not None and decorator.isinstance(Function):
|
if instance is not None and decorator.isinstance(Function):
|
||||||
@@ -352,15 +351,15 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
|
|
||||||
wrappers = self._evaluator.execute(decorator, (old_func,))
|
wrappers = self._evaluator.execute(decorator, (old_func,))
|
||||||
if not len(wrappers):
|
if not len(wrappers):
|
||||||
debug.warning('no wrappers found', self.base_func)
|
debug.warning('no wrappers found %s', self.base_func)
|
||||||
return None
|
return None
|
||||||
if len(wrappers) > 1:
|
if len(wrappers) > 1:
|
||||||
# TODO resolve issue with multiple wrappers -> multiple types
|
# TODO resolve issue with multiple wrappers -> multiple types
|
||||||
debug.warning('multiple wrappers found', self.base_func,
|
debug.warning('multiple wrappers found %s %s',
|
||||||
wrappers)
|
self.base_func, wrappers)
|
||||||
f = wrappers[0]
|
f = wrappers[0]
|
||||||
|
|
||||||
debug.dbg('decorator end', f)
|
debug.dbg('decorator end %s', f)
|
||||||
if f != self.base_func and isinstance(f, pr.Function):
|
if f != self.base_func and isinstance(f, pr.Function):
|
||||||
f = Function(self._evaluator, f)
|
f = Function(self._evaluator, f)
|
||||||
return f
|
return f
|
||||||
|
|||||||
@@ -75,14 +75,14 @@ def sys_path_with_modifications(module):
|
|||||||
res = execute_code(exe.get_code())
|
res = execute_code(exe.get_code())
|
||||||
if res is not None:
|
if res is not None:
|
||||||
sys_path.insert(0, res)
|
sys_path.insert(0, res)
|
||||||
debug.dbg('sys path inserted: %s' % res)
|
debug.dbg('sys path inserted: %s', res)
|
||||||
exe.type = exe_type
|
exe.type = exe_type
|
||||||
exe.values.insert(0, exe_pop)
|
exe.values.insert(0, exe_pop)
|
||||||
elif array_cmd == 'append':
|
elif array_cmd == 'append':
|
||||||
res = execute_code(exe.get_code())
|
res = execute_code(exe.get_code())
|
||||||
if res is not None:
|
if res is not None:
|
||||||
sys_path.append(res)
|
sys_path.append(res)
|
||||||
debug.dbg('sys path added: %s' % res)
|
debug.dbg('sys path added: %s', res)
|
||||||
return sys_path
|
return sys_path
|
||||||
|
|
||||||
if module.path is None:
|
if module.path is None:
|
||||||
@@ -115,6 +115,6 @@ def _detect_django_path(module_path):
|
|||||||
|
|
||||||
with common.ignored(IOError):
|
with common.ignored(IOError):
|
||||||
with open(module_path + os.path.sep + 'manage.py'):
|
with open(module_path + os.path.sep + 'manage.py'):
|
||||||
debug.dbg('Found django path: %s' % module_path)
|
debug.dbg('Found django path: %s', module_path)
|
||||||
result.append(module_path)
|
result.append(module_path)
|
||||||
return result
|
return result
|
||||||
|
|||||||
+9
-13
@@ -269,11 +269,8 @@ class Parser(object):
|
|||||||
first_pos = self.start_pos
|
first_pos = self.start_pos
|
||||||
token_type, cname = self.next()
|
token_type, cname = self.next()
|
||||||
if token_type != tokenize.NAME:
|
if token_type != tokenize.NAME:
|
||||||
debug.warning(
|
debug.warning("class: syntax err, token is not a name@%s (%s: %s)",
|
||||||
"class: syntax err, token is not a name@%s (%s: %s)" % (
|
self.start_pos[0], tokenize.tok_name[token_type], cname)
|
||||||
self.start_pos[0], tokenize.tok_name[token_type], cname
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
cname = pr.Name(self.module, [(cname, self.start_pos)], self.start_pos,
|
cname = pr.Name(self.module, [(cname, self.start_pos)], self.start_pos,
|
||||||
@@ -286,7 +283,7 @@ class Parser(object):
|
|||||||
token_type, _next = self.next()
|
token_type, _next = self.next()
|
||||||
|
|
||||||
if _next != ':':
|
if _next != ':':
|
||||||
debug.warning("class syntax: %s@%s" % (cname, self.start_pos[0]))
|
debug.warning("class syntax: %s@%s", cname, self.start_pos[0])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# because of 2 line class initializations
|
# because of 2 line class initializations
|
||||||
@@ -446,8 +443,8 @@ class Parser(object):
|
|||||||
or self.user_scope is None
|
or self.user_scope is None
|
||||||
and self.start_pos[0] >= self.user_position[0]
|
and self.start_pos[0] >= self.user_position[0]
|
||||||
):
|
):
|
||||||
debug.dbg('user scope found [%s] = %s' %
|
debug.dbg('user scope found [%s] = %s',
|
||||||
(self.parserline.replace('\n', ''), repr(self._scope)))
|
self.parserline.replace('\n', ''), self._scope)
|
||||||
self.user_scope = self._scope
|
self.user_scope = self._scope
|
||||||
|
|
||||||
self._current = typ, tok
|
self._current = typ, tok
|
||||||
@@ -473,8 +470,8 @@ class Parser(object):
|
|||||||
# This iterator stuff is not intentional. It grew historically.
|
# This iterator stuff is not intentional. It grew historically.
|
||||||
for token_type, tok in self.iterator:
|
for token_type, tok in self.iterator:
|
||||||
self.module.temp_used_names = []
|
self.module.temp_used_names = []
|
||||||
# debug.dbg('main: tok=[%s] type=[%s] indent=[%s]'\
|
# debug.dbg('main: tok=[%s] type=[%s] indent=[%s]', \
|
||||||
# % (tok, tokenize.tok_name[token_type], start_position[0]))
|
# tok, tokenize.tok_name[token_type], start_position[0])
|
||||||
|
|
||||||
while token_type == tokenize.DEDENT and self._scope != self.module:
|
while token_type == tokenize.DEDENT and self._scope != self.module:
|
||||||
token_type, tok = self.next()
|
token_type, tok = self.next()
|
||||||
@@ -504,8 +501,7 @@ class Parser(object):
|
|||||||
if tok == 'def':
|
if tok == 'def':
|
||||||
func = self._parse_function()
|
func = self._parse_function()
|
||||||
if func is None:
|
if func is None:
|
||||||
debug.warning("function: syntax error@%s" %
|
debug.warning("function: syntax error@%s", self.start_pos[0])
|
||||||
self.start_pos[0])
|
|
||||||
continue
|
continue
|
||||||
self.freshscope = True
|
self.freshscope = True
|
||||||
self._scope = self._scope.add_scope(func, self._decorators)
|
self._scope = self._scope.add_scope(func, self._decorators)
|
||||||
@@ -549,7 +545,7 @@ class Parser(object):
|
|||||||
tok = 'import'
|
tok = 'import'
|
||||||
mod = None
|
mod = None
|
||||||
if not mod and not relative_count or tok != "import":
|
if not mod and not relative_count or tok != "import":
|
||||||
debug.warning("from: syntax error@%s" % self.start_pos[0])
|
debug.warning("from: syntax error@%s", self.start_pos[0])
|
||||||
defunct = True
|
defunct = True
|
||||||
if tok != 'import':
|
if tok != 'import':
|
||||||
self._gen.push_last_back()
|
self._gen.push_last_back()
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ class Function(Scope):
|
|||||||
try:
|
try:
|
||||||
n.append(p.get_name())
|
n.append(p.get_name())
|
||||||
except IndexError:
|
except IndexError:
|
||||||
debug.warning("multiple names in param %s" % n)
|
debug.warning("multiple names in param %s", n)
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def get_call_signature(self, width=72, funcname=None):
|
def get_call_signature(self, width=72, funcname=None):
|
||||||
@@ -1018,12 +1018,12 @@ class Statement(Simple):
|
|||||||
|
|
||||||
middle, tok = parse_stmt_or_arr(token_iterator, ['in'], True)
|
middle, tok = parse_stmt_or_arr(token_iterator, ['in'], True)
|
||||||
if tok != 'in' or middle is None:
|
if tok != 'in' or middle is None:
|
||||||
debug.warning('list comprehension middle @%s' % str(start_pos))
|
debug.warning('list comprehension middle @%s', start_pos)
|
||||||
return None, tok
|
return None, tok
|
||||||
|
|
||||||
in_clause, tok = parse_stmt_or_arr(token_iterator)
|
in_clause, tok = parse_stmt_or_arr(token_iterator)
|
||||||
if in_clause is None:
|
if in_clause is None:
|
||||||
debug.warning('list comprehension in @%s' % str(start_pos))
|
debug.warning('list comprehension in @%s', start_pos)
|
||||||
return None, tok
|
return None, tok
|
||||||
|
|
||||||
return ListComprehension(st, middle, in_clause, self), tok
|
return ListComprehension(st, middle, in_clause, self), tok
|
||||||
@@ -1156,7 +1156,7 @@ class Param(Statement):
|
|||||||
""" get the name of the param """
|
""" get the name of the param """
|
||||||
n = self.get_set_vars()
|
n = self.get_set_vars()
|
||||||
if len(n) > 1:
|
if len(n) > 1:
|
||||||
debug.warning("Multiple param names (%s)." % n)
|
debug.warning("Multiple param names (%s).", n)
|
||||||
return n[0]
|
return n[0]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class UserContext(object):
|
|||||||
string += tok
|
string += tok
|
||||||
last_type = token_type
|
last_type = token_type
|
||||||
except tokenize.TokenError:
|
except tokenize.TokenError:
|
||||||
debug.warning("Tokenize couldn't finish", sys.exc_info)
|
debug.warning("Tokenize couldn't finish: %s", sys.exc_info)
|
||||||
|
|
||||||
# string can still contain spaces at the end
|
# string can still contain spaces at the end
|
||||||
return string[::-1].strip(), start_cursor
|
return string[::-1].strip(), start_cursor
|
||||||
|
|||||||
Reference in New Issue
Block a user