diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/parse-sanpi-hyo.py | 38 |
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) + " |") |
