Source code for cadrumo.adapters.persistence.profile.invoice_source_resolver
"""Outward adapter for the invoice source-mesh read capability.Core types::class:`~cadrumo.domain.invoices.models.InvoiceCatalogue`."""from__future__importannotationsfromtypingimportoverridefrom....application.invoices.source_resolver_portsimport(InvoiceSourceCatalogueReader,InvoiceSourcePersistenceError,)from....domain.invoices.modelsimportInvoiceCataloguefrom..storage.errorsimportSTORAGE_DEGRADATION_ERRORSfrom.invoicesimportInvoiceCatalogueRepository
[docs]classInvoiceCatalogueSourceResolverAdapter(InvoiceSourceCatalogueReader):"""Translate the encrypted invoice repository to the application read port."""def__init__(self,*,repository:InvoiceCatalogueRepository)->None:"""Bind an already-composed invoice repository."""self._repository=repository
[docs]@overridedefload(self)->InvoiceCatalogue:"""Load the catalogue while translating degradation failures."""try:returnself._repository.load()exceptSTORAGE_DEGRADATION_ERRORSasexc:raiseInvoiceSourcePersistenceError("invoice_catalogue_load")fromexc