INNER CODE UNIT · Python
read_history
OpenChemistry/avogadrolibs · scripts/coverage_summary.py:71
def read_history(path: Path | None) -> list[dict[str, str]]:
if path is None or not path.is_file():
return []
try:
with path.open(newline="", encoding="utf-8") as handle:
return [row for row in csv.DictReader(handle) if row.get("module")]
except (OSError, csv.Error):
return []
def previous_run(rows: list[dict[str, str]]):
"""Return ((date, commit, run_id), {module: row}) for the newest run."""
if not rows:
return None, {}
last = rows[-1]
key = (last.get("date", ""), last.get("commit", ""), last.get("run_id", ""))
by_module = {
row["module"]: row