def pprint_task(task, keys, label_size=60):
    if istask(task):
        func = task[0]
        if func is apply:
            head = funcname(task[1])
            tail = ')'
            args = unquote(task[2]) if len(task) > 2 else ()
            kwargs = unquote(task[3]) if len(task) > 3 else {}
        else:
            if hasattr(func, 'funcs'):
                head = '('.join(funcname(f) for f in func.funcs)
                tail = ')'*len(func.funcs)
            else:
                head = funcname(task[0])
                tail = ')'
            args = task[1:]
            kwargs = {}
        if args or kwargs:
            label_size2 = int((label_size - len(head) - len(tail)) //
                              (len(args) + len(kwargs)))
            pprint = lambda t: pprint_task(t, keys, label_size2)
        if args:
            if label_size2 > 5:
                args = ', '.join(pprint(t) for t in args)
            else:
                args = '...'
        else:
            args = ''
        if kwargs:
            if label_size2 > 5:
                kwargs = ', ' + ', '.join('{0}={1}'.format(k, pprint(v))
                                          for k, v in sorted(kwargs.items()))
            else:
                kwargs = ', ...'
        else:
            kwargs = ''
        return '{0}({1}{2}{3}'.format(head, args, kwargs, tail)
    elif isinstance(task, list):
        if not task:
            return '[]'
        elif len(task) > 3:
            result = pprint_task(task[:3], keys, label_size)
            return result[:-1] + ', ...]'
        else:
            label_size2 = int((label_size - 2 - 2*len(task)) // len(task))
            args = ', '.join(pprint_task(t, keys, label_size2) for t in task)
            return '[{0}]'.format(args)
    else:
        try:
            if task in keys:
                return '_'
            else:
                return '*'
        except TypeError:
            return '*'
Return a nicely formatted string for a task.
dataset/ETHPy150Open dask/dask/dask/diagnostics/profile_visualize.py/pprint_task