From 8dfd752666c2ab1d87523e9e1caf25b0413d65a7 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Mon, 10 Aug 2020 19:01:21 +0200 Subject: Correctly pick colour for the badge --- scripts/statistics.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scripts/statistics.py') diff --git a/scripts/statistics.py b/scripts/statistics.py index 927baba..9ec460d 100644 --- a/scripts/statistics.py +++ b/scripts/statistics.py @@ -20,11 +20,19 @@ def collect(d): return (n_admitted, n_theorems, n_qed) +def pick_colour(n, m): + if n > 0.2 * m: return "red" + elif n > 0.1 * m: return "orange" + elif n == 0: return "brightgreen" + else: return "yellow" + + def main(d): - n_admitted, _, _ = collect(d) + n_admitted, n_theorems, _ = collect(d) + colour = pick_colour(n_admitted, n_theorems) url = "https://img.shields.io/badge/Admitted%20Proofs-{}-{}?style=flat".format( - str(n_admitted), "orange") + str(n_admitted), colour) req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) with open("admitted.svg", "wb") as f: -- cgit