Source code for cadrumo.application.user_profile.profile_keys
"""Application-owned profile-key catalogue projection.The operation-scoped setup flow is the sole authoring source. The catalogueis compiled for the caller's pinned generation; no domain slot, registrationpush, or import-order bootstrap is involved."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfrom...core.requirementimportRequirementfrom...domain.contribuyente.normaliseimportnormalise_keyfrom.profile_keyimportProfileKeyifTYPE_CHECKING:from...domain.calculations.registry.authorityimportPinnedAuthorityOperation
[docs]defprofile_keys(operation:PinnedAuthorityOperation)->tuple[ProfileKey,...]:"""Compile and return profile keys from the caller's pinned wizard flow."""from..wizard.catalogueimportbuild_setup_flowfrom..wizard.compilerimportcompile_profile_keysreturncompile_profile_keys((build_setup_flow(operation),))
[docs]defprofile_key(raw:str,*,operation:PinnedAuthorityOperation)->ProfileKey:"""Return the catalogue record matching ``raw`` after key normalisation."""canonical=normalise_key(raw)forentryinprofile_keys(operation):ifentry.key==canonical:returnentryraiseKeyError(f"unknown profile key: {raw!r}")
[docs]defoptional_profile_keys(operation:PinnedAuthorityOperation)->tuple[ProfileKey,...]:"""Return catalogue entries whose requirement is ``OPTIONAL``."""returntuple(entryforentryinprofile_keys(operation)ifentry.requirementisRequirement.OPTIONAL)