aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/parse-sanpi-hyo.py
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-09-23 22:49:07 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-09-23 22:49:07 +0900
commitef6198546f3ff120598ec50f51f52feb1b15b530 (patch)
tree19f76ccd68854853ffc4058e3174a64f7ea79596 /scripts/parse-sanpi-hyo.py
parentceced3373704062875dec16c6c673ca98170860a (diff)
parse-sanpi-hyo.py ほか: 会派内で分かれた賛否をまとめて表示する
会派内で賛否が割れた場合、その会派の全議員を列にしていたため、令和7年3月は17列と横に長くなっていた。 同じ票の議員は「会派(人数)」にまとめ、異なる議員だけ名前を出して列を分ける方式に変えた。議長・副議長など全議案で表決に加わらない議員は、まとめた列に含める(別の列にしない)。 これで令和7年3月の表は13列になった。あわせて凡例に「退場」を追記した。
Diffstat (limited to 'scripts/parse-sanpi-hyo.py')
-rw-r--r--scripts/parse-sanpi-hyo.py38
1 files changed, 29 insertions, 9 deletions
diff --git a/scripts/parse-sanpi-hyo.py b/scripts/parse-sanpi-hyo.py
index a9a7bd0..1e6a496 100644
--- a/scripts/parse-sanpi-hyo.py
+++ b/scripts/parse-sanpi-hyo.py
@@ -199,24 +199,44 @@ def main(path, label):
ok = str(yes) in pdfs and str(no_) in pdfs
print(f" [検算] {no} {kekka}: 賛成{yes} 反対{no_} / PDF={pdfs} {'✓' if ok else '✗要確認'}")
- # 会派ごとの列(会派内で分かれたとき、および「一人会派」は議員ごとに分ける)
+ # 会派ごとの列。
+ # - 「一人会派」は常に議員ごとに分ける(会派名だけでは構成員が分からないため)
+ # - それ以外は、全議案を通した賛否が同じ議員をまとめる。
+ # 分かれた会派では、複数名が同じ票なら「会派(n人)」にまとめ、
+ # 1人だけ異なる議員は名前を出す(それで列が増えすぎるのを防ぐ)
+ # - 議長・副議長など、全議案で表決に加わらない議員は、まとめた列に含める
out_cols = []
k = 0
for s, f, n in parties:
idx = member_cols[k:k + n]
k += n
- split = ("一人" in s) or any(
- len({d["votes"].get(i) for i in idx if d["votes"].get(i) in (YES | NO)}) > 1
- for d in data
- )
- if not split:
+ if "一人" in s:
+ for i in idx:
+ out_cols.append((f"{mnames[i]}({s})", [i]))
+ continue
+ groups, novote = {}, []
+ for i in idx:
+ pat = tuple(d["votes"].get(i) for d in data)
+ if any(v in (YES | NO) for v in pat):
+ groups.setdefault(pat, []).append(i)
+ else:
+ novote.append(i)
+ if not groups: # 会派全員が表決に加わっていない
+ out_cols.append((s, idx))
+ continue
+ order = sorted(groups.values(), key=lambda g: g[0])
+ order[0] = order[0] + novote
+ if len(order) == 1:
if n == 1 and idx:
out_cols.append((f"{s} {mnames[idx[0]]}", idx))
else:
out_cols.append((s, idx))
- else:
- for i in idx:
- out_cols.append((f"{mnames[i]}({s})", [i]))
+ continue
+ for g in order:
+ if len(g) == 1:
+ out_cols.append((f"{mnames[g[0]]}({s})", g))
+ else:
+ out_cols.append((f"{s}({len(g)}人)", g))
print(f"\n### {label}\n")
print("| 議案 | 議決結果 | " + " | ".join(h for h, _ in out_cols) + " |")