]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/commitdiff
Make use of new function vao_ext_id_to_ifopt_stop_id().
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 18 Jul 2023 19:38:18 +0000 (21:38 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 18 Jul 2023 19:38:18 +0000 (21:38 +0200)
scripts/update_public_transport_bus_stops.py

index a40aa60bd4c734faebe493b40c46439c9cfd992d..147ecd2e517e11ab5c5959f7a139e4e1d67df6c7 100644 (file)
@@ -13,6 +13,7 @@ from termcolor import cprint  # python3-termcolor
 
 from wrpylib.cli_tools import unified_diff, input_yes_no_quit, Choice
 from wrpylib.json_tools import order_json_keys, format_json
 
 from wrpylib.cli_tools import unified_diff, input_yes_no_quit, Choice
 from wrpylib.json_tools import order_json_keys, format_json
+from wrpylib.lib_update_public_transport import vao_ext_id_to_ifopt_stop_id
 from wrpylib.mwapi import WikiSite, page_json
 from wrpylib.sledrun_json import Sledrun, Position, PublicTransportStop
 
 from wrpylib.mwapi import WikiSite, page_json
 from wrpylib.sledrun_json import Sledrun, Position, PublicTransportStop
 
@@ -37,9 +38,8 @@ def update_sledrun(site: WikiSite, bus_stop_geojson: GeoJSON, title: str):
             pt_stop['ifopt_stop_id'] = f'at:47:{pt_stop["vvt_stop_id"]}'
             continue
         if 'vao_ext_id' in pt_stop:  # e.g. '476164600' -> "at:47:61646"
             pt_stop['ifopt_stop_id'] = f'at:47:{pt_stop["vvt_stop_id"]}'
             continue
         if 'vao_ext_id' in pt_stop:  # e.g. '476164600' -> "at:47:61646"
-            if match := re.match(r'(47)(\d{5})00', pt_stop['vao_ext_id']):
-                g1, g2 = match.groups()
-                pt_stop['ifopt_stop_id'] = f"at:{g1}:{g2}"
+            if ifopt_stop_id := vao_ext_id_to_ifopt_stop_id(pt_stop['vao_ext_id']):
+                pt_stop['ifopt_stop_id'] = ifopt_stop_id
                 continue
         if monitor_template := pt_stop.get('monitor_template'):
             if monitor_template.get('name') == "Fahrplan Abfahrtsmonitor VVT":
                 continue
         if monitor_template := pt_stop.get('monitor_template'):
             if monitor_template.get('name') == "Fahrplan Abfahrtsmonitor VVT":