Entry points for talkers
This commit is contained in:
parent
3422a1093d
commit
4b3b9d8691
@ -2,8 +2,13 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
from importlib_metadata import entry_points
|
||||
else:
|
||||
from importlib.metadata import entry_points
|
||||
|
||||
import comictalker.talkers.comicvine
|
||||
from comictalker.comictalker import ComicTalker, TalkerError
|
||||
from comictalker.resulttypes import ComicIssue, ComicSeries
|
||||
|
||||
@ -21,11 +26,13 @@ def get_talkers(version: str, cache: pathlib.Path) -> dict[str, ComicTalker]:
|
||||
"""Returns all comic talker instances"""
|
||||
talkers: dict[str, ComicTalker] = {}
|
||||
|
||||
for talker in [comictalker.talkers.comicvine.ComicVineTalker]:
|
||||
for talker in entry_points(group="comictagger.talkers"):
|
||||
try:
|
||||
obj = talker(version, cache)
|
||||
talker_cls = talker.load()
|
||||
obj = talker_cls(version, cache)
|
||||
talkers[obj.id] = obj
|
||||
except Exception:
|
||||
logger.exception("Failed to load talker: %s", "comicvine")
|
||||
raise TalkerError(source="comicvine", code=4, desc="Failed to initialise talker")
|
||||
logger.exception("Failed to load talker: %s", talker.name)
|
||||
raise TalkerError(source=talker.name, code=4, desc="Failed to initialise talker")
|
||||
|
||||
return talkers
|
||||
|
Loading…
Reference in New Issue
Block a user