http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10426
Revision: 10426 Author: xqt Date: 2012-06-28 07:49:49 +0000 (Thu, 28 Jun 2012) Log Message: ----------- invalid replacements inside file links; fix for bug #3538506 update from trunk r10425
Modified Paths: -------------- branches/rewrite/scripts/cosmetic_changes.py
Modified: branches/rewrite/scripts/cosmetic_changes.py =================================================================== --- branches/rewrite/scripts/cosmetic_changes.py 2012-06-28 06:55:52 UTC (rev 10425) +++ branches/rewrite/scripts/cosmetic_changes.py 2012-06-28 07:49:49 UTC (rev 10426) @@ -741,8 +741,8 @@ # This only works if there are only two items in digits dict old = digits[digits.keys()[0]] # do not change inside file links - namespaces = list(self.site.namespace(6, all = True)) - pattern = re.compile(u'[[(' + '|'.join(namespaces) + '):.+?..+?]]', + namespaces = list(self.site.namespace(6, all=True)) + pattern = re.compile(u'[[(' + '|'.join(namespaces) + '):.+?.\w+? *(|[^[]*?([[[^[]*?]][^[]*?)?)?]]', re.UNICODE) exceptions.append(pattern) text = pywikibot.replaceExcept(text, u',', u'،', exceptions) @@ -754,8 +754,8 @@ text = pywikibot.replaceExcept(text, u'ه', u'ھ', exceptions) text = pywikibot.replaceExcept(text, u'ك', u'ک', exceptions) text = pywikibot.replaceExcept(text, ur'[ىي]', u'ی', exceptions) - # replace persian digits - for i in range(0,10): + # replace persian/arabic digits + for i in xrange(0,10): text = pywikibot.replaceExcept(text, old[i], new[i], exceptions) # do not change digits in class, style and table params pattern = re.compile(u'\w+=(".+?"|\d+)', re.UNICODE) @@ -764,7 +764,8 @@ pattern = re.compile(u'<[/]*?[^</]+?[/]*?>', re.UNICODE) exceptions.append(pattern) exceptions.append('table') #exclude tables for now - for i in range(0,10): + # replace digits + for i in xrange(0, 10): text = pywikibot.replaceExcept(text, str(i), new[i], exceptions) return text