From: Philipp Spitzer Date: Tue, 15 Mar 2022 21:13:37 +0000 (+0100) Subject: Use functions get_sledrun_description and optional_set. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/3543c419126f779d77fc06485ed539d5efec9f09 Use functions get_sledrun_description and optional_set. --- diff --git a/bots/sledrun_wikitext_to_json.py b/bots/sledrun_wikitext_to_json.py index ffc4ff4..feb2f28 100644 --- a/bots/sledrun_wikitext_to_json.py +++ b/bots/sledrun_wikitext_to_json.py @@ -35,6 +35,7 @@ from wrpylib.wrmwmarkup import create_sledrun_wiki, lonlat_to_json, lonlat_ele_t 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_lonlat_from_str, \ opt_uint_from_str +from wrpylib.lib_sledrun_wikitext_to_json import optional_set, get_sledrun_description docuReplacements = {'¶ms;': pagegenerators.parameterHelp} @@ -106,13 +107,7 @@ class SledrunWikiTextToJsonBot( "entry_under_construction": sum(1 for c in wikilink_list if c.text == 'Kategorie:In Arbeit') > 0, } - for v in wikicode.get_sections(levels=[2], matches='Allgemeines'): - for w in v.ifilter_text(recursive=False): - x = w.strip() - if x: - sledrun_json["description"] = str(x) - break - break + optional_set(sledrun_json, 'description', get_sledrun_description(wikicode)) rbb_list = wikicode.filter_templates(recursive=False, matches=lambda t: t.name.strip() == 'Rodelbahnbox') if len(rbb_list) == 1: