From 659ada954a9dcb3956d55e09a0028ae1d5c5aaa6 Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Sun, 5 Jun 2022 14:31:43 +0200 Subject: [PATCH] Create map even if sledrun JSON exists. --- bots/sledrun_wikitext_to_json.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bots/sledrun_wikitext_to_json.py b/bots/sledrun_wikitext_to_json.py index dc5d06c..60bcb21 100644 --- a/bots/sledrun_wikitext_to_json.py +++ b/bots/sledrun_wikitext_to_json.py @@ -96,11 +96,11 @@ class SledrunWikiTextToJsonBot( sledrun_json_page = Page(self.site, self.current_page.title() + '/Rodelbahn.json') - if sledrun_json_page.exists(): # should be an option - return - map_json_page = Page(self.site, self.current_page.title() + '/Landkarte.json') + if sledrun_json_page.exists() and map_json_page.exists(): # should be an option + return + map_json = None v = wikicode.filter_tags(matches='wrmap') if len(v) > 0: @@ -468,13 +468,14 @@ class SledrunWikiTextToJsonBot( sledrun_json_ordered = order_json_keys(sledrun_json, self.sledrun_schema) assert sledrun_json_ordered == sledrun_json sledrun_json_text = json.dumps(sledrun_json_ordered, ensure_ascii=False, indent=4) - summary = 'Rodelbahnbeschreibung konvertiert von Wikitext nach JSON.' - pywikibot.output('\03{lightpurple}---\03{default}') - pywikibot.output(sledrun_json_text) - pywikibot.output('\03{lightpurple}---\03{default}') - self.userPut(sledrun_json_page, sledrun_json_page.text, sledrun_json_text, summary=summary, contentmodel='json') - - if map_json is not None: + if not sledrun_json_page.exists(): + summary = 'Rodelbahnbeschreibung konvertiert von Wikitext nach JSON.' + pywikibot.output('\03{lightpurple}---\03{default}') + pywikibot.output(sledrun_json_text) + pywikibot.output('\03{lightpurple}---\03{default}') + self.userPut(sledrun_json_page, sledrun_json_page.text, sledrun_json_text, summary=summary, contentmodel='json') + + if map_json is not None and not map_json_page.exists(): map_json_text = json.dumps(map_json, ensure_ascii=False, indent=4) summary = 'Landkarte konvertiert von Wikitext nach JSON.' self.userPut(map_json_page, map_json_page.text, map_json_text, summary=summary, contentmodel='json') -- 2.39.5