From 214f6aa6553ecdfa11d2ec63bb1cef1a49e8538d Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sun, 31 Oct 2021 23:35:35 +0100 Subject: Add simplified concerts syntax --- build-programs.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'build-programs.py') 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[^\n]+)', @@ -15,7 +15,7 @@ PROGRAM_RE = re.compile('\n'.join(( 'DESCRIPTION :', '(?P.+?)', 'MORCEAUX :', - r'(?P(?:- [^\n]+\n)*- [^\n]+)' + r'(?P(?:[^\n]+\n)*[^\n]+)' )), flags=re.DOTALL) def read_programs(programs): @@ -55,20 +55,13 @@ def print_program(info): '

(.+)

', 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() -- cgit v1.2.3