Source code for cadrumo.adapters.inbound.censo.parser
"""Inbound parser for the Certificado de Situación Censal (G313) artefact.STRUCTURE-ONLY, extraction deliberately unpinned: the certificate's issuedPDF layout has never been observed against a real specimen (none isobtainable today — no certificate and no usable Clave credentials exist),so this adapter refuses every document loudly and instructively instead ofguessing a layout and silently mis-extracting censal facts. The targetshape and the profile-fact projection are fully typed and tested in:mod:`cadrumo.domain.censo`; the day a specimen arrives (through theencrypted evidence path), the extraction lands here behind the samesignature and the refusal narrows to genuinely unrecognised documents.The bytes route mirrors :func:`parse_justificante_bytes`: secure-storageflows hold decrypted bytes in memory and must never materialise aplaintext temporary file."""from__future__importannotationsfrom....domain.censo.certificadoimportCertificadoCensalParseError,CertificadoSituacionCensal_PDF_MAGIC=b"%PDF-"
[docs]defparse_certificado_censal_bytes(data:bytes)->CertificadoSituacionCensal:"""Parse certificate bytes into a :class:`CertificadoSituacionCensal`. Raises: CertificadoCensalParseError: Always, today. A non-PDF payload is refused as an unrecognised document; a PDF payload is refused because the issued-certificate layout extraction is unpinned pending a real specimen. Both refusals carry a distinct locale key so the flow degrades honestly. """ifnotdata.startswith(_PDF_MAGIC):raiseCertificadoCensalParseError(translated_message="errors.censo.certificado_not_a_pdf",)raiseCertificadoCensalParseError(translated_message="errors.censo.certificado_extraction_unpinned",)