self.chained_validators = [RodelbahnboxDictConverter()]
-def sledrun_to_rodelbahnbox(sledrun, version):
+def sledrun_to_rodelbahnbox(sledrun, version=None):
"""Converts a sledrun class to the {{Rodelbahnbox}} representation.
The sledrun class has to have properties like position_latitude, ...
See the table sledruncache for field (column) values.
:param sledrun: an arbitrary class that contains the right properties
:param version: a string specifying the version of the rodelbahnbox zu produce.
- Version '1.3' and '1.4' are supported."""
- keys = []
- values = []
- keys.append(u'Position')
- values.append(wrpylib.wrvalidators.GeoNone().from_python((sledrun.position_latitude, sledrun.position_longitude)))
- keys.append(u'Position oben')
- values.append(wrpylib.wrvalidators.GeoNone().from_python((sledrun.top_latitude, sledrun.top_longitude)))
- keys.append(u'Höhe oben')
- values.append(wrpylib.wrvalidators.UnsignedNone().from_python(sledrun.top_elevation))
- keys.append(u'Position unten')
- values.append(wrpylib.wrvalidators.GeoNone().from_python((sledrun.bottom_latitude, sledrun.bottom_longitude)))
- keys.append(u'Höhe unten')
- values.append(wrpylib.wrvalidators.UnsignedNone().from_python(sledrun.bottom_elevation))
- keys.append(u'Länge')
- values.append(wrpylib.wrvalidators.UnsignedNone().from_python(sledrun.length))
- keys.append(u'Schwierigkeit')
- values.append(wrpylib.wrvalidators.GermanDifficulty().from_python(sledrun.difficulty))
- keys.append(u'Lawinen')
- values.append(wrpylib.wrvalidators.GermanAvalanches().from_python(sledrun.avalanches))
- keys.append(u'Betreiber')
- values.append(wrpylib.wrvalidators.UnicodeNone().from_python(sledrun.operator))
- keys.append(u'Öffentliche Anreise')
- values.append(wrpylib.wrvalidators.GermanPublicTransport().from_python(sledrun.public_transport))
- if version == '1.4':
- keys.append(u'Aufstieg möglich')
- values.append(wrpylib.wrvalidators.GermanBoolNone().from_python(sledrun.walkup_possible))
- keys.append(u'Aufstieg getrennt')
- values.append(wrpylib.wrvalidators.GermanTristateFloatComment().from_python((sledrun.walkup_separate, sledrun.walkup_separate_comment)))
- keys.append(u'Gehzeit')
- values.append(wrpylib.wrvalidators.UnsignedNone().from_python(sledrun.walkup_time))
- keys.append(u'Aufstiegshilfe')
- values.append(wrpylib.wrvalidators.GermanLift().from_python((sledrun.lift, sledrun.lift_details)))
- keys.append(u'Beleuchtungsanlage')
- values.append(wrpylib.wrvalidators.GermanTristateFloatComment().from_python((sledrun.night_light, sledrun.night_light_comment)))
- keys.append(u'Beleuchtungstage')
- values.append(wrpylib.wrvalidators.UnsignedCommentNone(max=7).from_python((sledrun.night_light_days, sledrun.night_light_days_comment)))
- keys.append(u'Rodelverleih')
- values.append(wrpylib.wrvalidators.SledRental().from_python((sledrun.sled_rental, sledrun.sled_rental_comment)))
- keys.append(u'Gütesiegel')
- values.append(wrpylib.wrvalidators.GermanCachet().from_python(sledrun.cachet))
- keys.append(u'Webauskunft')
- values.append(wrpylib.wrvalidators.UrlNeinNone().from_python(sledrun.information_web))
- keys.append(u'Telefonauskunft')
- values.append(wrpylib.wrvalidators.PhoneCommentListNeinLoopNone(comments_are_optional=False).from_python(sledrun.information_phone))
- keys.append(u'Bild')
- values.append(wrpylib.wrvalidators.UnicodeNone().from_python(sledrun.image))
- keys.append(u'In Übersichtskarte')
- values.append(wrpylib.wrvalidators.GermanBoolNone().from_python(sledrun.show_in_overview))
- keys.append(u'Forumid')
- values.append(wrpylib.wrvalidators.UnsignedNeinNone().from_python(sledrun.forum_id))
- return wrpylib.mwmarkup.create_template(u'Rodelbahnbox', [], keys, values, True, 20)
+ Version '1.4' is supported."""
+ assert version in [None, '1.4']
+ return RodelbahnboxValidator().from_python(sledrun)
def gasthausbox_to_inn(wikitext, inn=None):