import pkg_resources


def parse_use(group, use, load_entry_point=pkg_resources.load_entry_point):
    """Parses and loads the entry point for a 'use' directive. The ``use``
    string is expected to look like ``dist#name`` and will be split on the
    first ``'#'`` into a ``dist, name`` pair. Then we pass the whole lot
    to the ``load_entry_point`` callback (using the same protocol as
    ``pkg_resources.load_entry_point``) and return whatever we get back.

    :param group: the entry point group to load from.
    :param use: the un-parsed ``use`` string.
    :param load_entry_point: the function that will actually load entry points.
    """
    dist, entry_point = use.split('#', 1)
    return load_entry_point(dist, group, entry_point)