3 User script for pywikibot (https://gerrit.wikimedia.org/r/pywikibot/core.git), tested with version 6.6.1.
4 Put it in directory scripts/userscripts.
6 Edit JSON associated with sledruns.
8 The following generators and filters are supported:
15 from pywikibot import pagegenerators, Page
16 from pywikibot.bot import (
17 AutomaticTWSummaryBot,
24 from wrpylib.wrmwmarkup import create_sledrun_wiki
27 docuReplacements = {'¶ms;': pagegenerators.parameterHelp}
30 class SledrunFromJsonBot(
35 AutomaticTWSummaryBot,
37 def treat_page(self) -> None:
38 """Load the given page, do some changes, and save it."""
39 if self.current_page.content_model != 'json':
41 content_json = json.loads(self.current_page.text)
42 processed_json = content_json
43 text = json.dumps(processed_json, ensure_ascii=False, indent=4)
44 summary = 'JSON Daten aktualisiert.'
45 self.put_current(text, summary=summary)
48 def main(*args: str) -> None:
49 local_args = pywikibot.handle_args(args)
50 gen_factory = pagegenerators.GeneratorFactory()
51 gen_factory.handle_args(local_args)
52 gen = gen_factory.getCombinedGenerator(preload=True)
54 bot = SledrunFromJsonBot(generator=gen)
57 pywikibot.bot.suggest_help(missing_generator=True)
60 if __name__ == '__main__':