#!/usr/bin/env python3 """Usage: tools/review-rounds ... Lists per PR created since (ISO date or time) the review rounds of werkrevisor, their verdicts, the line comments of the bot and the findings that stood only in the result comment, to see whether a change of the review costs or saves rounds. Needs GITEA_TOKEN with read access in the environment; it never prints the token. Example: GITEA_TOKEN=… tools/review-rounds https://git.example.org mi 2026-10-09T20:00 werkrevisor werkator """ import json import os import re import sys import urllib.request def main(argv): if len(argv) < 4 or argv[0] in ("-h", "--help"): print(__doc__.strip()) return 0 base, owner, since, repos = argv[0].rstrip("/"), argv[1], argv[2], argv[3:] headers = {"Authorization": "token " + os.environ["GITEA_TOKEN"]} def get(path): request = urllib.request.Request(f"{base}/api/v1/repos/{owner}/{path}", headers=headers) with urllib.request.urlopen(request, timeout=60) as response: return json.load(response) def pulls(repo): page = 1 while True: batch = get(f"{repo}/pulls?state=all&limit=50&page={page}") if not batch: return yield from batch page += 1 for repo in repos: for pr in pulls(repo): if pr["created_at"] < since: continue results = [c["body"] for c in get(f"{repo}/issues/{pr['number']}/comments") if "