2024-01-25 20:34:40 +00:00
|
|
|
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.
|
|
|
|
"""
|
2024-06-12 09:45:35 +00:00
|
|
|
first_entry = True
|
2024-01-25 20:34:40 +00:00
|
|
|
for doc, annots in annot_docs:
|
2024-06-12 09:45:35 +00:00
|
|
|
output: str = self.formatter(doc, annots, first=first_entry)
|
2024-01-25 20:34:40 +00:00
|
|
|
if output:
|
|
|
|
print("{output}\n".format(output=output.rstrip("\n")))
|
2024-06-12 09:45:35 +00:00
|
|
|
first_entry = False
|