Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import os | |
| from pathlib import Path | |
| from backend.core import Backend | |
| from backend.discovery_lanes import discovery_lane_for_kink | |
| def starter_review_rows(backend: Backend, limit: int) -> list[dict[str, object]]: | |
| rows: list[dict[str, object]] = [] | |
| for rank, kink in enumerate(backend._starter_candidates({}, limit), start=1): | |
| rows.append( | |
| { | |
| "rank": rank, | |
| "id": kink["id"], | |
| "name": kink["name"], | |
| "starter_tier": kink.get("starter_tier", ""), | |
| "starter_reason": kink.get("starter_reason") or backend._starter_reason_for_kink(kink), | |
| "lane": discovery_lane_for_kink(kink), | |
| "starter_score": round(float(backend._starter_score(kink)), 3), | |
| "source_backed_popularity": int(float(kink.get("source_backed_popularity", 0.0) or 0.0)), | |
| "popularity": int(float(kink.get("popularity", 0.0) or 0.0)), | |
| } | |
| ) | |
| return rows | |
| def build_parser() -> argparse.ArgumentParser: | |
| parser = argparse.ArgumentParser(description="Print the current starter deck with policy reasons.") | |
| parser.add_argument("--store", default=os.environ.get("KINK_STORE_PATH") or str(Path(__file__).resolve().parent.parent / "data" / "store_slim.db")) | |
| parser.add_argument("--limit", type=int, default=24) | |
| parser.add_argument("--json", action="store_true", help="Emit JSON instead of a text table.") | |
| return parser | |
| def main() -> int: | |
| args = build_parser().parse_args() | |
| backend = Backend(Path(args.store)) | |
| rows = starter_review_rows(backend, max(1, int(args.limit))) | |
| if args.json: | |
| print(json.dumps({"items": rows}, indent=2)) | |
| return 0 | |
| for row in rows: | |
| print( | |
| f"{row['rank']:>2} {row['starter_tier']:<13} {row['lane']:<10} " | |
| f"{row['source_backed_popularity']:>8} {row['name']} -- {row['starter_reason']}" | |
| ) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |