]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/commitdiff
Use functions get_sledrun_description and optional_set.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 15 Mar 2022 21:13:37 +0000 (22:13 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 15 Mar 2022 21:13:37 +0000 (22:13 +0100)
bots/sledrun_wikitext_to_json.py

index ffc4ff4768f93653957644a544435309dfd681d6..feb2f285bb1841351526542810882dfe64196a4f 100644 (file)
@@ -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.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 = {'&params;': pagegenerators.parameterHelp}
 
 
 docuReplacements = {'&params;': 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,
         }
 
             "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:
 
         rbb_list = wikicode.filter_templates(recursive=False, matches=lambda t: t.name.strip() == 'Rodelbahnbox')
         if len(rbb_list) == 1: