refactor: Extract exporters to separate module
This commit is contained in:
parent
c8e8453b68
commit
72ddaaf1bc
5 changed files with 213 additions and 157 deletions
26
papis_extract/exporters/stdout.py
Normal file
26
papis_extract/exporters/stdout.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from dataclasses import dataclass
|
||||
|
||||
from papis.document import Document
|
||||
|
||||
from papis_extract.annotation import Annotation
|
||||
from papis_extract.formatter import Formatter
|
||||
|
||||
|
||||
@dataclass
|
||||
class StdoutExporter:
|
||||
formatter: Formatter
|
||||
edit: bool = False
|
||||
git: bool = False
|
||||
force: bool = False
|
||||
|
||||
def run(self, annot_docs: list[tuple[Document, list[Annotation]]]) -> None:
|
||||
"""Pretty print annotations to stdout.
|
||||
|
||||
Gives a nice human-readable representations of
|
||||
the annotations in somewhat of a list form.
|
||||
Not intended for machine-readability.
|
||||
"""
|
||||
for doc, annots in annot_docs:
|
||||
output: str = self.formatter(doc, annots)
|
||||
if output:
|
||||
print("{output}\n".format(output=output.rstrip("\n")))
|
||||
Loading…
Add table
Add a link
Reference in a new issue