quatuorbellefeuille.com

Content, build scripts and admin scripts for the Bellefeuille Quartet website.
git clone https://git.kevinlegouguec.net/quatuorbellefeuille.com
Log | Files | Refs

commit 5876793d01ab2e392e93eec9323dd6a7edb53170
parent 836aaf1fdfa5a60d261ed6e06e880d08b1b68bd0
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Mon, 21 Feb 2022 19:57:49 +0100

Extract more stuff out of build-concerts.py

Diffstat:
Mbuild-concerts.py | 22+++++++---------------
Mhelpers.py | 14++++++++++++++
2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/build-concerts.py b/build-concerts.py @@ -5,7 +5,13 @@ from pathlib import Path import re from sys import argv -from helpers import guess_language, read_concerts, relative_path, tmplocale +from helpers import ( + guess_language, + read_concerts, + relative_path, + tmplocale, + touchup_plaintext, +) # TODO: change some jargon: @@ -162,20 +168,6 @@ def break_lines(lines): return tuple(line+'<br>' for line in lines[:-1]) + (lines[-1],) -TOUCHUPS = ( - (re.compile('([0-9])(st|nd|rd|th|er|ère|nde|ème)'), r'\1<sup>\2</sup>'), - (re.compile('(https://[^ ]+)'), r'<a href="\1" target="_blank">\1</a>'), - (re.compile('([^ ]+@[^ ]+)'), r'<a href="mailto:\1">\1</a>'), -) - - -def touchup_plaintext(plaintext): - text = plaintext - for regexp, repl in TOUCHUPS: - text = regexp.sub(repl, text) - return text - - def print_concert_details(concert, lang): concert_id = f'concert-{concert.time.strftime("%F")}' classes = ('details',) diff --git a/helpers.py b/helpers.py @@ -131,3 +131,17 @@ def read_concerts(filename): for match in re.finditer(_CONCERT_RE, f.read()) ) return tuple(sorted(concerts, key=attrgetter('time'))) + + +_TOUCHUPS = ( + (re.compile('([0-9])(st|nd|rd|th|er|ère|nde|ème)'), r'\1<sup>\2</sup>'), + (re.compile('(https://[^ ]+)'), r'<a href="\1" target="_blank">\1</a>'), + (re.compile('([^ ]+@[^ ]+)'), r'<a href="mailto:\1">\1</a>'), +) + + +def touchup_plaintext(plaintext): + text = plaintext + for regexp, repl in _TOUCHUPS: + text = regexp.sub(repl, text) + return text