entrypoints_utils.py 608 B

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