""" Accident Reporting Layer Generates production-grade HTML and JSON reports, incorporating visualizations. """ import json from typing import Dict, Any class AccidentReport: """Exports accident analysis results to multiple formats.""" def __init__(self, metrics: Dict[str, Any], insights: Dict[str, Any]): self.metrics = metrics self.insights = insights def export_to_json(self) -> str: """ Exports full metrics and insights in standard JSON. Returns: JSON formatted string. """ payload = { "metrics": self.metrics, "insights": self.insights } return json.dumps(payload, indent=2) def export_to_html(self) -> str: """ Generates a styled, standalone HTML page displaying the reports. Returns: HTML markup string. """ rec_list = "".join(f"
  • {r}
  • " for r in self.insights.get("safety_recommendations", [])) html = f""" Accident Analysis Executive Report

    Accident Analysis Summary Report

    Calamity Risk Index (0-10): {self.insights.get("risk_index", 0)}
    Peak Danger Hour: {self.insights.get("deadliest_hour", "N/A")}
    Primary Collision Threat: {self.insights.get("primary_collision_threat", "N/A")}
    Primary Geospatial Hotspot: {self.insights.get("primary_geospatial_hotspot", "N/A")}

    Safety Recommendations

    """ return html