import pkg_resources


def get_renderer_name(name: str) -> str:
    """ Return the name of the renderer used for a certain file extension.

    :param str name: The name of the extension to get the renderer name for. (.jpg, .docx, etc)

    :rtype : `str`
    """

    # `ep_iterator` is an iterable object. Must convert it to a `list` for access.
    # `list()` can only be called once because the iterator moves to the end after conversion.
    ep_iterator = pkg_resources.iter_entry_points(group='mfr.renderers', name=name.lower())
    ep_list = list(ep_iterator)

    # Empty list indicates unsupported file type.  Return '' and let `make_renderer()` handle it.
    if len(ep_list) == 0:
        return ''

    # If the file type is supported, there must be only one element in the list.
    assert len(ep_list) == 1
    return ep_list[0].attrs[0]