diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2021-10-31 23:35:35 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2022-02-07 00:34:51 +0100 |
| commit | 214f6aa6553ecdfa11d2ec63bb1cef1a49e8538d (patch) | |
| tree | 1d81f5b56ac8c3b52a0839b3a87f87280309e7e3 /build-programs.py | |
| parent | 7dbc6d60c4f8da78c2ed8f9e6dde694b5a9d0d3e (diff) | |
| download | quatuorbellefeuille.com-214f6aa6553ecdfa11d2ec63bb1cef1a49e8538d.tar.xz | |
Add simplified concerts syntax
Diffstat (limited to 'build-programs.py')
| -rwxr-xr-x | build-programs.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/build-programs.py b/build-programs.py index d749b80..fbf04ab 100755 --- a/build-programs.py +++ b/build-programs.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 import html -from os import path -from pathlib import Path import re from subprocess import run from sys import argv +from helpers import relative_path + PROGRAM_RE = re.compile('\n'.join(( r'NOM : (?P<name>[^\n]+)', @@ -15,7 +15,7 @@ PROGRAM_RE = re.compile('\n'.join(( 'DESCRIPTION :', '(?P<description>.+?)', 'MORCEAUX :', - r'(?P<pieces>(?:- [^\n]+\n)*- [^\n]+)' + r'(?P<pieces>(?:[^\n]+\n)*[^\n]+)' )), flags=re.DOTALL) def read_programs(programs): @@ -55,20 +55,13 @@ def print_program(info): '<p>(.+)</p>', r'\1', pandoc(info['name']) ) info['description'] = pandoc(info['description']) - - info['pieces'] = '\n'.join( - piece(p[2:]) # Assume p.startswith('- '). - for p in info['pieces'].splitlines() - ) + info['pieces'] = '\n'.join(map(piece, info['pieces'].splitlines())) print(BLOCK_TEMPLATE.format_map(info)) def main(programs_src): - # pathlib.Path(x).relative_to(y) cannot handle y not being under x, - # os.path.dirname('x') yields '' rather than '.'. - # 😮💨 - imgdir = path.relpath('images', Path(programs_src).parent) + imgdir = relative_path(to='images', ref=programs_src) for p in read_programs(programs_src): info = p.groupdict() |
