simple debugging improvement - make it more readable by giving it an indent

This commit is contained in:
Dave Halter
2014-01-11 01:58:31 +01:00
parent 19fa320c88
commit e7c7bbca79
2 changed files with 21 additions and 4 deletions

View File

@@ -27,8 +27,20 @@ ignored_modules = ['jedi.evaluate.builtin', 'jedi.parser']
def reset_time():
global start_time
global start_time, debug_indent
start_time = time.time()
debug_indent = -1
def increase_indent(func):
"""Decorator for makin """
def wrapper(*args, **kwargs):
global debug_indent
debug_indent += 1
result = func(*args, **kwargs)
debug_indent -= 1
return result
return wrapper
def dbg(*args):
@@ -37,18 +49,21 @@ def dbg(*args):
frm = inspect.stack()[1]
mod = inspect.getmodule(frm[0])
if not (mod.__name__ in ignored_modules):
debug_function(NOTICE, 'dbg: ' + ', '.join(u(a) for a in args))
i = ' ' * debug_indent
debug_function(NOTICE, i + 'dbg: ' + ', '.join(u(a) for a in args))
def warning(*args):
if debug_function and enable_warning:
debug_function(WARNING, 'warning: ' + ', '.join(u(a) for a in args))
i = ' ' * debug_indent
debug_function(WARNING, i + 'warning: ' + ', '.join(u(a) for a in args))
def speed(name):
if debug_function and enable_speed:
now = time.time()
debug_function(SPEED, 'speed: ' + '%s %s' % (name, now - start_time))
i = ' ' * debug_indent
debug_function(SPEED, i + 'speed: ' + '%s %s' % (name, now - start_time))
def print_to_stdout(level, str_out):

View File

@@ -193,6 +193,7 @@ class Evaluator(object):
@memoize_default(default=(), evaluator_is_first_arg=True)
@recursion.recursion_decorator
@debug.increase_indent
def eval_statement(self, stmt, seek_name=None):
"""
The starting point of the completion. A statement always owns a call
@@ -377,6 +378,7 @@ class Evaluator(object):
result = imports.strip_imports(self, types)
return self.follow_path(path, set(result), scope, position=position)
@debug.increase_indent
def execute(self, obj, params=(), evaluate_generator=False):
if obj.isinstance(er.Function):
obj = obj.get_decorated_func()