if v is not None:
sledrun_json['public_transport'] = public_transport_german_to_str(v)
- for v in wikicode.get_sections(levels=[2], matches='Anreise mit öffentlichen Verkehrsmitteln',
- include_headings=False):
- w = next((w for w in v.nodes if isinstance(w, Tag) and w.wiki_markup == '*'), None)
- if w is not None:
- x = str(Wikicode(v.nodes[:v.nodes.index(w)])).strip()
- if x:
- sledrun_json["public_transport_description"] = str(x)
-
- public_transport_stops = []
- public_transport_lines = []
- ya = None
- for w in v.nodes:
- if isinstance(w, Template):
- if w.name == 'Haltestelle':
- if ya is not None:
- public_transport_stops.append(ya)
- ya = {}
- z = w.get(1, None)
- if z is not None:
- ya['municipality'] = str(z)
- z = w.get(2, None)
- if z is not None:
- ya['name_local'] = str(z)
- za = str_or_none(w.get(3, None))
- zb = str_or_none(w.get(4, None))
- z = lonlat_ele_to_json(opt_lonlat_from_str(za), opt_uint_from_str(zb))
- if len(z) > 0:
- ya['position'] = z
- elif w.name in ["Fahrplan Abfahrtsmonitor VVT"]:
- ya['monitor_template'] = template_to_json(w)
- elif w.name in ["Fahrplan Hinfahrt VVT"]:
- ya['route_arrival_template'] = template_to_json(w)
- elif w.name in ["Fahrplan Rückfahrt VVT"]:
- ya['route_departure_template'] = template_to_json(w)
- elif w.name in ["Fahrplan Linie VVT"]:
- if ya is not None:
- public_transport_stops.append(ya)
- ya = None
- y = {
- 'timetable_template': template_to_json(w),
- }
- public_transport_lines.append(y)
- if ya is not None:
- public_transport_stops.append(ya)
- if len(public_transport_stops) > 0:
- sledrun_json['public_transport_stops'] = public_transport_stops
- if len(public_transport_lines) > 0:
- sledrun_json['public_transport_lines'] = public_transport_lines
- break
-
- for v in wikicode.get_sections(levels=[2], matches='Anreise mit dem Auto'):
- for w in v.ifilter_text(recursive=False):
- x = w.strip()
- if x:
- sledrun_json["car_description"] = str(x)
- break
- x = []
- for w in v.ifilter_templates(matches='Parkplatz'):
- za = str_or_none(w.get(1, None))
- zb = str_or_none(w.get(2, None))
- z = lonlat_ele_to_json(opt_lonlat_from_str(za), opt_uint_from_str(zb))
- if len(z) > 0:
- x.append({'position': z})
- if len(x) > 0:
- sledrun_json['car_parking'] = x
-
- x = []
- for w in io.StringIO(str(v)):
- match = re.match(r"\*\* von \'\'\'(.+)\'\'\'(.*): ([\d.,]+) km", w.rstrip())
- if match:
- ya, yb, yc = match.groups()
-
- yc = float(yc.replace(',', '.'))
- x.append({
- 'km': yc,
- 'route': (ya.strip() + ' ' + yb.strip()).strip(),
- })
- if len(x) > 0:
- sledrun_json['car_distances'] = x
+ for v in wikicode.get_sections(levels=[2], matches='Anreise mit öffentlichen Verkehrsmitteln',
+ include_headings=False):
+ w = next((w for w in v.nodes if isinstance(w, Tag) and w.wiki_markup == '*'), None)
+ if w is not None:
+ x = str(Wikicode(v.nodes[:v.nodes.index(w)])).strip()
+ if x:
+ sledrun_json["public_transport_description"] = str(x)
+
+ public_transport_stops = []
+ public_transport_lines = []
+ ya = None
+ for w in v.nodes:
+ if isinstance(w, Template):
+ if w.name == 'Haltestelle':
+ if ya is not None:
+ public_transport_stops.append(ya)
+ ya = {}
+ z = w.get(1, None)
+ if z is not None:
+ ya['municipality'] = str(z)
+ z = w.get(2, None)
+ if z is not None:
+ ya['name_local'] = str(z)
+ za = str_or_none(w.get(3, None))
+ zb = str_or_none(w.get(4, None))
+ z = lonlat_ele_to_json(opt_lonlat_from_str(za), opt_uint_from_str(zb))
+ if len(z) > 0:
+ ya['position'] = z
+ elif w.name in ["Fahrplan Abfahrtsmonitor VVT"]:
+ ya['monitor_template'] = template_to_json(w)
+ elif w.name in ["Fahrplan Hinfahrt VVT"]:
+ ya['route_arrival_template'] = template_to_json(w)
+ elif w.name in ["Fahrplan Rückfahrt VVT"]:
+ ya['route_departure_template'] = template_to_json(w)
+ elif w.name in ["Fahrplan Linie VVT"]:
+ if ya is not None:
+ public_transport_stops.append(ya)
+ ya = None
+ y = {
+ 'timetable_template': template_to_json(w),
+ }
+ public_transport_lines.append(y)
+ if ya is not None:
+ public_transport_stops.append(ya)
+ if len(public_transport_stops) > 0:
+ sledrun_json['public_transport_stops'] = public_transport_stops
+ if len(public_transport_lines) > 0:
+ sledrun_json['public_transport_lines'] = public_transport_lines
+ break
+
+ for v in wikicode.get_sections(levels=[2], matches='Anreise mit dem Auto'):
+ for w in v.ifilter_text(recursive=False):
+ x = w.strip()
+ if x:
+ sledrun_json["car_description"] = str(x)
+ break
+ x = []
+ for w in v.ifilter_templates(matches='Parkplatz'):
+ za = str_or_none(w.get(1, None))
+ zb = str_or_none(w.get(2, None))
+ z = lonlat_ele_to_json(opt_lonlat_from_str(za), opt_uint_from_str(zb))
+ if len(z) > 0:
+ x.append({'position': z})
+ if len(x) > 0:
+ sledrun_json['car_parking'] = x
+
+ x = []
+ for w in io.StringIO(str(v)):
+ match = re.match(r"\*\* von \'\'\'(.+)\'\'\'(.*): ([\d.,]+) km", w.rstrip())
+ if match:
+ ya, yb, yc = match.groups()
+
+ yc = float(yc.replace(',', '.'))
+ x.append({
+ 'km': yc,
+ 'route': (ya.strip() + ' ' + yb.strip()).strip(),
+ })
+ if len(x) > 0:
+ sledrun_json['car_distances'] = x
x = []
for v in wikicode.get_sections(levels=[2], matches='Allgemeines'):