<s> from jedi . _compatibility import encoding , is_py3 , u <EOL> import inspect <EOL> import os <EOL> import time <EOL> try : <EOL> if os . name == '<STR_LIT>' : <EOL> raise ImportError <EOL> else : <EOL> from colorama import Fore , init <EOL> from colorama import initialise <EOL> initialise . atexit_done = True <EOL> init ( ) <EOL> except ImportError : <EOL> class Fore ( object ) : <EOL> RED = '<STR_LIT>' <EOL> GREEN = '<STR_LIT>' <EOL> YELLOW = '<STR_LIT>' <EOL> RESET = '<STR_LIT>' <EOL> NOTICE = object ( ) <EOL> WARNING = object ( ) <EOL> SPEED = object ( ) <EOL> enable_speed = False <EOL> enable_warning = False <EOL> enable_notice = False <EOL> debug_function = None <EOL> ignored_modules = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> _debug_indent = - <NUM_LIT:1> <EOL> _start_time = time . time ( ) <EOL> def reset_time ( ) : <EOL> global _start_time , _debug_indent <EOL> _start_time = time . time ( ) <EOL> _debug_indent = - <NUM_LIT:1> <EOL> def increase_indent ( func ) : <EOL> """<STR_LIT>""" <EOL> def wrapper ( * args , ** kwargs ) : <EOL> global _debug_indent <EOL> _debug_indent += <NUM_LIT:1> <EOL> try : <EOL> result = func ( * args , ** kwargs ) <EOL> finally : <EOL> _debug_indent -= <NUM_LIT:1> <EOL> return result <EOL> return wrapper <EOL> def dbg ( message , * args ) : <EOL> """<STR_LIT>""" <EOL> if debug_function and enable_notice : <EOL> frm = inspect . stack ( ) [ <NUM_LIT:1> ] <EOL> mod = inspect . getmodule ( frm [ <NUM_LIT:0> ] ) <EOL> if not ( mod . __name__ in ignored_modules ) : <EOL> i = '<STR_LIT:U+0020>' * _debug_indent <EOL> debug_function ( NOTICE , i + '<STR_LIT>' + message % tuple ( u ( repr ( a ) ) for a in args ) ) <EOL> def warning ( message , * args ) : <EOL> if debug_function and enable_warning : <EOL> i = '<STR_LIT:U+0020>' * _debug_indent <EOL> debug_function ( WARNING , i + '<STR_LIT>' + message % tuple ( u ( repr ( a ) ) for a in args ) ) <EOL> def speed ( name ) : <EOL> if debug_function and enable_speed : <EOL> now = time . time ( ) <EOL> i = '<STR_LIT:U+0020>' * _debug_indent <EOL> debug_function ( SPEED , i + '<STR_LIT>' + '<STR_LIT>' % ( name , now - _start_time ) ) <EOL> def print_to_stdout ( level , str_out ) : <EOL> """<STR_LIT>""" <EOL> if level == NOTICE : <EOL> col = Fore . GREEN <EOL> elif level == WARNING : <EOL> col = Fore . RED <EOL> else : <EOL> col = Fore . YELLOW <EOL> if not is_py3 : <EOL> str_out = str_out . encode ( encoding , '<STR_LIT:replace>' ) <EOL> print ( col + str_out + Fore . RESET ) </s>
