import pywikibot
import sys
from difflib import context_diff
from pywikibot import pagegenerators, Timestamp
import datetime, re

site = pywikibot.Site('zh', 'wikipedia')
ensite = pywikibot.Site('en', 'wikipedia')
repo = site.data_repository()
#trasnclusion generator
referredTemplate = pywikibot.Page(site, 'Template:Redirect')
transclusionGen = pagegenerators.ReferringPageGenerator(referredTemplate, followRedirects=False,
                           withTemplateInclusion=True,
                           onlyTemplateInclusion=True,
                           total=None, content=False)

#namespace filter
filteredTG = pagegenerators.NamespaceFilterPageGenerator(transclusionGen, '', site)
prog = re.compile("t")

for page in filteredTG:
    for line in page.text.split("\n"):
        if 'redirect' in line or "Redirect" in line:
            if "|t|" in line or "|s|" in line:
                prevline = line
                line = line.replace("|t|","||")
                line = line.replace("|s|","||")
                print(page.title())
                print(prevline)
                print(line)
                page.text = page.text.replace(prevline, line)
                page.save("minor fix, remove deprecated parameter from templates")
苏联
{{Redirect|USSR|s|CCCP}}
{{Redirect|USSR||CCCP}}
Page [[苏联]] saved
许昌市
{{Redirect|许昌|s|许都}}
{{Redirect|许昌||许都}}
Page [[许昌市]] saved
泉州市
{{Redirect|泉州|t|温陵|刺桐}}
{{Redirect|泉州||温陵|刺桐}}
Sleeping for 5.4 seconds, 2019-06-08 06:49:46
Page [[泉州市]] saved
斑鸠属
{{Redirect|斑鸠|t|}}
{{Redirect|斑鸠||}}
Page [[斑鸠属]] saved
阿罗汉
{{redirect|羅漢|t|無學}}
{{redirect|羅漢||無學}}
Sleeping for 4.6 seconds, 2019-06-08 06:50:07
Page [[阿罗汉]] saved
辽宁工程技术大学
{{Redirect|辽工大|s|LNTU}}
{{Redirect|辽工大||LNTU}}
Sleeping for 6.4 seconds, 2019-06-08 06:50:15
Page [[辽宁工程技术大学]] saved
实况足球系列
{{redirect|PES|t|勝利十一人}}
{{redirect|PES||勝利十一人}}
Page [[实况足球系列]] saved
捕食
{{redirect|天敵|t|掠食者}}
{{redirect|天敵||掠食者}}
Page [[捕食]] saved
地面中繼式無線電
{{redirect|TETRA|t|行車調度電話}}
{{redirect|TETRA||行車調度電話}}
Page [[地面中繼式無線電]] saved
文昌閣
{{redirect|奎閣|t|奎星阁}}
{{redirect|奎閣||奎星阁}}
Sleeping for 6.7 seconds, 2019-06-08 06:51:46
Page [[文昌閣]] saved
安仁县
{{Redirect|安仁|t|安仁县}}
{{Redirect|安仁||安仁县}}
Page [[安仁县]] saved
罪案現場
{{Redirect|犯罪現場|t|案發現場}}
{{Redirect|犯罪現場||案發現場}}
Sleeping for 6.7 seconds, 2019-06-08 06:52:10
Page [[罪案現場]] saved
訓練生
{{redirect|練習生|t|見習生}}
{{redirect|練習生||見習生}}
Page [[訓練生]] saved