Make utils.debug.format_args public.

This commit is contained in:
Florian Bruhin 2015-08-11 17:08:49 +02:00
parent caedb57e56
commit 0ca96740c9

View File

@ -180,7 +180,7 @@ def signal_name(sig):
return m.group(1) return m.group(1)
def _format_args(args=None, kwargs=None): def format_args(args=None, kwargs=None):
"""Format a list of arguments/kwargs to a function-call like string.""" """Format a list of arguments/kwargs to a function-call like string."""
if args is not None: if args is not None:
arglist = [utils.compact_text(repr(arg), 200) for arg in args] arglist = [utils.compact_text(repr(arg), 200) for arg in args]
@ -202,7 +202,7 @@ def dbg_signal(sig, args):
Return: Return:
A human-readable string representation of signal/args. A human-readable string representation of signal/args.
""" """
return '{}({})'.format(signal_name(sig), _format_args(args)) return '{}({})'.format(signal_name(sig), format_args(args))
def format_call(func, args=None, kwargs=None, full=True): def format_call(func, args=None, kwargs=None, full=True):
@ -221,7 +221,7 @@ def format_call(func, args=None, kwargs=None, full=True):
name = utils.qualname(func) name = utils.qualname(func)
else: else:
name = func.__name__ name = func.__name__
return '{}({})'.format(name, _format_args(args, kwargs)) return '{}({})'.format(name, format_args(args, kwargs))
@contextlib.contextmanager @contextlib.contextmanager