summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2022-02-21 19:57:49 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2022-02-21 19:57:49 +0100
commit5876793d01ab2e392e93eec9323dd6a7edb53170 (patch)
tree9bb1ca9ee8460a9257b5d6e0617606b2f4d34ce5
parent836aaf1fdfa5a60d261ed6e06e880d08b1b68bd0 (diff)
downloadquatuorbellefeuille.com-5876793d01ab2e392e93eec9323dd6a7edb53170.tar.xz
Extract more stuff out of build-concerts.py
-rwxr-xr-xbuild-concerts.py22
-rw-r--r--helpers.py14
2 files changed, 21 insertions, 15 deletions
diff --git a/build-concerts.py b/build-concerts.py
index d1a7c11..0e5a70b 100755
--- 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
index 87ed9c1..a746ea2 100644
--- 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