aeat.adapters.inbound.pdf._utils module

Shared low-level helpers used by every PDF-import family adapter.

Declaracion, borrador, and justificante parsers all need the same two provenance operations: hash the source bytes for integrity and derive a persistable source reference that does not expose the operator’s local filename. Keeping those helpers here prevents per-format drift in the secure-storage boundary.

sha256_file(path)[source]

Return the lowercase hex SHA-256 of the bytes at path.

Delegates to the canonical chunked file digest, wrapping the OSError raised on an unreadable artefact in the shared PDF-import error so callers see the translated message rather than a raw OS failure. Error messages and logs use <input-pdf> instead of the concrete path to avoid leaking source filenames through diagnostics.

Return type:

str

Parameters:

path (Path)

source_pdf_reference_path(source_pdf_sha256)[source]

Return the persisted source reference path for a parsed PDF digest.

The returned value is .secure-source/<sha256>.pdf rather than the operator’s local filesystem path. Parser records can persist it as provenance without disclosing the source directory or filename, while the companion digest remains the integrity coordinate for the original bytes.

Return type:

Path

Parameters:

source_pdf_sha256 (str)