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
|
|
@ -46,6 +46,7 @@ def run_live_capture(
|
|||
*,
|
||||
interface_ip: str | None = None,
|
||||
copy_clipboard: bool = True,
|
||||
write_debug_csv: bool = False,
|
||||
) -> dict:
|
||||
local_ip = interface_ip or detect_local_ipv4()
|
||||
session = LiveHistorySession(local_ip)
|
||||
|
|
@ -95,7 +96,8 @@ def run_live_capture(
|
|||
warnings = page_gap_warnings(pairs, best_run) + warnings
|
||||
pages_seen = [p[0] for p in best_run]
|
||||
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(
|
||||
rows,
|
||||
warnings,
|
||||
|
|
@ -104,7 +106,15 @@ def run_live_capture(
|
|||
)
|
||||
payload = json.dumps(export, ensure_ascii=False, indent=2)
|
||||
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:
|
||||
print("No Monopoly history pages were captured.")
|
||||
|
|
@ -118,7 +128,8 @@ def run_live_capture(
|
|||
print("Multiple banners captured; clipboard copy skipped.")
|
||||
|
||||
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']}")
|
||||
return {"exports": exports}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue