From 3bc002e5c87f1042791c4ec67ce7ae6ab3878bce Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 22 Feb 2022 12:51:48 +0100 Subject: [wip] Add CDATA (cont'd and over) Now we just need to add the publication date. --- build-feed.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'build-feed.py') diff --git a/build-feed.py b/build-feed.py index a6b0890..e200920 100755 --- a/build-feed.py +++ b/build-feed.py @@ -38,6 +38,19 @@ LOCALIZED_FORMATS = { } +def join(sequence, joiner_factory): + # There's got to be a standard itertools/functools thingy to do that… + result = [] + + for i, item in enumerate(sequence, start=1): + result.append(item) + + if i == len(sequence): + return result + + result.append(joiner_factory()) + + def cdata_concert(concert, lang): formatters = DATE_FORMATTERS[lang] @@ -49,8 +62,7 @@ def cdata_concert(concert, lang): blocks.extend(( E.p(formatters['date'](concert.time)), E.p(formatters['time'](concert.time)), - # TODO: NEED TO USE FUNC/ITERTOOLS SHENANIGANS TO WEAVE E.br INTO THIS - E.p(concert.address.replace('\n', '
')), + E.p(*join(concert.address.splitlines(), E.br)), E.ol( *(E.li(touchup_plaintext(p)) for p in concert.pieces.splitlines()) ), -- cgit v1.2.3