Revision: 5562 Author: cosoleto Date: 2008-06-12 06:24:30 +0000 (Thu, 12 Jun 2008)
Log Message: ----------- Fixed a 'ValueError: substring not found' in parsing templates with parameters. Fixed the ''UnicodeEncodeError: 'ascii' codec can't encode character...'' error reported in bug #1988771.
Modified Paths: -------------- trunk/pywikipedia/nowcommons.py
Modified: trunk/pywikipedia/nowcommons.py =================================================================== --- trunk/pywikipedia/nowcommons.py 2008-06-12 05:13:02 UTC (rev 5561) +++ trunk/pywikipedia/nowcommons.py 2008-06-12 06:24:30 UTC (rev 5562) @@ -161,7 +161,9 @@ if params == []: filenameOnCommons = localImagePage.titleWithoutNamespace() elif self.site.lang in namespaceInTemplate: - filenameOnCommons = params[0][params[0].index(':') + 1:] + for par in params: + if ':' in par: + filenameOnCommons = par[par.index(':') + 1:] else: filenameOnCommons = params[0] return filenameOnCommons @@ -219,7 +221,7 @@ else: wikipedia.output(u'The image is not identical to the one on Commons.') except (wikipedia.NoPage, wikipedia.IsRedirectPage), e: - wikipedia.output(u'%s' % e) + wikipedia.output(u'%s' % e[0]) continue
def main():