http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11519
Revision: 11519 Author: multichill Date: 2013-05-09 18:38:53 +0000 (Thu, 09 May 2013) Log Message: ----------- Follow redirects
Modified Paths: -------------- branches/rewrite/scripts/harvest_template.py
Modified: branches/rewrite/scripts/harvest_template.py =================================================================== --- branches/rewrite/scripts/harvest_template.py 2013-05-09 17:59:23 UTC (rev 11518) +++ branches/rewrite/scripts/harvest_template.py 2013-05-09 18:38:53 UTC (rev 11519) @@ -104,6 +104,8 @@ try: link = pywikibot.Link(match.group(1)) linkedPage = pywikibot.Page(link) + if linkedPage.isRedirectPage(): + linkedPage = linkedPage.getRedirectTarget() linkedItem = pywikibot.ItemPage.fromPage(linkedPage) claim.setTarget(linkedItem) pywikibot.output('Adding %s --> %s' % (claim.getID(), claim.getTarget().getID()))