Merge branch 'mizaki-talker_entry_points' into develop

This commit is contained in:
Timmy Welch 2023-02-20 14:27:09 -08:00
commit f131c650fb
No known key found for this signature in database
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -66,6 +66,9 @@ setup(
"rar = comicapi.archivers.rar:RarArchiver",
"folder = comicapi.archivers.folder:FolderArchiver",
],
"comictagger.talkers": [
"comicvine = comictalker.talkers.comicvine:ComicVineTalker",
],
},
classifiers=[
"Development Status :: 4 - Beta",