From: Philipp Spitzer Date: Sun, 23 Jan 2022 16:09:36 +0000 (+0100) Subject: Parse cachet. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/379c1ee4942020b8db1a501765256ac149bd1c31 Parse cachet. --- diff --git a/bots/sledrun_wikitext_to_json.py b/bots/sledrun_wikitext_to_json.py index 718b275..1107048 100644 --- a/bots/sledrun_wikitext_to_json.py +++ b/bots/sledrun_wikitext_to_json.py @@ -196,6 +196,12 @@ class SledrunWikiTextToJsonBot( sledrun_json['sled_rental'] = w _sled_rental() + def _cachet(): + v = rbb['Gütesiegel'] + if v is not None: + sledrun_json['cachet'] = len(v) > 0 + _cachet() + v = rbb['In Übersichtskarte'] if v is not None: sledrun_json['show_in_overview'] = v diff --git a/wrpylib/wrmwmarkup.py b/wrpylib/wrmwmarkup.py index 90f52ca..9426e98 100644 --- a/wrpylib/wrmwmarkup.py +++ b/wrpylib/wrmwmarkup.py @@ -437,6 +437,13 @@ def create_sledrun_wiki(sledrun_json: Dict, map_json: Optional[Dict], impression w.append((n, c)) return w + def cachet() -> Optional[List]: + v = sledrun_json.get('cachet') + if v is not None: + if not v: + return [] + return None + def webauskunft() -> Tuple[Optional[bool], Optional[str]]: info_web = sledrun_json.get('info_web') if info_web is None: @@ -477,7 +484,7 @@ def create_sledrun_wiki(sledrun_json: Dict, map_json: Optional[Dict], impression ('Beleuchtungsanlage', opt_tristate_german_comment_from_str(sledrun_json.get('nightlight_possible', ''))), ('Beleuchtungstage', nightlightdays_from_str(sledrun_json.get('nightlight_weekdays', ''))), ('Rodelverleih', rodelverleih()), - ('Gütesiegel', None), + ('Gütesiegel', cachet()), ('Webauskunft', webauskunft()), ('Telefonauskunft', telefonauskunft()), ('Bild', sledrun_json.get('image')), diff --git a/wrpylib/wrvalidators.py b/wrpylib/wrvalidators.py index 61b1415..3b0ae5f 100644 --- a/wrpylib/wrvalidators.py +++ b/wrpylib/wrvalidators.py @@ -694,7 +694,7 @@ def single_cachet_german_to_str(value: Tuple[str, str, str]) -> str: return ' '.join(value) -def cachet_german_from_str(value): +def cachet_german_from_str(value) -> Optional[List[Tuple[str, str, str]]]: """Converts a "Gütesiegel": '' => None 'Nein' => []