Revision: 5288 Author: btongminh Date: 2008-04-30 17:31:44 +0000 (Wed, 30 Apr 2008)
Log Message: ----------- Catch missing sites
Modified Paths: -------------- trunk/pywikipedia/commonsdelinker/delinker.py
Modified: trunk/pywikipedia/commonsdelinker/delinker.py =================================================================== --- trunk/pywikipedia/commonsdelinker/delinker.py 2008-04-30 17:15:31 UTC (rev 5287) +++ trunk/pywikipedia/commonsdelinker/delinker.py 2008-04-30 17:31:44 UTC (rev 5288) @@ -108,6 +108,9 @@ skipped_images = {} for (lang, family), pages in usage.iteritems(): site = self.CommonsDelinker.get_site(lang, family) + if not site: + output(u'%s Warning! Unknown site %s:%s' % (self, family, lang)) + continue try: summary = self.get_summary(site, image, admin, reason, replacement) @@ -737,10 +740,14 @@ if key not in self.sites: self.sites[key] = [] for site, used in self.sites[key]: + if not site: return False if not used: self.sites[key][self.sites[key].index((site, False))] = (site, True) return site - site = wikipedia.Site(code, fam) + try: + site = wikipedia.Site(code, fam) + except wikipedia.NoSuchSite: + site = False self.sites[key].append((site, True)) return site finally:
pywikipedia-l@lists.wikimedia.org