From: Philipp Spitzer Date: Mon, 29 Nov 2021 22:12:02 +0000 (+0100) Subject: Further work on parsing (now a map is parsed). X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/7eb6337cb3f01ca598a74afc66430f0b84b1b7b6 Further work on parsing (now a map is parsed). --- diff --git a/bots/sledrun_wikitext_to_json.py b/bots/sledrun_wikitext_to_json.py index 686a196..c770e92 100644 --- a/bots/sledrun_wikitext_to_json.py +++ b/bots/sledrun_wikitext_to_json.py @@ -24,9 +24,9 @@ from pywikibot.bot import ( from pywikibot.logging import warning from pywikibot.site._namespace import BuiltinNamespace -from wrpylib.wrmwmarkup import create_sledrun_wiki, lonlat_to_json, lonlat_ele_to_json +from wrpylib.wrmwmarkup import create_sledrun_wiki, lonlat_to_json, lonlat_ele_to_json, parse_wrmap from wrpylib.wrvalidators import rodelbahnbox_from_template, tristate_german_to_str, difficulty_german_to_str, \ - avalanches_german_to_str, public_transport_german_to_str + avalanches_german_to_str, public_transport_german_to_str, opt_str_opt_comment_enum_to_str from pywikibot.site import Namespace @@ -65,6 +65,11 @@ class SledrunWikiTextToJsonBot( warning(f"{map_json_page.title()} already exists, skipping {self.current_page.title()}.") return + map_json = None + v = wikicode.filter_tags(matches='wrmap') + if len(v) > 0: + map_json = parse_wrmap(str(v[0])) + sledrun_json = { "name": self.current_page.title(), "aliases": [], @@ -72,7 +77,6 @@ class SledrunWikiTextToJsonBot( "description": "Holadrio!", } - map_json = None rbb_list = wikicode.filter_templates(recursive=False, matches=lambda t: t.name.strip() == 'Rodelbahnbox') if len(rbb_list) == 1: @@ -122,6 +126,11 @@ class SledrunWikiTextToJsonBot( if w is not None: sledrun_json['nightlight_description'] = w + v = rbb['Rodelverleih'] + if v is not None: + sledrun_json['sled_rental_direct'] = v != [] + sledrun_json['sled_rental_description'] = opt_str_opt_comment_enum_to_str(v) + v = rbb['In Übersichtskarte'] if v is not None: sledrun_json['show_in_overview'] = v @@ -142,6 +151,10 @@ class SledrunWikiTextToJsonBot( if v != {}: sledrun_json['bottom'] = v + v = rbb['Telefonauskunft'] + if v is not None: + sledrun_json['info_phone'] = [{'phone': p, 'name': n} for p, n in v] + v = rbb['Öffentliche Anreise'] if v is not None: sledrun_json['public_transport'] = public_transport_german_to_str(v)