http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11724
Revision: 11724 Author: xqt Date: 2013-07-07 17:27:02 +0000 (Sun, 07 Jul 2013) Log Message: ----------- use iterlanglinks since interwiki() is empty with wikidata
Modified Paths: -------------- branches/rewrite/scripts/featured.py
Modified: branches/rewrite/scripts/featured.py =================================================================== --- branches/rewrite/scripts/featured.py 2013-07-07 17:09:51 UTC (rev 11723) +++ branches/rewrite/scripts/featured.py 2013-07-07 17:27:02 UTC (rev 11724) @@ -360,17 +360,13 @@ oursite = pywikibot.getSite() if page.isRedirectPage(): page = page.getRedirectTarget() - try: - iw = page.interwiki() - except: - pywikibot.output(u"%s -> no interwiki, giving up" % page.title()) - return
ourpage = None - for p in iw: - if p.site() == oursite: - ourpage = p + for link in page.iterlanglinks(): + if link.site == oursite: + ourpage = pywikibot.Page(link) break + if not ourpage: if not quiet: pywikibot.output(u"%s -> no corresponding page in %s" @@ -400,16 +396,12 @@ % ourpage.title()) return
- try: - iw = ourpage.interwiki() - except: - return - - backpage is None - for p in iw: - if p.site() == page.site(): - backpage = p + backpage = None + for link in ourpage.iterlanglinks(): + if link.site == page.site: + backpage = pywikibot.Page(link) break + if not backpage: pywikibot.output(u"%s -> no back interwiki ref" % page.title()) return