From d148eeb4a46cb647d13d451cb01cdc66835d2b03 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 10 Mar 2021 23:28:39 +0100 Subject: Add links from/to English pages --- build-programs.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'build-programs.py') diff --git a/build-programs.py b/build-programs.py index 69c7057..40398d8 100755 --- a/build-programs.py +++ b/build-programs.py @@ -1,8 +1,11 @@ #!/usr/bin/env python3 import html +from os import path +from pathlib import Path import re from subprocess import run +from sys import argv PROGRAM_RE = re.compile('\n'.join(( @@ -24,8 +27,8 @@ BLOCK_TEMPLATE = '''\
{name}
{composers}
- - + +
{description}
    @@ -53,10 +56,17 @@ def print_program(info): print(BLOCK_TEMPLATE.format_map(info)) -def main(): - for p in read_programs('programs.in'): - print_program(p.groupdict()) +def main(programs_src): + # pathlib.Path(x).relative_to(y) cannot handle y not being under x, + # os.path.relpath('x') yields '' rather than '.'. + # 😮‍💨 + imgdir = path.relpath('images', Path(programs_src).parent) + + for p in read_programs(programs_src): + info = p.groupdict() + info['imgdir'] = imgdir + print_program(info) if __name__ == '__main__': - main() + main(argv[1]) -- cgit v1.2.3