From 8e0838b04a76f64342b570e22a1c0447c85ecd64 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 13 Aug 2020 16:40:48 +0100 Subject: Add statistics to be tracked --- scripts/statistics.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/statistics.py b/scripts/statistics.py index f3db9ff..7ff89ac 100644 --- a/scripts/statistics.py +++ b/scripts/statistics.py @@ -1,6 +1,8 @@ -import urllib.request +import datetime +import re import subprocess import sys +import urllib.request def collect(d): @@ -17,7 +19,17 @@ def collect(d): ["grep", "-r", "-E", "Qed|Defined", d]).splitlines()) except: n_qed = 0 - return (n_admitted, n_theorems, n_qed) + try: n_files = len(subprocess.check_output(["find", d, "-name", "*.v"]).splitlines()) + except: n_files = 0 + + try: + ps = subprocess.Popen(["find", d, "-name", "*.v"], stdout=subprocess.PIPE) + output = subprocess.check_output(["xargs", "wc"], stdin=ps.stdout).decode("utf-8").splitlines()[-1] + ps.wait() + n_lines = int(re.match("\s*(\d+)", output).group().strip()) + except: n_lines = 0 + + return (n_files, n_lines, n_admitted, n_theorems, n_qed) def pick_colour(n, m): @@ -28,7 +40,7 @@ def pick_colour(n, m): def main(d): - n_admitted, n_theorems, _ = collect(d) + n_files, n_lines, n_admitted, n_theorems, n_qed = collect(d) colour = pick_colour(n_admitted, n_theorems) url = "https://img.shields.io/badge/admitted%20proofs-{}-{}?style=flat".format( @@ -39,6 +51,11 @@ def main(d): with urllib.request.urlopen(req) as r: f.write(r.read()) + with open(str(datetime.datetime.now()).replace(" ", "_")+".csv", "w") as f: + f.write("n_files,n_lines,n_admitted,n_theorems,n_qed\n" + +str(n_files)+","+str(n_lines)+"," + +str(n_admitted)+","+str(n_theorems)+","+str(n_qed)+"\n") + if __name__ == "__main__": main(sys.argv[1]) -- cgit