Add --debug option to emit research CSVs
Add a --debug CLI flag to control writing of research CSVs alongside JSON exports. CLI: register --debug and pass write_debug_csv into run_live_capture; only write CSV/print CSV path when debug is enabled. Runner: add write_debug_csv parameter, skip writing CSVs and set csv_path to None when disabled, and avoid printing CSV lines for those exports. README: update live-capture docs to show JSON as the default export and note the --debug behavior for producing CSVs.
This commit is contained in:
parent
30dc4e4831
commit
0a1a19939b
3 changed files with 23 additions and 6 deletions
|
|
@ -32,7 +32,9 @@ Live capture, Windows:
|
||||||
.\run-exporter.ps1 --live
|
.\run-exporter.ps1 --live
|
||||||
```
|
```
|
||||||
|
|
||||||
Launch it before logging in, then open any supported history board in game. The tool keeps listening until you press any key. Exports are written under `exports\` as `Permanent_<date_time>.csv/json`, `Limited_<date_time>.csv/json`, or `Arc_<date_time>.csv/json`.
|
Launch it before logging in, then open any supported history board in game. The tool keeps listening until you press any key. Exports are written under `exports\` as `Permanent_<date_time>.json`, `Limited_<date_time>.json`, or `Arc_<date_time>.json`.
|
||||||
|
|
||||||
|
Pass `--debug` to also write the full research CSV next to each JSON export.
|
||||||
|
|
||||||
If only one banner is captured, the export JSON is copied to the clipboard. If multiple banners are captured in the same run, clipboard copy is skipped so one banner does not overwrite another.
|
If only one banner is captured, the export JSON is copied to the clipboard. If multiple banners are captured in the same run, clipboard copy is skipped so one banner does not overwrite another.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ def build_parser() -> argparse.ArgumentParser:
|
||||||
parser.add_argument("--flow-index", type=int, default=None)
|
parser.add_argument("--flow-index", type=int, default=None)
|
||||||
parser.add_argument("--interface-ip", default=None, help="local IPv4 address to bind for live capture")
|
parser.add_argument("--interface-ip", default=None, help="local IPv4 address to bind for live capture")
|
||||||
parser.add_argument("--no-clipboard", action="store_true", help="do not copy live exports to clipboard")
|
parser.add_argument("--no-clipboard", action="store_true", help="do not copy live exports to clipboard")
|
||||||
|
parser.add_argument("--debug", action="store_true", help="also write research CSVs next to the JSON exports")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--allow-boundary-records",
|
"--allow-boundary-records",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
|
@ -34,6 +35,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
result = run_live_capture(
|
result = run_live_capture(
|
||||||
interface_ip=args.interface_ip,
|
interface_ip=args.interface_ip,
|
||||||
copy_clipboard=not args.no_clipboard,
|
copy_clipboard=not args.no_clipboard,
|
||||||
|
write_debug_csv=args.debug,
|
||||||
)
|
)
|
||||||
for item in result["exports"]:
|
for item in result["exports"]:
|
||||||
export = item["export"]
|
export = item["export"]
|
||||||
|
|
@ -69,7 +71,8 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
pair_count = len(decoded["pairs"])
|
pair_count = len(decoded["pairs"])
|
||||||
|
|
||||||
out_path, json_path = export_paths(kind)
|
out_path, json_path = export_paths(kind)
|
||||||
write_csv(out_path, rows)
|
if args.debug:
|
||||||
|
write_csv(out_path, rows)
|
||||||
export = build_export_json(
|
export = build_export_json(
|
||||||
rows,
|
rows,
|
||||||
warnings,
|
warnings,
|
||||||
|
|
@ -80,7 +83,8 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
)
|
)
|
||||||
json_path.write_text(json.dumps(export, ensure_ascii=False, indent=2), encoding="utf-8")
|
json_path.write_text(json.dumps(export, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||||
|
|
||||||
print(f"CSV written: {out_path}")
|
if args.debug:
|
||||||
|
print(f"CSV written: {out_path}")
|
||||||
print(f"JSON written: {json_path}")
|
print(f"JSON written: {json_path}")
|
||||||
print(
|
print(
|
||||||
"Decoded {decoded}, exported {exported}, skipped {skipped}.".format(
|
"Decoded {decoded}, exported {exported}, skipped {skipped}.".format(
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ def run_live_capture(
|
||||||
*,
|
*,
|
||||||
interface_ip: str | None = None,
|
interface_ip: str | None = None,
|
||||||
copy_clipboard: bool = True,
|
copy_clipboard: bool = True,
|
||||||
|
write_debug_csv: bool = False,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
local_ip = interface_ip or detect_local_ipv4()
|
local_ip = interface_ip or detect_local_ipv4()
|
||||||
session = LiveHistorySession(local_ip)
|
session = LiveHistorySession(local_ip)
|
||||||
|
|
@ -95,7 +96,8 @@ def run_live_capture(
|
||||||
warnings = page_gap_warnings(pairs, best_run) + warnings
|
warnings = page_gap_warnings(pairs, best_run) + warnings
|
||||||
pages_seen = [p[0] for p in best_run]
|
pages_seen = [p[0] for p in best_run]
|
||||||
csv_path, json_path = export_paths(kind)
|
csv_path, json_path = export_paths(kind)
|
||||||
write_csv(csv_path, rows)
|
if write_debug_csv:
|
||||||
|
write_csv(csv_path, rows)
|
||||||
export = build_export_json(
|
export = build_export_json(
|
||||||
rows,
|
rows,
|
||||||
warnings,
|
warnings,
|
||||||
|
|
@ -104,7 +106,15 @@ def run_live_capture(
|
||||||
)
|
)
|
||||||
payload = json.dumps(export, ensure_ascii=False, indent=2)
|
payload = json.dumps(export, ensure_ascii=False, indent=2)
|
||||||
json_path.write_text(payload, encoding="utf-8")
|
json_path.write_text(payload, encoding="utf-8")
|
||||||
exports.append({"kind": kind, "csv_path": csv_path, "json_path": json_path, "export": export, "payload": payload})
|
exports.append(
|
||||||
|
{
|
||||||
|
"kind": kind,
|
||||||
|
"csv_path": csv_path if write_debug_csv else None,
|
||||||
|
"json_path": json_path,
|
||||||
|
"export": export,
|
||||||
|
"payload": payload,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if not exports:
|
if not exports:
|
||||||
print("No Monopoly history pages were captured.")
|
print("No Monopoly history pages were captured.")
|
||||||
|
|
@ -118,7 +128,8 @@ def run_live_capture(
|
||||||
print("Multiple banners captured; clipboard copy skipped.")
|
print("Multiple banners captured; clipboard copy skipped.")
|
||||||
|
|
||||||
for item in exports:
|
for item in exports:
|
||||||
print(f"CSV written: {item['csv_path']}")
|
if item["csv_path"] is not None:
|
||||||
|
print(f"CSV written: {item['csv_path']}")
|
||||||
print(f"Export written: {item['json_path']}")
|
print(f"Export written: {item['json_path']}")
|
||||||
return {"exports": exports}
|
return {"exports": exports}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue