Parser / Model Mapping Parser

ModelMappingParser

class teksi_hooks.parser.model_mapping_parser.ModelMappingParser[source]

Parse source-model to canonical-model mapping definitions.

A mapping document may contain several named source models under models.

Model definitions may contain:

  • model-level defaults;

  • model inheritance;

  • class-level row projection functions;

  • class-level canonical identities;

  • direct attribute mappings;

  • source relation localisations;

  • value-list lookup definitions.

This parser only converts YAML into mapping models. It does not:

  • inspect source-model classes;

  • apply conditional default attributes;

  • resolve explicit-before-implicit lookup precedence;

  • query value-list relations;

  • execute mapping functions;

  • produce canonical effects.

Conditional defaults, such as mappings for letzte_aenderung_wi and letzte_aenderung_gep, are retained in ModelMapping.defaults. A later resolver applies them only to source classes containing the corresponding source attributes.

parse_file(path, *, model_id=None)[source]

Parse one model mapping from a YAML file.

model_id may be omitted only when the file contains exactly one model.

Parameters:
  • path (str | Path)

  • model_id (str | None)

Return type:

ModelMapping

parse_models_file(path)[source]

Parse all model mappings from a YAML file.

Parameters:

path (str | Path)

Return type:

dict[str, ModelMapping]

parse_dict(data, *, model_id=None)[source]

Parse one model mapping from an already loaded YAML document.

Parameters:
  • data (Mapping[str, Any])

  • model_id (str | None)

Return type:

ModelMapping

parse_models_dict(data)[source]

Parse every model mapping from an already loaded YAML document.

Parameters:

data (Mapping[str, Any])

Return type:

dict[str, ModelMapping]