papis-extract/papis_extract/extractors/__init__.py
Marty Oehme c2a5190237
refactor: Improve module availability checks
Followed ruff (Pyflakes) suggestion to use importlib utils directly
instead of try and erroring with imports.
2024-01-24 12:27:21 +01:00

19 lines
512 B
Python

from importlib.util import find_spec
import papis.logging
from papis_extract.extraction import Extractor
from papis_extract.extractors import pdf
from papis_extract.extractors.pocketbook import PocketBookExtractor
logger = papis.logging.get_logger(__name__)
all_extractors: dict[str, Extractor] = {}
all_extractors["pdf"] = pdf.PdfExtractor()
if find_spec("bs4") and find_spec("magic"):
all_extractors["pocketbook"] = PocketBookExtractor()
else:
logger.debug("pocketbook extractor not activated.")