Skip to content

mambo_power.io.report

The typed conversion reports: ImportReport (returned by every importer's load_with_report) and ExportReport (returned by every exporter). An empty report means the conversion was lossless. See File formats › Warnings; the registry of codes per module is io.limitations.

mambo_power.io.report

The typed reports returned by importers (load_with_report) and exporters (wave M8).

Importers keep two parallel entry points: load_with_warnings returns the legacy list[str] (one CODE: message line per warning, unchanged for M1 callers) and load_with_report returns an ImportReport, whose ImportIssue entries carry the code and the ids involved so a caller can act on them without parsing text. Both come from the same warning objects: report.as_strings() is exactly the legacy list.

Exporters return an ExportReport of the same shape. The rule both share (M8 design item D1): an empty report means the conversion was lossless. Anything dropped, approximated or repaired is an issue naming the element id (bus_ids / element_ids) and, in the message, the field concerned. Importers and exporters neither log nor print; the report is the only channel.

This module is a leaf: it imports only mambo_power.model, and every format module imports it. The registry of codes per module is mambo_power.io.limitations.LIMITATIONS.

ConversionIssue module-attribute

ConversionIssue = ImportIssue

One issue in either report. The record is ImportIssue — its name predates exporters; the shape (code, message, bus_ids, element_ids) and the closed ImportIssueCode set are shared by both directions.

ReportError

ReportError(report: _Report)

Bases: ValueError

Raised by _Report.raise_on_error when a report carries errors.

Source code in src/mambo_power/io/report.py
def __init__(self, report: _Report) -> None:
    self.report = report
    super().__init__("; ".join(str(e) for e in report.errors))

ImportReport dataclass

ImportReport(
    warnings: list[ConversionIssue] = list(),
    errors: list[ConversionIssue] = list(),
)

Bases: _Report

Every repair an importer performed, in the order it happened (empty = lossless).

ExportReport dataclass

ExportReport(
    warnings: list[ConversionIssue] = list(),
    errors: list[ConversionIssue] = list(),
)

Bases: _Report

Every field an exporter dropped, approximated or repaired (empty = lossless, D1).

Mirrors ImportReport exactly: same issue record, warnings/errors, codes, as_strings and raise_on_error. An issue always names the element id and the field.