summaryrefslogtreecommitdiff
path: root/build-programs.py
diff options
context:
space:
mode:
Diffstat (limited to 'build-programs.py')
-rwxr-xr-xbuild-programs.py17
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()