]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/commitdiff
Now using comment for nightlight_possible.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Sun, 13 Mar 2022 16:27:25 +0000 (17:27 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Sun, 13 Mar 2022 16:27:25 +0000 (17:27 +0100)
bots/sledrun_wikitext_to_json.py
wrpylib/wrmwmarkup.py

index 3201097206a72cfda4422faa077cbef57cf1611b..d52abd741ac7c1113b74ccdcb31bbe060954f8a5 100644 (file)
@@ -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)
index 8fc36472dbd3ef3e66b078d622b667bab43e2cfc..7d53a3c63e8cbc9dbcc1eef5eed4c7801d8dd929 100644 (file)
@@ -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()),