]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/commitdiff
Take field "nightlight_weekdays" into account.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 12 Jul 2022 21:29:37 +0000 (23:29 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 12 Jul 2022 21:29:37 +0000 (23:29 +0200)
wrpylib/wrmwmarkup.py

index 49fb7971fe1320b91fa5d6d828303d3349b8ca06..3448bcf9ada016df9d31b35f50b751cf3963b71b 100644 (file)
@@ -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()),