<s> class Colors ( object ) : <EOL> RED = '<STR_LIT>' <EOL> GREEN = '<STR_LIT>' <EOL> YELLOW = '<STR_LIT>' <EOL> BLUE = '<STR_LIT>' <EOL> MAGENTA = '<STR_LIT>' <EOL> CYAN = '<STR_LIT>' <EOL> ENDC = '<STR_LIT>' <EOL> def timeit ( logger , fmt , threshold ) : <EOL> from json import dumps <EOL> import time <EOL> def is_json ( json_data ) : <EOL> try : <EOL> json_object = dumps ( json_data , indent = <NUM_LIT:4> ) <EOL> except ValueError : <EOL> return False <EOL> else : <EOL> return json_object <EOL> def timereald ( method ) : <EOL> def timed ( * args , ** kw ) : <EOL> start = time . clock ( ) <EOL> result = method ( * args , ** kw ) <EOL> end = time . clock ( ) <EOL> try : <EOL> obj , value = args <EOL> data = is_json ( value ) if False else value <EOL> except Exception : <EOL> data = is_json ( args ) if False else args <EOL> sec = ( end - start ) <EOL> sec_color = Colors . RED <EOL> if sec <= threshold [ <NUM_LIT:0> ] : <EOL> sec_color = Colors . BLUE <EOL> elif sec <= threshold [ <NUM_LIT:1> ] : <EOL> sec_color = Colors . GREEN <EOL> if fmt == '<STR_LIT>' : <EOL> logger . debug ( "<STR_LIT>" % <EOL> ( method . __name__ , <EOL> sec_color , <EOL> sec , <EOL> Colors . ENDC , <EOL> ) ) <EOL> elif fmt == '<STR_LIT>' : <EOL> logger . debug ( <EOL> "<STR_LIT>" % <EOL> ( method . __name__ , <EOL> sec_color , <EOL> sec , <EOL> Colors . ENDC , <EOL> obj , <EOL> kw , <EOL> data , <EOL> ) ) <EOL> return result <EOL> return timed <EOL> return timereald </s>
