From: Philipp Spitzer Date: Tue, 15 Mar 2022 22:52:28 +0000 (+0100) Subject: Better parsing and displaying of gastronomy. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/7bc54aedb6dc1dff61cde0f7bede6b5445e24cd3 Better parsing and displaying of gastronomy. --- diff --git a/bots/sledrun_wikitext_to_json.py b/bots/sledrun_wikitext_to_json.py index 3906296..0ba0e1e 100644 --- a/bots/sledrun_wikitext_to_json.py +++ b/bots/sledrun_wikitext_to_json.py @@ -359,11 +359,17 @@ class SledrunWikiTextToJsonBot( g['weblink'] = external_link_to_json(ext_link) remaining = str(Wikicode(n for n in wiki.nodes if isinstance(n, (Text, Tag)) and str(n).strip() != '*')).strip() - match = re.match(r'\((.+)\)', remaining) + match = re.match(r'(.*)\((.+)\)', remaining) if match: - remaining = match.group(1) - if len(remaining) > 0: - g['note'] = remaining + name, note = match.group(1) + name = name.strip() + note = note.strip() + if len(name) > 0: + g['name'] = name + if len(note) > 0: + g['note'] = note + elif len(remaining) > 0: + g['name'] = remaining gastronomy.append(g) else: break diff --git a/wrpylib/templates/sledrun_wikitext.txt b/wrpylib/templates/sledrun_wikitext.txt index bab2b76..ceb7fd1 100644 --- a/wrpylib/templates/sledrun_wikitext.txt +++ b/wrpylib/templates/sledrun_wikitext.txt @@ -27,7 +27,8 @@ * '''Betreiber''': {{ operator }} * '''Hütten''': {%- for info in gastronomy %} -** {% if info.wr_page %}{{ wr_page(info.wr_page) }}{% endif %} +** {{ info.name }} + {%- if info.wr_page %}{{ wr_page(info.wr_page) }}{% endif %} {%- if info.weblink %}{{ weblink(info.weblink) }}{% endif %} {%- if info.note %} ({{ info.note }}){% endif %} {%- endfor %}