-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup.py
34 lines (27 loc) · 879 Bytes
/
cleanup.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
import pywikibot
from api.page_lister import get_pages_from_category
def cleanup(content):
content = content.replace('{{-dika-}}', '')
content = content.replace('{{}} :', '')
return content
counter = 0
for page in get_pages_from_category('mg', 'Pejy ahitana dikan-teny'):
counter += 1
print('>>>>', page.title(), '<<<<')
old = content = page.get()
changed = False
if content.find('{{anag+}}') != -1:
changed = True
content = content.replace('{{anag+}}', '')
if content.find('=mg=') == -1:
changed = True
content = cleanup(content)
else:
if (content.find('-e-mat-|mg') != -1
or content.find('-e-ana-|mg') != -1
):
changed = True
content = cleanup(content)
if changed:
pywikibot.showDiff(old, content)
page.put(content, 'fandiovana')