http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10120
Revision: 10120 Author: xqt Date: 2012-04-16 12:26:38 +0000 (Mon, 16 Apr 2012) Log Message: ----------- do not localize #REDIRECT tag if the target page is the same, update from trunk r9532
Modified Paths: -------------- branches/rewrite/scripts/redirect.py
Modified: branches/rewrite/scripts/redirect.py =================================================================== --- branches/rewrite/scripts/redirect.py 2012-04-16 11:48:44 UTC (rev 10119) +++ branches/rewrite/scripts/redirect.py 2012-04-16 12:26:38 UTC (rev 10120) @@ -49,8 +49,8 @@ # # (C) Daniel Herding, 2004. # (C) Purodha Blissenbach, 2009. -# (C) xqt, 2009-2010 -# (C) Pywikipedia bot team, 2004-2010 +# (C) xqt, 2009-2012 +# (C) Pywikipedia bot team, 2004-2011 # # Distributed under the terms of the MIT license. # @@ -58,7 +58,8 @@ # import re, sys, datetime import pywikibot -from pywikibot import config, i18n +from pywikibot import i18n +from pywikibot import config # import xmlreader
@@ -336,7 +337,8 @@ - datetime.timedelta(0, self.offset*3600) # self.offset hours ago offset_time = start.strftime("%Y%m%d%H%M%S") - + pywikibot.output(u'Retrieving %s moved pages via API...' + % str(self.api_number)) move_gen = self.site.logevents(logtype="move", start=offset_time) if self.api_number: move_gen.set_maximum_items(self.api_number) @@ -575,7 +577,7 @@ '#%s %s' % (self.site.redirect(True), targetPage.title(asLink=True, textlink=True)), oldText) - if text == oldText: + if redir.title() == targetPage.title() or text == oldText: pywikibot.output(u"Note: Nothing left to do on %s" % redir.title(asLink=True)) break @@ -633,6 +635,7 @@ elif self.action == 'both': self.fix_double_or_delete_broken_redirects()
+ def main(*args): # read command line parameters # what the bot should do (either resolve double redirs, or delete broken @@ -713,7 +716,6 @@ bot = RedirectRobot(action, gen, always, number, step) bot.run()
- if __name__ == '__main__': try: main()
pywikipedia-svn@lists.wikimedia.org