cdm_reader_mapper.mdf_reader.schemas package

Common Data Model (CDM) schema tables.

Subpackages

Submodules

cdm_reader_mapper.mdf_reader.schemas.schemas module

Manage data model schema files.

Functions to manage data model schema files and objects according to the requirements of the data reader tool.

class cdm_reader_mapper.mdf_reader.schemas.schemas.SchemaDict[source]

Bases: TypedDict

Complete schema definition for a report.

Variables:
  • header (SchemaHeaderDict, optional) – Configuration for the report header.

  • sections (dict[str, SectionDict], optional) – Mapping of section names to section schemas.

  • elements (dict, optional) – Mapping of element names to their attributes.

  • name (list[Path], optional) – List of Path objects representing schema files or sources.

  • imodel (str | None, optional) – Name of the internal data model, if applicable.

elements: dict[str, Any]
header: SchemaHeaderDict
imodel: str | None
name: list[Path]
sections: dict[str, SectionDict]
class cdm_reader_mapper.mdf_reader.schemas.schemas.SchemaHeaderDict[source]

Bases: TypedDict

Schema definition for the report header.

Variables:
  • parsing_order (list[dict], optional) – List of dictionaries defining the order in which header fields are parsed.

  • delimiter (str, optional) – Delimiter used to separate fields in the header.

  • field_layout (str, optional) – Layout or format of the fields (e.g., fixed width, CSV).

  • format (str, optional) – General format type of the header.

  • encoding (str, optional) – Text encoding for the header, e.g., ‘utf-8’.

  • multiple_reports_per_line (bool, optional) – Whether multiple reports may appear on a single line.

delimiter: str
encoding: str
field_layout: str
format: str
multiple_reports_per_line: bool
parsing_order: list[dict[str, Any]]
class cdm_reader_mapper.mdf_reader.schemas.schemas.SectionDict[source]

Bases: TypedDict

Schema definition for a single section within a report.

Variables:
  • header (dict, optional) – Metadata or configuration for the section header.

  • elements (dict, optional) – Dictionary of elements/fields contained within the section.

elements: dict[str, Any]
header: dict[str, Any]
cdm_reader_mapper.mdf_reader.schemas.schemas.read_schema(imodel=None, ext_schema_path=None, ext_schema_file=None)[source]

Load and normalize a data model schema.

Reads a data model schema file into a dictionary and normalizes it by adding the information required by the parser.

Parameters:
  • imodel (str, optional) – Name of internally available input data model, e.g. icoads_r300_d704.

  • ext_schema_path (str or Path, optional) – The path to the external input data model schema file. The schema file must have the same name as the directory. One of imodel and ext_schema_path or ext_schema_file must be set.

  • ext_schema_file (str or Path, optional) – The external input data model schema file. One of imodel and ext_schema_path or ext_schema_file must be set.

Return type:

SchemaDict

Returns:

SchemaDict – Data model schema.