Marty Oehme
c2aec7add6
This allows headers to be created by a formatter, which will *only* be added to the very first entry created and not to each entry. Currently for example this is used to create a csv header but not for each document in turn.
28 lines
858 B
Python
28 lines
858 B
Python
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.
|
|
"""
|
|
first_entry = True
|
|
for doc, annots in annot_docs:
|
|
output: str = self.formatter(doc, annots, first=first_entry)
|
|
if output:
|
|
print("{output}\n".format(output=output.rstrip("\n")))
|
|
first_entry = False
|