import inspect


def __get_caller_name(caller_frame):
    """Gets the name of the caller (fully qualified, if possible).

    :param caller_frame: A caller's frame.
    :type caller_frame: :class:`frame`

    :returns: The name of the caller (:class:`str`).
    """

    caller_name = caller_frame.f_code.co_name
    if 'self' in caller_frame.f_locals:
        caller_name = "%s.%s" % (
            caller_frame.f_locals['self'].__class__.__name__, caller_name
        )
    module = inspect.getmodule(caller_frame)
    if module:
        caller_name = "%s.%s" % (module.__name__, caller_name)
    return caller_name