feat(export): scenario signature on the main sheet, one column per label

Eleven S: columns on the attacks sheet (1 = confirmed v1 label, p = proposed by
the site's keyword engine) plus scenarios_in_order; the separate case_scenarios
sheet stays. Old dated export removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZZENdTLzNGsbNy4DyF1yt
This commit is contained in:
StellarCrow
2026-09-17 17:49:36 +02:00
co-authored by Claude Fable 5.1
parent 6c6f79c34e
commit 10fddba77d
4 changed files with 22 additions and 5 deletions
+21 -4
View File
@@ -115,7 +115,9 @@ def main():
"description", "notes", "money_wanted", "coin_type", "reports", "url", "url_2", "url_3", "url_4", "url_5"]
cov_cols = ["sources_with_text", "article_chars", "untrimmed_blocks", "summary_status", "summary_chars"]
new_cols = ["venue_of_control", "held_duration", "outcome", "arrests", "amount_demanded_usd", "amount_taken_usd"]
cols = base_cols + FLAGS + cov_cols + new_cols + ["summary"]
SCEN = VOCAB["scenario (11 labels)"]
scen_cols = ["S: " + n for n in SCEN] + ["scenarios_in_order"]
cols = base_cols + scen_cols + FLAGS + cov_cols + new_cols + ["summary"]
LABEL = {"kidnappings": "detention"} # the DB column keeps its old name; the export shows the glossary name
ws.append([LABEL.get(c, c) for c in cols])
for c in ws[1]:
@@ -133,7 +135,13 @@ def main():
sstat = "bulk, short"
else:
sstat = "bulk, unverified"
row = [r.get(k) for k in base_cols] + [r.get(k) for k in FLAGS] + \
tags = build_signature(r, r.get("scenario")) if build_signature else [
{"scenario": r.get("scenario"), "status": "confirmed"}]
tagmap = {t["scenario"]: t["status"] for t in tags}
scen_vals = [(1 if tagmap.get(n) == "confirmed" else ("p" if tagmap.get(n) == "proposed" else None)) for n in SCEN]
seq_text = " > ".join([t["scenario"] for t in tags if t["status"] == "confirmed"]
+ [t["scenario"] + " (p)" for t in tags if t["status"] == "proposed"])
row = [r.get(k) for k in base_cols] + scen_vals + [seq_text] + [r.get(k) for k in FLAGS] + \
[n_src, chars, untr, sstat, len(r.get("summary") or "")]
# rule-derived proposals for the new columns
venue = held = outcome = None
@@ -155,6 +163,15 @@ def main():
for j, k in enumerate(cols, 1):
cell = ws.cell(row=rown, column=j)
v = cell.value
if k.startswith("S: "):
if v == "p":
cell.fill = BLUE
elif v is None and r.get("scenario") not in SCEN:
cell.fill = RED
continue
if k == "scenarios_in_order":
cell.fill = ORANGE if "(p)" in (v or "") or len(tags) == 1 else None
continue
if k in FLAGS and v is None:
cell.fill = RED
elif k == "kidnappings" and cid in det and str(det[cid].get("status", "")).startswith(("ACCEPTED", "proposed")) \
@@ -177,8 +194,8 @@ def main():
cell.fill = BLUE if v not in (None, "") else ORANGE
ws.freeze_panes = "B2"
for j, k in enumerate(cols, 1):
ws.column_dimensions[get_column_letter(j)].width = 60 if k in ("summary", "description") else (
28 if k in ("victim", "location", "money_wanted", "url") else 14)
ws.column_dimensions[get_column_letter(j)].width = 60 if k in ("summary", "description", "scenarios_in_order") else (
28 if k in ("victim", "location", "money_wanted", "url") else (8 if k.startswith("S: ") else 14))
ws.auto_filter.ref = ws.dimensions
# ---------------- case_scenarios ----------------
@@ -1 +1 @@
,disi,pop-os,15.09.2026 15:33,file:///home/disi/.config/libreoffice/4;
,disi,pop-os,17.09.2026 17:23,file:///home/disi/.config/libreoffice/4;