http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10847
Revision: 10847 Author: xqt Date: 2012-12-30 13:38:38 +0000 (Sun, 30 Dec 2012) Log Message: ----------- ignore redirects to user namespaces
Modified Paths: -------------- trunk/pywikipedia/fixing_redirects.py
Modified: trunk/pywikipedia/fixing_redirects.py =================================================================== --- trunk/pywikipedia/fixing_redirects.py 2012-12-30 11:45:31 UTC (rev 10846) +++ trunk/pywikipedia/fixing_redirects.py 2012-12-30 13:38:38 UTC (rev 10847) @@ -16,7 +16,7 @@ # # This script based on disambredir.py and solve_disambiguation.py # -# (C) Pywikipedia team, 2004-2011 +# (C) Pywikipedia team, 2004-2012 # # Distributed under the terms of the MIT license. # @@ -152,12 +152,10 @@ try: text = page.get() except pywikibot.IsRedirectPage: - pywikibot.output(u'%s is a redirect page. Skipping' - % page.title(asLink=True)) + pywikibot.output(u'%s is a redirect page. Skipping' % page) return except pywikibot.NoPage: - pywikibot.output(u'%s does not exist. Skipping' - % page.title(asLink=True)) + pywikibot.output(u'%s does not exist. Skipping' % page) return pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) @@ -171,17 +169,19 @@ for page2 in links: try: target = page2.getRedirectTarget() - except (pywikibot.Error,pywikibot.SectionError): + except (pywikibot.Error, pywikibot.SectionError): continue + # no fix to user namespaces + if target.namespace() in [0, 1] and not page2.namespace() in [0, 1]: + continue text = treat(text, page2, target) if text != page.get(): comment = i18n.twtranslate(mysite, 'fixing_redirects-fixing') - pywikibot.showDiff(page.get() ,text) + pywikibot.showDiff(page.get(), text) try: page.put(text, comment) except (pywikibot.Error): - pywikibot.output('Error: unable to put %s' - % page.title(asLink=True)) + pywikibot.output('Error: unable to put %s' % page)
def main(): featured = False
pywikipedia-svn@lists.wikimedia.org