#!/usr/bin/env python3 # -*- coding: utf-8 -*- """作业 9 · 生成 16:9 HTML 幻灯片(浏览器全屏即 PPT)。""" from __future__ import annotations import html from pathlib import Path from typing import Any import _bootstrap # noqa: F401 from 作业9_ppt_data import data_dir, fmt_int, fmt_pct, repo_root def e(s: Any) -> str: return html.escape("" if s is None else str(s), quote=True) def svg_bars(daily: list[dict[str, Any]]) -> str: if not daily: return "
暂无趋势数据
" vals = [int(d.get("traces") or 0) for d in daily] mx = max(vals) or 1 w, h, pad = 720, 220, 28 gap = 6 n = len(vals) bw = max(8, (w - pad * 2 - gap * (n - 1)) / n) parts = [ '") return "".join(parts) def render_html(deck: dict[str, Any]) -> str: core = deck.get("core") or {} biz = deck.get("business") or {} cost = deck.get("cost") or {} nxt = deck.get("next") or {} mom = core.get("mom") or {} daily = list(core.get("daily") or []) goals = "".join("