From: Philipp Spitzer Date: Sun, 13 Mar 2022 16:27:25 +0000 (+0100) Subject: Now using comment for nightlight_possible. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/ee15ca896ad5b49a1b504bbed8e72ab2e43ae3b2 Now using comment for nightlight_possible. --- diff --git a/bots/sledrun_wikitext_to_json.py b/bots/sledrun_wikitext_to_json.py index 3201097..d52abd7 100644 --- a/bots/sledrun_wikitext_to_json.py +++ b/bots/sledrun_wikitext_to_json.py @@ -34,7 +34,7 @@ from pywikibot.site._namespace import BuiltinNamespace 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, opt_str_opt_comment_enum_to_str, opt_lonlat_from_str, \ + avalanches_german_to_str, public_transport_german_to_str, opt_lonlat_from_str, \ opt_uint_from_str from pywikibot.site import Namespace @@ -175,7 +175,7 @@ class SledrunWikiTextToJsonBot( if v is not None: sledrun_json['nightlight_possible'] = tristate_german_to_str(v) if w is not None: - sledrun_json['nightlight_description'] = w + sledrun_json['nightlight_possible_comment'] = w v, w = rbb['Beleuchtungstage'] if v is not None: @@ -342,6 +342,21 @@ class SledrunWikiTextToJsonBot( x = [] for v in wikicode.get_sections(levels=[2], matches='Allgemeines'): + def _nightlight(value: str) -> Optional[str]: + line_iter = io.StringIO(value) + line = next(line_iter, None) + while line is not None and not line.startswith("* '''Beleuchtung''':"): + line = next(line_iter, None) + if line is None: + return None + line = line.replace("* '''Beleuchtung''':", "").strip() + if len(line) > 0: + return line + return None + w = _nightlight(str(v)) + if w is not None: + sledrun_json['nightlight_description'] = w + def _gastronomy(value: str): gastronomy = [] line_iter = io.StringIO(value) diff --git a/wrpylib/wrmwmarkup.py b/wrpylib/wrmwmarkup.py index 8fc3647..7d53a3c 100644 --- a/wrpylib/wrmwmarkup.py +++ b/wrpylib/wrmwmarkup.py @@ -15,9 +15,9 @@ import wrpylib.wrmwdb from wrpylib.wrvalidators import LonLat, opt_lonlat_from_str, opt_lonlat_to_str, opt_uint_from_str, opt_uint_to_str, \ opt_str_opt_comment_enum_to_str, lift_german_to_str, webauskunft_to_str, cachet_german_to_str, \ opt_phone_comment_enum_to_str, lift_german_from_str, GASTHAUSBOX_DICT, opt_difficulty_german_from_str, \ - opt_avalanches_german_from_str, nightlightdays_from_str, opt_public_transport_german_from_str, \ + opt_avalanches_german_from_str, opt_public_transport_german_from_str, \ opt_tristate_german_comment_from_str, rodelbahnbox_to_str, lonlat_to_str, opt_no_or_str_to_str, \ - opt_no_or_str_from_str + opt_no_or_str_from_str, opt_tristate_german_from_str def split_lon_lat(value: Optional[LonLat]) -> Union[LonLat, Tuple[None, None]]: @@ -481,7 +481,8 @@ def create_sledrun_wiki(sledrun_json: Dict, map_json: Optional[Dict], impression ('Aufstieg getrennt', opt_tristate_german_comment_from_str(sledrun_json.get('walkup_separate', ''))), ('Gehzeit', sledrun_json.get('walkup_time')), ('Aufstiegshilfe', aufstiegshilfe()), - ('Beleuchtungsanlage', opt_tristate_german_comment_from_str(sledrun_json.get('nightlight_possible', ''))), + ('Beleuchtungsanlage', (opt_tristate_german_from_str(sledrun_json.get('nightlight_possible', '')), + sledrun_json.get('nightlight_possible_comment'))), ('Beleuchtungstage', (sledrun_json.get('nightlight_weekdays_count'), sledrun_json.get('nightlight_weekdays_comment'))), ('Rodelverleih', rodelverleih()),