"""Engine dignity on each body of a `/api/varga_full` divisional chart (BUG-1202). The chart page's divisional tables show the same ten-level dignity as the D1 "状态" column. The level is `jyotish_engine.varga_dignity_level`, the function the Vimsopaka path uses, so the page never carries a second rule set. """ from __future__ import annotations from jyotish_engine import varga_dignity_level def annotate_varga_dignity(varga: dict) -> dict: """Add `dignity_level` to every body of one `_calculate_single_varga` result.""" planets = varga.get("planets") if isinstance(varga, dict) else None if not isinstance(planets, dict): return varga for name, row in planets.items(): if not isinstance(row, dict): continue level = varga_dignity_level(name, planets) if level: row["dignity_level"] = level return varga