angee.resources.entries
Value objects for declared addon resource files and parsed rows.
_ResourceAddon
class _ResourceAddon(Protocol)Addon facts consumed by resource declarations.
name
@property
def name() -> strReturn the full dotted Django app name.
label
@property
def label() -> strReturn the short Django app label.
path
@property
def path() -> strReturn the filesystem path to the addon package root.
resolve_model
def resolve_model(label: str) -> type[models.Model]Return the model class named by an app_label.ModelName label.
ResourceDeclaration
One normalized resource entry declaration.
AdoptDeclaration
Normalized resource adoption declaration.
EntryKey
Dependency graph key identifying one resource entry by addon and source.
RESERVED_ROW_KEYS
Row keys interpreted by the resource loader rather than model fields.
TEXT_FORMATS
Supported text resource formats keyed by file suffix.
STRUCTURED_FORMATS
Text formats that can carry _meta and rows envelopes.
resource_manifest_for
def resource_manifest_for(
app_config: AppConfig) -> dict[str, tuple[dict[str, Any], ...]]Return normalized resource declarations keyed by tier for one addon.
ResourceEntry
@dataclass(slots=True)
class ResourceEntry()One local or remote resource file declared by an addon.
addon
Addon that owns this resource declaration.
tier
Normalized resource tier value.
source_key
Registered source key (path for a local file; url once integrate adds it).
source_value
The source's stored value — an addon-relative path, a URL, etc.
model
Optional fallback model label for every row in the file.
encoding
Text encoding used when reading the materialized file.
depends_on
Resource source keys that must load before this entry.
adopt
Unique field(s) used for adoption; True infers one unique field.
from_declaration
@classmethod
def from_declaration(cls, addon: _ResourceAddon, tier: str,
declaration: ResourceDeclaration) -> ResourceEntryReturn an entry from a resource declaration, resolving its source type.
source
@property
def source() -> strReturn this entry's stable source value (path, URL, …).
display
@property
def display() -> strReturn an owner-qualified name for diagnostics.
materialize
def materialize() -> PathReturn the local file path, materializing the source once.
read_resource_rows
def read_resource_rows() -> tuple[ResourceRow, ...]Return parsed and normalized rows from this entry.
infer_model_label
def infer_model_label() -> strInfer app.Model from a [NNN_]app.model.ext filename.
EntryGraph
@dataclass(frozen=True, slots=True)
class EntryGraph()Dependency graph for a selected set of resource entries.
entries
Entries selected for one resource operation.
from_entries
@classmethod
def from_entries(cls, entries: Iterable[ResourceEntry]) -> EntryGraphReturn a graph over entries in their selected order.
ordered
def ordered() -> tuple[ResourceEntry, ...]Return entries in dependency order, preserving independent order.
ResourceRow
@dataclass(slots=True)
class ResourceRow()One normalized resource row.
entry
Entry that contributed this row.
model_label
Django model label targeted by this row.
xref
Addon-local external row key.
values
Model field values to import.
from_record
@classmethod
def from_record(cls,
entry: ResourceEntry,
record: Mapping[str, Any],
*,
index: int,
fallback_model: str | None = None) -> ResourceRowReturn a normalized row from parsed file data.
dataset_row
@property
def dataset_row() -> dict[str, Any]Return the row as an import-export dataset mapping.
ResourceGroup
@dataclass(slots=True)
class ResourceGroup()Rows from one entry that target one model.
entry
Resource entry that supplied the rows.
model
Django model imported by this group.
rows
Rows loaded into the target model.
to_dataset
def to_dataset() -> tablib.DatasetReturn this group as a tablib dataset.
ValidationResult
@dataclass(slots=True)
class ValidationResult()Counts returned by resource validation.
checked_files
Number of resource files checked.
checked_rows
Number of resource rows checked.
LoadResult
@dataclass(slots=True)
class LoadResult()Counts returned by a resource load.
created
Rows created during the load.
updated
Rows updated during the load.
skipped
Rows skipped because the ledger already matched.
with_result
def with_result(result: Result) -> LoadResultReturn this load count plus import-export's native result totals.
loaded
@property
def loaded() -> intReturn the number of created or updated rows.