mth5.groups.reports
Classes
Store report files (PDF/text) and images under |
Module Contents
- class mth5.groups.reports.ReportsGroup(group: h5py.Group, **kwargs: Any)[source]
Bases:
mth5.groups.base.BaseGroupStore report files (PDF/text) and images under
/Survey/Reports.Files are embedded into HDF5 datasets with basic metadata preserved.
Examples
>>> reports = survey.reports_group >>> _ = reports.add_report("site_report", filename="/tmp/report.pdf") >>> _ = reports.get_report("site_report")
- add_report(report_name: str, report_metadata: dict[str, Any] | None = None, filename: str | pathlib.Path | None = None) None[source]
Add a report or image file to the group.
- Parameters:
report_name (str) – Dataset name to store the file under.
report_metadata (dict, optional) – Additional attributes to attach to the dataset.
filename (str or Path, optional) – Path to the file to embed; supported types: PDF/TXT/MD and common images.
- Raises:
FileNotFoundError – If
filenamedoes not exist.
Examples
>>> reports.add_report("manual", filename="docs/manual.pdf")
- get_report(report_name: str) pathlib.Path[source]
Extract a stored report or image to the current working directory.
- Parameters:
report_name (str) – Name of the stored dataset.
- Returns:
Path to the materialized file on disk.
- Return type:
pathlib.Path
- Raises:
ValueError – If the stored file type is unsupported.
Examples
>>> path = reports.get_report("site_report") >>> path.exists() True