Add CT verion check against talker requirements
This commit is contained in:
parent
d37c7a680d
commit
12dd06c558
@ -4,6 +4,8 @@ import logging
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from packaging.specifiers import InvalidSpecifier, SpecifierSet
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
from importlib_metadata import entry_points
|
||||
else:
|
||||
@ -30,7 +32,15 @@ def get_talkers(version: str, cache: pathlib.Path) -> dict[str, ComicTalker]:
|
||||
if obj.id != talker.name:
|
||||
logger.error("Talker ID must be the same as the entry point name")
|
||||
continue
|
||||
talkers[talker.name] = obj
|
||||
try:
|
||||
if version in SpecifierSet(obj.ct_req_spec, prereleases=True):
|
||||
talkers[talker.name] = obj
|
||||
else:
|
||||
logger.error(
|
||||
f"CT required version not met for talker: {talker.name} with specifier: {obj.ct_req_spec}"
|
||||
)
|
||||
except InvalidSpecifier:
|
||||
logger.error(f"Invalid specifier for talker: {talker.name} - specifier: {obj.ct_req_spec}")
|
||||
|
||||
except Exception:
|
||||
logger.exception("Failed to load talker: %s", talker.name)
|
||||
|
@ -107,6 +107,7 @@ class ComicTalker:
|
||||
|
||||
name: str = "Example"
|
||||
id: str = "example"
|
||||
ct_req_spec: str = ">=1.6.0a7" # The ComicTagger version required by the talker using PyPA version specifiers
|
||||
website: str = "https://example.com"
|
||||
logo_url: str = f"{website}/logo.png"
|
||||
attribution: str = f"Metadata provided by <a href='{website}'>{name}</a>"
|
||||
|
Loading…
Reference in New Issue
Block a user