Improve stdout rendering

This commit is contained in:
Marty Oehme 2022-12-22 19:39:36 +01:00
parent 80b615651c
commit 2380772396
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9

View file

@ -90,7 +90,7 @@ class ExtractPlugin(PapersPlugin):
try: try:
papers_annotated.append((paper, self._get_annotations(file))) papers_annotated.append((paper, self._get_annotations(file)))
except fitz.FileDataError as e: except fitz.FileDataError as e:
print(f"ERROR: Document {file} is broken: {e}") self.ui.error(f"Document {file} is broken: {e}")
return papers_annotated return papers_annotated
def _gather_papers(self, citekeys): def _gather_papers(self, citekeys):
@ -102,7 +102,7 @@ class ExtractPlugin(PapersPlugin):
def _get_file(self, paper): def _get_file(self, paper):
path = self.broker.real_docpath(paper.docpath) path = self.broker.real_docpath(paper.docpath)
if not path: if not path:
self.ui.error(f"{paper.citekey} has no valid document.") self.ui.warning(f"{paper.citekey} has no valid document.")
return path return path
def _get_annotations(self, filename): def _get_annotations(self, filename):
@ -118,14 +118,16 @@ class ExtractPlugin(PapersPlugin):
return annotations return annotations
def _to_stdout(self, annotated_papers): def _to_stdout(self, annotated_papers):
output = ""
for contents in annotated_papers: for contents in annotated_papers:
paper = contents[0] paper = contents[0]
annotations = contents[1] annotations = contents[1]
if annotations: if annotations:
print(f"{paper.citekey}") output+=f"{paper.citekey}\n"
for annot in annotations: for annot in annotations:
print(f'> "{annot}"') output+=f'> "{annot}"\n'
print("") output+="\n"
print(output)
def _to_notes(self, conf, annotated_papers, edit=False): def _to_notes(self, conf, annotated_papers, edit=False):
for contents in annotated_papers: for contents in annotated_papers: