mpylab.reporting.profile module¶
Shared report-profile validation and provenance without domain dependencies.
- mpylab.reporting.profile.load_report_profile(path, *, allow_pdf_logo=False)
Load and validate one TOML report profile.
- Parameters:
path (path-like) – TOML profile to load. Relative logo paths are resolved from this file’s directory.
allow_pdf_logo (bool, optional) – Accept PDF logos for renderers supporting PDF embedding. Defaults to False; TEM reports continue to require PNG or JPEG images.
- Returns:
Validated profile with source and value-origin information.
- Return type:
- Raises:
ReportProfileError – If TOML syntax, sections, values, colors, dates, environmental values, or the configured logo are invalid.
OSError – If the profile file cannot be opened.
- mpylab.reporting.profile.report_metadata_rows(profile, created_at=None)
Convert effective report metadata to provenance-aware table rows.
- Parameters:
profile (ReportProfile) – Resolved report profile.
created_at (datetime.datetime or None, optional) – UTC report-creation timestamp.
Noneuses the current UTC time.
- Returns:
Rows with
section,key,value, andsourcefields. The source distinguishes generated values, defaults, missing values, and the profile file that supplied an explicit value.- Return type:
list of dict
- mpylab.reporting.profile.resolve_report_profile(profile=None, *, allow_pdf_logo=False)
Resolve defaults, one profile, or an ordered profile stack.
- Parameters:
profile (path-like, ReportProfile, iterable, or None, optional) – Profile input. Iterable entries may themselves be paths or resolved profiles and are merged in order, with later values overriding only identical section keys.
Noneor an empty iterable selects the validated defaults.allow_pdf_logo (bool, optional) – Accept PDF logos for renderers supporting PDF embedding. Defaults to False; TEM reports continue to require PNG or JPEG images.
- Returns:
Effective profile retaining all source paths and per-value origins.
- Return type:
- Raises:
ReportProfileError – If the input type or any profile value is invalid, or a configured logo cannot be found.
OSError – If a referenced profile file cannot be opened.
- mpylab.reporting.profile.write_report_metadata_table(path, rows)
Write report metadata and provenance as a TSV table.
- Parameters:
path (path-like) – Destination file. Missing parent directories are created.
rows (iterable of mapping) – Metadata rows using
METADATA_FIELDS, normally returned byreport_metadata_rows().
- Returns:
Destination path after writing the table.
- Return type:
pathlib.Path