warning(f"{image_page.title()} does not exist.")
sledrun_json['image'] = v
- v = rbb['Länge']
- if v is not None:
- sledrun_json['length'] = v
+ optional_set(sledrun_json, 'length', rbb['Länge'])
v = rbb['Schwierigkeit']
if v is not None:
sledrun_json['avalanches'] = avalanches_german_to_str(v)
v, w = rbb['Betreiber']
- if v is not None:
- sledrun_json['has_operator'] = v
- if w is not None:
- sledrun_json['operator'] = w
+ optional_set(sledrun_json, 'has_operator', v)
+ optional_set(sledrun_json, 'operator', w)
- v = rbb['Aufstieg möglich']
- if v is not None:
- sledrun_json['walkup_possible'] = v
+ optional_set(sledrun_json, 'walkup_possible', rbb['Aufstieg möglich'])
v, w = rbb['Aufstieg getrennt']
if v is not None:
sledrun_json['walkup_separate'] = tristate_german_to_str(v)
- if w is not None:
- sledrun_json['walkup_comment'] = w # TODO
+ optional_set(sledrun_json, 'walkup_comment', w)
- v = rbb['Gehzeit']
- if v is not None:
- sledrun_json['walkup_time'] = v
+ optional_set(sledrun_json, 'walkup_time', rbb['Gehzeit'])
def _walkup_support():
walkup_support_rbb = rbb['Aufstiegshilfe']
walkup_supports = []
for walkup_support_type, comment in walkup_support_rbb:
walkup_support = {'type': walkup_support_type}
- if comment is not None:
- walkup_support['comment'] = comment
+ optional_set(walkup_support, 'comment', comment)
walkup_supports.append(walkup_support)
sledrun_json['walkup_supports'] = walkup_supports
_walkup_support()
v, w = rbb['Beleuchtungsanlage']
if v is not None:
sledrun_json['nightlight_possible'] = tristate_german_to_str(v)
- if w is not None:
- sledrun_json['nightlight_possible_comment'] = w
+ optional_set(sledrun_json, 'nightlight_possible_comment', w)
v, w = rbb['Beleuchtungstage']
- if v is not None:
- sledrun_json['nightlight_weekdays_count'] = v
- if w is not None:
- sledrun_json['nightlight_weekdays_comment'] = w
+ optional_set(sledrun_json, 'nightlight_weekdays_count', v)
+ optional_set(sledrun_json, 'nightlight_weekdays_comment', w)
def _sled_rental():
v = rbb['Rodelverleih']
x['wr_page'] = wikilink_to_json(wiki_link)
else:
x['name'] = name
- if comment is not None:
- x['comment'] = comment
+ optional_set(x, 'comment', comment)
w.append(x)
sledrun_json['sled_rental'] = w
_sled_rental()
sledrun_json['cachet'] = len(v) > 0
_cachet()
- v = rbb['In Übersichtskarte']
- if v is not None:
- sledrun_json['show_in_overview'] = v
-
- v = rbb['Forumid']
- if v is not None:
- sledrun_json['forum_id'] = v
+ optional_set(sledrun_json, 'show_in_overview', rbb['In Übersichtskarte'])
+ optional_set(sledrun_json, 'forum_id', rbb['Forumid'])
v = rbb['Position']
if v is not None:
if len(line) > 0:
return line
return None
- w = _nightlight(str(v))
- if w is not None:
- sledrun_json['nightlight_description'] = w
+ optional_set(sledrun_json, 'nightlight_description', _nightlight(str(v)))
def _gastronomy(value: str):
gastronomy = []
else:
break
return gastronomy
+
w = _gastronomy(str(v))
if len(w) > 0:
sledrun_json['gastronomy'] = w