2015-02-01 19:57:50 +01:00
|
|
|
from logging import getLogger
|
2019-06-25 13:49:33 +02:00
|
|
|
|
|
|
|
log = getLogger("entrypoints_utils")
|
2015-02-01 19:57:50 +01:00
|
|
|
from pkg_resources import iter_entry_points
|
|
|
|
|
|
|
|
|
|
|
|
def get_one_entrypoint(group, kind):
|
2019-06-25 13:49:33 +02:00
|
|
|
"""Messes with entrypoints to return an entrypoint of a given group/kind"""
|
2015-02-01 19:57:50 +01:00
|
|
|
points = tuple(iter_entry_points(group=group, name=kind))
|
|
|
|
if not points:
|
2019-06-25 13:49:33 +02:00
|
|
|
raise ValueError("cant find an entrypoint %s:%s" % (group, kind))
|
2015-02-01 19:57:50 +01:00
|
|
|
if len(points) > 1:
|
2017-01-19 11:11:36 +01:00
|
|
|
log.warning("Found more than one timeform for %s:%s", group, kind)
|
2015-02-01 19:57:50 +01:00
|
|
|
return points[0].load()
|
2015-02-01 21:47:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
def get_avail_entrypoints(group):
|
|
|
|
return [e.name for e in iter_entry_points(group=group)]
|