38 lines
994 B
Makefile
38 lines
994 B
Makefile
# Local Variables:
|
|
# mode: makefile
|
|
# End:
|
|
set shell := ["bash", "-uc"]
|
|
|
|
outdir := "out"
|
|
report_out_path := outdir / "report.pdf"
|
|
summary_out_path := outdir / "summary.pdf"
|
|
|
|
default: all
|
|
|
|
_setup:
|
|
mkdir -p {{outdir}}
|
|
|
|
check-links document:
|
|
#!/usr/bin/env python3
|
|
import re
|
|
import requests
|
|
import sys
|
|
print("Checking links in {{document}}...")
|
|
with open("{{document}}", "rb") as f:
|
|
r = rb"</Type/Action/S/URI/URI\((.*?)\)"
|
|
matches = set(re.findall(r, f.read(), re.S))
|
|
print(f"Found {len(matches)} links")
|
|
for url in matches:
|
|
print(f"Testing {url.decode('utf-8')}")
|
|
res = requests.head(url, headers={"User-Agent": "BrokenURLChecker 1.0"})
|
|
if not (200 <= res.status_code <= 399):
|
|
print(f"{url} is broken: {res.status_code} {res.reason}")
|
|
sys.exit(1)
|
|
|
|
report: _setup
|
|
typst c --root . report/bachelor_thesis.typ {{report_out_path}}
|
|
|
|
summary: _setup
|
|
typst c --root . summary/exec_summary.typ {{summary_out_path}}
|
|
|
|
all: report summary |