larigira/larigira/entrypoints_utils.py
2019-06-25 13:49:54 +02:00

18 lines
609 B
Python

from logging import getLogger
log = getLogger("entrypoints_utils")
from pkg_resources import iter_entry_points
def get_one_entrypoint(group, kind):
"""Messes with entrypoints to return an entrypoint of a given group/kind"""
points = tuple(iter_entry_points(group=group, name=kind))
if not points:
raise ValueError("cant find an entrypoint %s:%s" % (group, kind))
if len(points) > 1:
log.warning("Found more than one timeform for %s:%s", group, kind)
return points[0].load()
def get_avail_entrypoints(group):
return [e.name for e in iter_entry_points(group=group)]