Files
Programming-Contests/tests/make_report.py
T
2026-10-15 20:44:05 -03:00

32 lines
1.8 KiB
Python
Executable File

#!/usr/bin/env python3
# Builds test_report/index.html from the screenshots and test_report/captions.txt
# (one line per screenshot: NAME | caption), plus test_report/feature_check.txt.
import html, os
os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'test_report'))
captions = {}
if os.path.exists('captions.txt'):
for line in open('captions.txt'):
if '|' in line:
name, text = line.split('|', 1)
captions[name.strip()] = text.strip()
names = sorted(f[:-4] for f in os.listdir('.') if f.endswith('.png'))
order = [n for n in captions if n in names] + [n for n in names if n not in captions]
out = ['<!DOCTYPE html><html><head><meta charset="utf-8"><title>ACPC 2026 image, test report</title>',
'<style>body{font-family:sans-serif;max-width:1300px;margin:auto;padding:20px}'
'img{max-width:100%;border:1px solid #999}figure{margin:0 0 40px 0}'
'figcaption{font-size:1.1em;margin:6px 0}pre{background:#f4f4f4;padding:12px}</style></head><body>',
'<h1>ACPC 2026 contest image: test report</h1>']
if os.path.exists('intro.txt'):
out.append('<p>%s</p>' % html.escape(open('intro.txt').read().strip()))
if os.path.exists('technotes_check.txt'):
out.append('<h2>Technical notes checklist</h2><pre>%s</pre>' % html.escape(open('technotes_check.txt').read()))
if os.path.exists('feature_check.txt'):
out.append('<h2>Feature checklist</h2><pre>%s</pre>' % html.escape(open('feature_check.txt').read()))
out.append('<h2>Screens</h2>')
for n in order:
out.append('<figure><figcaption><b>%s</b> %s</figcaption><img src="%s.png"></figure>'
% (html.escape(n), html.escape(captions.get(n, '')), n))
out.append('</body></html>')
open('index.html', 'w').write('\n'.join(out))
print('test_report/index.html:', len(order), 'screens')