aeat.adapters.inbound.justificante._parsers package¶
Private text-backend dispatch for the inbound justificante adapter.
Callers outside adapters.inbound.justificante must never import
from here. Backends expose a common extract_text entry point that
returns the raw concatenated text of a justificante PDF; all field-level
extraction happens in adapters.inbound.justificante._extract.
The dispatch is keyed on
domain.justificante.JustificanteParserBackend, and parse
failures are normalised as
domain.justificante.JustificanteParseError. The path entry point
caches concatenated text by source digest, backend, size, and mtime; the bytes
entry point stays uncached so secure-storage callers do not need to materialise
or persist plaintext files.
- extract_text(pdf_path, backend)[source]¶
Extract concatenated text from
pdf_pathusingbackend.The path result is cached for stable file revisions so repeated corpus parses do not reopen the same PDF.
- Parameters:
pdf_path (
Path) – Absolute path to the PDF to read.backend (
JustificanteParserBackend) – Which backend to dispatch to.
- Return type:
- Returns:
The concatenated text of every page in the PDF, joined by newlines.
- Raises:
JustificanteParseError – If the path cannot be read or the selected backend is not implemented.
- extract_text_from_bytes(pdf_bytes, backend)[source]¶
Extract concatenated text from in-memory PDF bytes using
backend.Bytes are sent directly to the selected backend and are not cached, which keeps secure-storage and live-capture parsing free of plaintext filesystem artefacts.
- Return type:
- Parameters:
pdf_bytes (bytes)
backend (JustificanteParserBackend)