refactor: share falsey-safe html rendering

This commit is contained in:
yaojingang
2026-06-14 14:46:44 +08:00
parent 7b210a5417
commit 6f5f4db4a7
7 changed files with 46 additions and 17 deletions
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
import argparse
import html
import json
from datetime import date
from pathlib import Path
from typing import Any
from html_rendering import html_text
from render_world_class_evidence_intake import build_intake
from render_world_class_evidence_ledger import build_ledger
from render_world_class_submission_review import build_submission_review
@@ -23,10 +23,6 @@ def rel_path(path: Path, root: Path) -> str:
return str(path.resolve())
def html_text(value: Any) -> str:
return html.escape("" if value is None else str(value), quote=True)
def by_key(items: list[dict[str, Any]], key_name: str) -> dict[str, dict[str, Any]]:
return {str(item.get(key_name, "")): item for item in items if item.get(key_name)}