diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2021-03-10 23:28:39 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2021-03-10 23:28:39 +0100 |
| commit | d148eeb4a46cb647d13d451cb01cdc66835d2b03 (patch) | |
| tree | 7d25301eee1714e71570225abee033a5ec81cc0d /build-programs.py | |
| parent | 9f74233ffedb0609d43d54b6169dc47dd6337803 (diff) | |
| download | quatuorbellefeuille.com-d148eeb4a46cb647d13d451cb01cdc66835d2b03.tar.xz | |
Add links from/to English pages
Diffstat (limited to 'build-programs.py')
| -rwxr-xr-x | build-programs.py | 22 |
1 files changed, 16 insertions, 6 deletions
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 = '''\ <summary> <div class="name">{name}</div> <div class="composers">{composers}</div> - <img class="button open" src="images/chevron-down.svg"> - <img class="button close" src="images/chevron-up.svg"> + <img class="button open" src="{imgdir}/chevron-down.svg"> + <img class="button close" src="{imgdir}/chevron-up.svg"> </summary> {description} <ol class="pieces"> @@ -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]) |
