forked from VimPlug/jedi
added speed function
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import inspect
|
import inspect
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Use colorama for nicer console output.
|
# Use colorama for nicer console output.
|
||||||
from colorama import Fore, init
|
from colorama import Fore, init
|
||||||
@@ -7,19 +9,26 @@ except ImportError:
|
|||||||
class Fore(object):
|
class Fore(object):
|
||||||
RED = ''
|
RED = ''
|
||||||
GREEN = ''
|
GREEN = ''
|
||||||
|
YELLOW = ''
|
||||||
RESET = ''
|
RESET = ''
|
||||||
|
|
||||||
NOTICE = object()
|
NOTICE = object()
|
||||||
WARNING = object()
|
WARNING = object()
|
||||||
ERROR = object()
|
SPEED = object()
|
||||||
|
|
||||||
|
enable_speed = False
|
||||||
|
enable_warning = False
|
||||||
|
enable_notice = False
|
||||||
|
|
||||||
debug_function = None
|
debug_function = None
|
||||||
ignored_modules = ['parsing', 'builtin', 'jedi.builtin', 'jedi.parsing']
|
ignored_modules = ['parsing', 'builtin', 'jedi.builtin', 'jedi.parsing']
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
|
||||||
def dbg(*args):
|
def dbg(*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:
|
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):
|
||||||
@@ -27,18 +36,24 @@ def dbg(*args):
|
|||||||
|
|
||||||
|
|
||||||
def warning(*args):
|
def warning(*args):
|
||||||
if debug_function:
|
if debug_function and enable_warning:
|
||||||
debug_function(WARNING, *args)
|
debug_function(WARNING, *args)
|
||||||
|
|
||||||
|
|
||||||
def error(*args):
|
def speed(name):
|
||||||
if debug_function:
|
if debug_function:
|
||||||
debug_function(ERROR, *args)
|
args = ('%s\t\t' % name,)
|
||||||
|
debug_function(SPEED, *args)
|
||||||
|
|
||||||
|
|
||||||
def print_to_stdout(level, *args):
|
def print_to_stdout(level, *args):
|
||||||
""" The default debug function """
|
""" The default debug function """
|
||||||
msg = (Fore.GREEN + 'dbg: ' if level == NOTICE else Fore.RED + 'warning: ')
|
if level == NOTICE:
|
||||||
|
msg = Fore.GREEN + 'dbg: '
|
||||||
|
elif level == WARNING:
|
||||||
|
msg = Fore.RED + 'warning: '
|
||||||
|
else:
|
||||||
|
msg = Fore.YELLOW + 'speed: '
|
||||||
print(msg + ', '.join(str(a) for a in args) + Fore.RESET)
|
print(msg + ', '.join(str(a) for a in args) + Fore.RESET)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user