-
Notifications
You must be signed in to change notification settings - Fork 12
/
url-replace.py
executable file
·41 lines (30 loc) · 1.27 KB
/
url-replace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env python3
import mwparserfromhell
from ws.checkers import ExtlinkReplacements
from ws.pageupdater import PageUpdater
class Updater(PageUpdater):
force_interactive = True
skip_pages = []
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# temporarily enable all namespaces (Arch's git URLs migration)
#self.namespaces = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 3000, 3001]
if __name__ == "__main__":
import ws.config
import ws.logging
from ws.interactive import InteractiveQuit
argparser = ws.config.getArgParser(description="Parse all pages on the wiki and replace URLs")
Updater.set_argparser(argparser)
# checkers don't have their own set_argparser method at the moment,
# they just reuse API's and PageUpdater's options
args = ws.config.parse_args(argparser)
# set up logging
ws.logging.init(args)
# create updater and add checkers
updater = Updater.from_argparser(args)
checker = ExtlinkReplacements(updater.api, timeout=args.connection_timeout, max_retries=args.connection_max_retries)
updater.add_checker(mwparserfromhell.nodes.ExternalLink, checker)
try:
updater.run()
except (InteractiveQuit, KeyboardInterrupt):
pass