Пример #1
0
 def _f(*args, **kwargs):
     if not __enabled:
         return f(*args, **kwargs)
     if ignore_first:
         a = [render_value(v) for v in args[1:]]
     else:
         a = [render_value(v) for v in args]
     a += ["%s=%s" % (k, render_value(v)) for k, v in kwargs.items()]
     res = f(*args, **kwargs)
     print "%s(%s) => %s" % (colorize(f.__name__, "green"), ", ".join(a), render_value(res))
     return res
Пример #2
0
 def render_value(value):
     value_type = type(value)
     if value_type in __registered_renderers:
         return colorize(__registered_renderers[value_type](value), "yellow")
     return colorize(repr(value), "yellow")