]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/commitdiff
Move bot to bots directory.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 26 Oct 2021 14:56:02 +0000 (16:56 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 26 Oct 2021 14:56:02 +0000 (16:56 +0200)
bots/sledrun_from_json.py [new file with mode: 0644]
scripts/sledrun_from_json.py [deleted file]

diff --git a/bots/sledrun_from_json.py b/bots/sledrun_from_json.py
new file mode 100644 (file)
index 0000000..cf34ab1
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+"""
+User script for pywikibot (https://gerrit.wikimedia.org/r/pywikibot/core.git), tested with version 6.6.1.
+Put it in directory scripts/userscripts.
+
+Replace a sledrun page with content generated from associated JSON subpages
+(Rodelbahn and Landkarte).
+
+The following generators and filters are supported:
+
+&params;
+"""
+import json
+
+import pywikibot
+from pywikibot import pagegenerators, Page
+from pywikibot.bot import (
+    AutomaticTWSummaryBot,
+    ConfigParserBot,
+    ExistingPageBot,
+    NoRedirectPageBot,
+    SingleSiteBot,
+)
+
+from wrpylib.wrmwmarkup import create_sledrun_wiki
+
+
+docuReplacements = {'&params;': pagegenerators.parameterHelp}
+
+
+class SledrunFromJsonBot(
+    SingleSiteBot,
+    ConfigParserBot,
+    ExistingPageBot,
+    NoRedirectPageBot,
+    AutomaticTWSummaryBot,
+):
+    def treat_page(self) -> None:
+        """Load the given page, do some changes, and save it."""
+        sledrun_json_page = Page(self.site, self.current_page.title() + '/Rodelbahn.json')
+        if not sledrun_json_page.exists() or sledrun_json_page.content_model != 'json':
+            return
+        sledrun_json = json.loads(sledrun_json_page.text)
+        map_json_page = Page(self.site, self.current_page.title() + '/Landkarte.json')
+        if map_json_page.exists():
+            map_json = json.loads(map_json_page.text)
+        else:
+            map_json = None
+        text = create_sledrun_wiki(sledrun_json, map_json)
+        summary = 'Rodelbahnbeschreibung von aus JSON Daten aktualisiert.'
+        self.put_current(text, summary=summary)
+
+
+def main(*args: str) -> None:
+    local_args = pywikibot.handle_args(args)
+    gen_factory = pagegenerators.GeneratorFactory()
+    gen_factory.handle_args(local_args)
+    gen = gen_factory.getCombinedGenerator(preload=True)
+    if gen:
+        bot = SledrunFromJsonBot(generator=gen)
+        bot.run()
+    else:
+        pywikibot.bot.suggest_help(missing_generator=True)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/scripts/sledrun_from_json.py b/scripts/sledrun_from_json.py
deleted file mode 100644 (file)
index cf34ab1..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/python
-"""
-User script for pywikibot (https://gerrit.wikimedia.org/r/pywikibot/core.git), tested with version 6.6.1.
-Put it in directory scripts/userscripts.
-
-Replace a sledrun page with content generated from associated JSON subpages
-(Rodelbahn and Landkarte).
-
-The following generators and filters are supported:
-
-&params;
-"""
-import json
-
-import pywikibot
-from pywikibot import pagegenerators, Page
-from pywikibot.bot import (
-    AutomaticTWSummaryBot,
-    ConfigParserBot,
-    ExistingPageBot,
-    NoRedirectPageBot,
-    SingleSiteBot,
-)
-
-from wrpylib.wrmwmarkup import create_sledrun_wiki
-
-
-docuReplacements = {'&params;': pagegenerators.parameterHelp}
-
-
-class SledrunFromJsonBot(
-    SingleSiteBot,
-    ConfigParserBot,
-    ExistingPageBot,
-    NoRedirectPageBot,
-    AutomaticTWSummaryBot,
-):
-    def treat_page(self) -> None:
-        """Load the given page, do some changes, and save it."""
-        sledrun_json_page = Page(self.site, self.current_page.title() + '/Rodelbahn.json')
-        if not sledrun_json_page.exists() or sledrun_json_page.content_model != 'json':
-            return
-        sledrun_json = json.loads(sledrun_json_page.text)
-        map_json_page = Page(self.site, self.current_page.title() + '/Landkarte.json')
-        if map_json_page.exists():
-            map_json = json.loads(map_json_page.text)
-        else:
-            map_json = None
-        text = create_sledrun_wiki(sledrun_json, map_json)
-        summary = 'Rodelbahnbeschreibung von aus JSON Daten aktualisiert.'
-        self.put_current(text, summary=summary)
-
-
-def main(*args: str) -> None:
-    local_args = pywikibot.handle_args(args)
-    gen_factory = pagegenerators.GeneratorFactory()
-    gen_factory.handle_args(local_args)
-    gen = gen_factory.getCombinedGenerator(preload=True)
-    if gen:
-        bot = SledrunFromJsonBot(generator=gen)
-        bot.run()
-    else:
-        pywikibot.bot.suggest_help(missing_generator=True)
-
-
-if __name__ == '__main__':
-    main()