aeat.domain.calculations.registry._loader module¶
Read-only TOML loader for AEAT registry definitions.
Compiles TOML authoring fragments into strict runtime objects. Each
ModeloDefinition is assembled from one TOML file or a directory
manifest; each ModeloRevision is compiled from a single revision
file or a set of append fragments merged in deterministic order.
- class ModeloRevisionSource(revision_id, layout, path, fragment_paths)[source]¶
Bases:
objectOn-disk source for one modelo revision before schema validation.
- Parameters:
-
path:
Path¶
- class ModeloSource(modelo_id, layout, path, manifest_path, revision_sources=())[source]¶
Bases:
objectOn-disk source for one modelo before schema validation.
- Parameters:
-
path:
Path¶
-
manifest_path:
Path¶
-
revision_sources:
tuple[ModeloRevisionSource,...]¶
- load_modelo_file(path)[source]¶
Load one modelo TOML file into strict schema objects.
- Return type:
- Returns:
The compiled
ModeloDefinitionfrom the TOML file.- Parameters:
path (Path)
- load_modelo_directory(directory)[source]¶
Load a
ModeloDefinitionfrom a directory layout.The directory must contain
manifest.tomlcarrying the[modelo]metadata table. Per-revision data lives inrevisions/{id}.tomlfiles, or inrevisions/{id}/fragment directories. Revision files declare one or more revisions via top-level[revisions."<id>"](and[[revisions."<id>".X]]array tables). Fragment directories declare exactly the directory revision id across one or more TOML files using the same table shape. All revision sources are merged into the single in-memoryModeloDefinitionthat single-file mode produces.Public API stays identical to
load_modelo_file: callers receive the sameModeloDefinitionregardless of on-disk layout.- Return type:
- Parameters:
directory (Path)
- load_modelo_path(path)[source]¶
Load a
ModeloDefinitionfrom either supported on-disk layout.- Return type:
- Parameters:
path (Path)
- load_modelo_source(source)[source]¶
Load a modelo from a discovered source descriptor.
- Return type:
- Returns:
The compiled
ModeloDefinitionfrom the source.- Parameters:
source (ModeloSource)
- load_modelo_directory_without_locales(resolved)[source]¶
Load a directory-mode
ModeloDefinitionwithout applying locale TOML.Composes the same manifest/revisions/build steps as
load_modelo_directory()but skipsapply_locales(), for callers (the schema-local locale-authoring CLI) that must read the raw Spanish schema before any translation overlay is injected.- Raises:
RegistryLoadError – If the manifest is missing, malformed, or no revisions are found under
resolved/revisions.- Return type:
- Parameters:
resolved (Path)
- load_catalogue_file(path)[source]¶
Load one shared legal/source catalogue TOML file.
- Return type:
- Returns:
The compiled
RegistryCataloguesfrom the TOML file.- Parameters:
path (Path)
- load_legal_parameters_only(root)[source]¶
Load only the legal-parameter catalogue from
root/legal/*.toml.Lightweight cycle-safe entry point. Consumers in
aeat.domain.ivaandaeat.domain.rentalneed parameter values at module-import time, but the fullload_registry_tree()path pulls in_bindingswhich itself imports fromaeat.domain.iva— a circular import.This function reuses
load_catalogue_file()(already Pydantic-validated andlru_cache-deduplicated) and walks onlyroot/legal/*.toml. Modelo parsing and binding validation do not run; the legal refs carried by returned parameters are still resolved against the legal catalogue.- Parameters:
root (
Path) – Repositoryregistry/aeatdirectory.- Return type:
- Returns:
Frozen mapping of parameter-id →
LegalParameter.- Raises:
RegistryLoadError – When duplicate parameter ids are found across multiple TOML files in
root/legal/.
- load_registry_tree(root)[source]¶
Load all registry files from
root.- Discovers modelos in two layouts:
single-file:
modelos/<id>.tomldirectory:
modelos/<id>/manifest.toml+modelos/<id>/revisions/*.toml
A single modelo cannot exist in both layouts simultaneously; the loader raises
RegistryLoadErrorif both forms are present.- Return type:
- Returns:
A tuple of all
ModeloDefinitionobjects and the mergedRegistryCatalogues.- Parameters:
root (Path)
- discover_modelo_sources(modelos_dir)[source]¶
Discover
ModeloSourcelayouts under amodelos/directory.This is the generic source-layout contract for the registry: callers can reason about single-file modelos, directory-mode modelos, per-revision files, and fragmented revision directories without special-casing a modelo id.
- Return type:
- Parameters:
modelos_dir (Path)