Revision: 5625 Author: nicdumz Date: 2008-06-24 07:59:02 +0000 (Tue, 24 Jun 2008)
Log Message: ----------- this script was broken from its initial rev, was it ?
Modified Paths: -------------- trunk/pywikipedia/fixing_redirects.py
Modified: trunk/pywikipedia/fixing_redirects.py =================================================================== --- trunk/pywikipedia/fixing_redirects.py 2008-06-24 02:38:46 UTC (rev 5624) +++ trunk/pywikipedia/fixing_redirects.py 2008-06-24 07:59:02 UTC (rev 5625) @@ -65,6 +65,9 @@ """ Based on the method of the same name in solve_disambiguation.py """ + mysite = wikipedia.getSite() + linktrail = mysite.linktrail() + # make a backup of the original text so we can show the changes later linkR = re.compile(r'[[(?P<title>[^]|#]*)(?P<section>#[^]|]*)?(|(?P<label>[^]]*))?]](?P<linktrail>' + linktrail + ')') curpos = 0 @@ -79,7 +82,7 @@ if m.group('title') == '' or mysite.isInterwikiLink(m.group('title')): continue else: - actualLinkPage = wikipedia.Page(page.site(), m.group('title')) + actualLinkPage = wikipedia.Page(targetPage.site(), m.group('title')) # Check whether the link found is to page. if actualLinkPage != linkedPage: continue @@ -147,7 +150,10 @@ text = treat(text, page2, target) if text != page.get(): comment = wikipedia.translate(mysite, msg) - page.put(text, comment) + try: + page.put(text, comment) + except (wikipedia.Error): + wikipedia.output('Error : unable to put %s' % page.aslink())
def main(): start = '!'