Add debug logging for extractor

This commit is contained in:
Marty Oehme 2023-08-28 12:53:03 +02:00
parent df235caf8f
commit 1bb1b80620
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 9 additions and 2 deletions

View file

@ -88,11 +88,11 @@ def _add_annots_to_note(
f.write("\n".join(new_annotations)) f.write("\n".join(new_annotations))
f.write("\n") f.write("\n")
logger.info( logger.info(
f"Wrote {len(new_annotations)} annotations "\ f"Wrote {len(new_annotations)} "
f"{'annotation' if len(new_annotations) == 1 else 'annotations'}"
f"to {papis.document.describe(document)}" f"to {papis.document.describe(document)}"
) )
if git: if git:
msg = "Update notes for '{0}'".format(papis.document.describe(document)) msg = "Update notes for '{0}'".format(papis.document.describe(document))
folder = document.get_main_folder() folder = document.get_main_folder()

View file

@ -2,12 +2,15 @@ from pathlib import Path
import Levenshtein import Levenshtein
import fitz_new as fitz import fitz_new as fitz
import papis.logging
import papis.config import papis.config
from papis_extract.annotation_data import Annotation from papis_extract.annotation_data import Annotation
COLOR_MAPPING = {} COLOR_MAPPING = {}
logger = papis.logging.get_logger(__name__)
def start(filename: Path) -> list[Annotation]: def start(filename: Path) -> list[Annotation]:
"""Extract annotations from a file. """Extract annotations from a file.
@ -30,6 +33,10 @@ def start(filename: Path) -> list[Annotation]:
) )
a.tag = _tag_from_colorname(a.colorname) a.tag = _tag_from_colorname(a.colorname)
annotations.append(a) annotations.append(a)
logger.debug(
f"Found {len(annotations)} "
f"{'annotation' if len(annotations) == 1 else 'annotations'} for {filename}."
)
return annotations return annotations