Retrieve a function's information.

def get_func_info(func):
    """Retrieve a function's information."""
    name = func.__name__
    doc = func.__doc__ or ""
    try:
        nicename = func.description
    except AttributeError:
        if doc:
            nicename = doc.split('\n')[0]
            if len(nicename) > 80:
                nicename = name
        else:
            nicename = name
    parameters = []
    try:
        closure = func.func_closure
    except AttributeError:
        closure = func.__closure__
    try:
        varnames = func.func_code.co_freevars
    except AttributeError:
        varnames = func.__code__.co_freevars

    if closure:
        for index, arg in enumerate(closure):
            if not callable(arg.cell_contents):
                parameters.append((varnames[index],
                                   text_type(arg.cell_contents)))
    return ({
        "nicename": nicename,
        "doc": doc,
        "parameters": parameters,
        "name": name,
        "time": str(datetime.datetime.now()),
        "hostname": socket.gethostname(),
    })