#!/usr/bin/python
import argparse
import json
+import sys
from typing import List
from termcolor import cprint # python3-termcolor
import jsonschema
-import pywikibot
-from pywikibot import input_yn
+from wrpylib.cli_tools import unified_diff, input_yes_no_quit, Choice
from wrpylib.mwapi import WikiSite
from wrpylib.wrmwmarkup import create_sledrun_wiki
return
cprint(wiki_page['title'], 'green')
- pywikibot.showDiff(previous_text.strip(), new_text.strip(), context=2)
- yn = input_yn('Do you accept the changes?', True)
- if not yn:
+ unified_diff(previous_text, new_text)
+ choice = input_yes_no_quit('Do you accept the changes [yes, no, quit]? ', None)
+ if choice == Choice.no:
return
+ if choice == Choice.quit:
+ sys.exit(0)
+
site(
'edit',
pageid=wiki_page['pageid'],
assert wikitext_page['title'] + '/Rodelbahn.json' == json_page['title']
if 'missing' in json_page:
continue
- if wikitext_page['revisions'][0]['timestamp'] < json_page['revisions'][0]['timestamp']:
+ if update_all or (wikitext_page['revisions'][0]['timestamp'] < json_page['revisions'][0]['timestamp']):
update_wikitext_title_list.append(wikitext_page['title'])
update_json_title_list.append(json_page['title'])