refactor: Extract extractor list to extractor module
This commit is contained in:
parent
629932a5e8
commit
a51205954c
3 changed files with 10 additions and 9 deletions
|
@ -8,6 +8,7 @@ import papis.strings
|
||||||
from papis.document import Document
|
from papis.document import Document
|
||||||
|
|
||||||
from papis_extract import exporter, extraction
|
from papis_extract import exporter, extraction
|
||||||
|
from papis_extract.extractors import all_extractors
|
||||||
from papis_extract.annotation import Annotation
|
from papis_extract.annotation import Annotation
|
||||||
from papis_extract.formatter import Formatter, formatters
|
from papis_extract.formatter import Formatter, formatters
|
||||||
|
|
||||||
|
@ -55,10 +56,10 @@ papis.config.register_default_settings(DEFAULT_OPTIONS)
|
||||||
"-e",
|
"-e",
|
||||||
"extractors",
|
"extractors",
|
||||||
type=click.Choice(
|
type=click.Choice(
|
||||||
list(extraction.extractors.keys()),
|
list(all_extractors.keys()),
|
||||||
case_sensitive=False,
|
case_sensitive=False,
|
||||||
),
|
),
|
||||||
default=list(extraction.extractors.keys()),
|
default=list(all_extractors.keys()),
|
||||||
multiple=True,
|
multiple=True,
|
||||||
help="Choose an extractor to apply to the selected documents.",
|
help="Choose an extractor to apply to the selected documents.",
|
||||||
)
|
)
|
||||||
|
@ -107,7 +108,7 @@ def main(
|
||||||
write=write,
|
write=write,
|
||||||
git=git,
|
git=git,
|
||||||
formatter=formatter,
|
formatter=formatter,
|
||||||
extractors=[extraction.extractors.get(e) for e in extractors],
|
extractors=[all_extractors.get(e) for e in extractors],
|
||||||
force=force,
|
force=force,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import papis.logging
|
||||||
from papis.document import Document
|
from papis.document import Document
|
||||||
|
|
||||||
from papis_extract.annotation import Annotation
|
from papis_extract.annotation import Annotation
|
||||||
from papis_extract.extractors.pdf import PdfExtractor
|
|
||||||
|
|
||||||
logger = papis.logging.get_logger(__name__)
|
logger = papis.logging.get_logger(__name__)
|
||||||
|
|
||||||
|
@ -51,8 +50,3 @@ def start(
|
||||||
logger.warning("Did not find suitable file for document: " f"{desc}")
|
logger.warning("Did not find suitable file for document: " f"{desc}")
|
||||||
|
|
||||||
return annotations
|
return annotations
|
||||||
|
|
||||||
|
|
||||||
extractors: dict[str, Extractor] = {
|
|
||||||
"pdf": PdfExtractor(),
|
|
||||||
}
|
|
||||||
|
|
6
papis_extract/extractors/__init__.py
Normal file
6
papis_extract/extractors/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from papis_extract.extraction import Extractor
|
||||||
|
from papis_extract.extractors import pdf
|
||||||
|
|
||||||
|
all_extractors: dict[str, Extractor] = {
|
||||||
|
"pdf": pdf.PdfExtractor(),
|
||||||
|
}
|
Loading…
Reference in a new issue