-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_6_no_iotation.py
49 lines (40 loc) · 1.4 KB
/
fix_6_no_iotation.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
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pywikibot, re, sys, argparse
import blib
from blib import getparam, rmparam, msg, site
def process_page(page, index, parsed):
pagetitle = str(page.title())
def pagemsg(txt):
msg("Page %s %s: %s" % (index, pagetitle, txt))
pagemsg("WARNING: Script no longer applies and would need fixing up")
return
pagemsg("Processing")
text = str(page.text)
parsed = blib.parse(page)
notes = []
for t in parsed.filter_templates():
origt = str(t)
param1 = getparam(t, "1")
if str(t.name) in ["ru-conj"]:
if re.search(r"^6[ac]", param1):
if getparam(t, "no_iotation"):
rmparam(t, "no_iotation")
if param1.startswith("6a"):
notes.append("6a + no_iotation -> 6°a")
else:
notes.append("6c + no_iotation -> 6°c")
t.add("1", re.sub("^6", "6°", param1))
elif re.search(r"^6b", param1):
notes.append("6b -> 6°b")
t.add("1", re.sub("^6", "6°", param1))
newt = str(t)
if origt != newt:
pagemsg("Replaced %s with %s" % (origt, newt))
return str(parsed), notes
parser = blib.create_argparser("Fix up class-6 no-iotation verbs",
include_pagefile=True)
args = parser.parse_args()
start, end = blib.parse_start_end(args.start, args.end)
blib.do_pagefile_cats_refs(args, start, end, process_page, edit=True,
default_cats=["Russian class 6 verbs"])