From: Philipp Spitzer Date: Tue, 12 Jul 2022 21:29:37 +0000 (+0200) Subject: Take field "nightlight_weekdays" into account. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/52cc3f7fa081635d9d70dc39620a3e06f8812a3f Take field "nightlight_weekdays" into account. --- diff --git a/wrpylib/wrmwmarkup.py b/wrpylib/wrmwmarkup.py index 49fb797..3448bcf 100644 --- a/wrpylib/wrmwmarkup.py +++ b/wrpylib/wrmwmarkup.py @@ -428,6 +428,18 @@ def create_sledrun_wiki(sledrun_json: Dict, map_json: Optional[Dict], impression return None return [(w['type'], w.get('note')) for w in ws] + def beleuchtungstage(sledrun_json: Dict) -> Tuple[Optional[int], Optional[str]]: + weekdays_count = sledrun_json.get('nightlight_weekdays_count') + note = sledrun_json.get('nightlight_weekdays_note') + weekdays = sledrun_json.get('nightlight_weekdays') + if weekdays is not None: + assert isinstance(weekdays, list) + if weekdays_count is None: + weekdays_count = len(weekdays) + if note is None: + note = ', '.join(w[:2] for w in weekdays) + return weekdays_count, note + def rodelverleih() -> Optional[List[Tuple[str, Optional[str]]]]: v = sledrun_json.get('sled_rental') if v is None: @@ -495,8 +507,7 @@ def create_sledrun_wiki(sledrun_json: Dict, map_json: Optional[Dict], impression ('Aufstiegshilfe', aufstiegshilfe()), ('Beleuchtungsanlage', (opt_tristate_german_from_str(sledrun_json.get('nightlight_possible', '')), sledrun_json.get('nightlight_possible_note'))), - ('Beleuchtungstage', (sledrun_json.get('nightlight_weekdays_count'), - sledrun_json.get('nightlight_weekdays_note'))), + ('Beleuchtungstage', beleuchtungstage(sledrun_json)), ('Rodelverleih', rodelverleih()), ('Gütesiegel', cachet()), ('Webauskunft', webauskunft()),