]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/commitdiff
Parse "Tiroler Naturrodelbahn Gütesiegel".
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Sun, 22 May 2022 15:46:24 +0000 (17:46 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Sun, 22 May 2022 15:46:24 +0000 (17:46 +0200)
bots/sledrun_wikitext_to_json.py

index 7ee83ca5a6047fcf8788339d76ade23163f0ae20..92484fdc80d8a2c4ef0ed6e2550c1837b9e4b78d 100644 (file)
@@ -426,6 +426,31 @@ class SledrunWikiTextToJsonBot(
 
         sledrun_json['allow_reports'] = True
 
 
         sledrun_json['allow_reports'] = True
 
+        def _tiroler_naturrodelbahn_guetesiegel():
+            for gst in wikicode.filter_templates():
+                if gst.name.strip() != 'Tiroler Naturrodelbahn Gütesiegel':
+                    continue
+                gsj = {}
+                keys = {
+                    'Anlagename': 'name',
+                    'Organisation': 'organization',
+                    'Erstverleihung': 'first_issued',
+                    'Verlängerung': 'valid_from',
+                    'Forum': 'forum_id',
+                    'Thread': 'thread_id',
+                }
+                numeric = ['first_issued', 'valid_from', 'forum_id', 'thread_id']
+                for key, value in keys.items():
+                    if gst.has(key):
+                        v = gst.get(key).value.strip()
+                        if v != '':
+                            if value in numeric:
+                                v = int(v)
+                            gsj[value] = v
+                if len(gsj) > 0:
+                    sledrun_json['tiroler_naturrodelbahn_gütesiegel'] = gsj
+        _tiroler_naturrodelbahn_guetesiegel()
+
         impressions = None
         sledrun_impressions_page = Page(self.site, self.current_page.title() + '/Impressionen')
         if sledrun_impressions_page.exists():
         impressions = None
         sledrun_impressions_page = Page(self.site, self.current_page.title() + '/Impressionen')
         if sledrun_impressions_page.exists():