]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/blobdiff - bots/sledrun_json_validate.py
Create script update_sledrun_json_from_wikitext_walkup_time_note.py.
[philipp/winterrodeln/wrpylib.git] / bots / sledrun_json_validate.py
index 4dbccfdb1472d9ea11f8aa4313226e69492e8c4b..458c89f2ac477df9d3f2a9cfa899d8764c35e896 100644 (file)
@@ -42,7 +42,11 @@ class SledrunFromJsonBot(
 
     def treat_page(self) -> None:
         """Load the given page, do some changes, and save it."""
-        content_json = json.loads(self.current_page.text)
+        sledrun_json_page = Page(self.site, self.current_page.title() + '/Rodelbahn.json')
+        if not sledrun_json_page.exists():
+            return
+        content_json = json.loads(sledrun_json_page.text)
+        text_orig = json.dumps(content_json, ensure_ascii=False, indent=4)
         try:
             validate(instance=content_json, schema=self.sledrun_schema)
 
@@ -54,7 +58,7 @@ class SledrunFromJsonBot(
             text = str(e)
 
         summary = 'JSON Daten aktualisiert.'
-        self.put_current(text, summary=summary)
+        self.userPut(sledrun_json_page, text_orig, text, summary=summary, contentmodel='json')
 
 
 def main(*args: str) -> None: