Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-03 07:47:22

0001 #!/usr/bin/env python3
0002 # -*- coding: utf-8 -*-
0003 
0004 import argparse
0005 import re
0006 import os
0007 import csv
0008 
0009 HERALD_URL = "https://acts-herald.app.cern.ch/view/{repo}/runs/{run_id}/artifacts/{artifact_name}/{path}"
0010 IS_CI = "GITHUB_ACTIONS" in os.environ
0011 
0012 
0013 parser = argparse.ArgumentParser()
0014 parser.add_argument("results")
0015 parser.add_argument("--html")
0016 parser.add_argument("--md")
0017 args = parser.parse_args()
0018 
0019 re_title = re.compile(r'<p class="title">\s*(.*)\s*<\/p>', re.RegexFlag.MULTILINE)
0020 re_check = re.compile(r'<a.*title="(.*)">\s*(.)\s*<\/a>', re.RegexFlag.MULTILINE)
0021 
0022 summary = []
0023 
0024 with open(args.results) as f:
0025     reader = csv.reader(f)
0026     for title, html_path, ec in reader:
0027         summary.append(
0028             {
0029                 "title": title,
0030                 "total": ec == "0",
0031                 "path": html_path,
0032             }
0033         )
0034 
0035 if args.html:
0036     with open(args.html, mode="w", encoding="utf-8") as f:
0037         f.write("""<!DOCTYPE html>
0038 <html>
0039 <head>
0040   <title>physmon summary</title>
0041   <meta charset="UTF-8">
0042 </head>
0043 <body>
0044   <h1>physmon summary</h1>
0045   <ul>
0046             """)
0047 
0048         for s in summary:
0049             if s["title"].startswith("Comparison"):
0050                 f.write(f"""
0051         <li>🔵 <a href="{s["path"]}">{s["title"]}</a></li>""")
0052             else:
0053                 f.write(
0054                     f"""
0055         <li>{"✅" if s["total"] else "🔴"} <a href="{s["path"]}">{s["title"]}</a></li>"""
0056                 )
0057 
0058         f.write("""
0059       </ul>
0060     </body>
0061     </html>
0062             """)
0063 
0064 if args.md:
0065     with open(args.md, mode="w", encoding="utf-8") as f:
0066         f.write("# physmon summary\n")
0067         for s in summary:
0068             if IS_CI:
0069                 url = HERALD_URL.format(
0070                     repo=os.environ["GITHUB_REPOSITORY"],
0071                     run_id=os.environ["GITHUB_RUN_ID"],
0072                     artifact_name="physmon",
0073                     path=s["path"],
0074                 )
0075             else:
0076                 url = s["path"]
0077 
0078             if s["title"].startswith("Comparison"):
0079                 f.write(f"  - 🔵️ [{s['title']}]({url})\n")
0080             else:
0081                 f.write(f"  - {'✅' if s['total'] else '🔴'} [{s['title']}]({url})\n")