http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10429
Revision: 10429 Author: xqt Date: 2012-06-29 16:14:09 +0000 (Fri, 29 Jun 2012) Log Message: ----------- enable multiple links in a file link, regex stolen from textlib.replaceexcept for nested templates, bugfix for bug #3538973, update from trunk r10428
Modified Paths: -------------- branches/rewrite/scripts/cosmetic_changes.py
Modified: branches/rewrite/scripts/cosmetic_changes.py =================================================================== --- branches/rewrite/scripts/cosmetic_changes.py 2012-06-29 16:13:07 UTC (rev 10428) +++ branches/rewrite/scripts/cosmetic_changes.py 2012-06-29 16:14:09 UTC (rev 10429) @@ -197,6 +197,7 @@ text = isbn.hyphenateIsbnNumbers(text) except isbn.InvalidIsbnException, error: pywikibot.log(u"ISBN error: %s" % error) + pass if self.debug: pywikibot.showDiff(oldText, text) return text @@ -742,7 +743,7 @@ 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) + '):.+?.\w+? *(|[^[]*?([[[^[]*?]][^[]*?)?)?]]', + pattern = re.compile(u'[[(' + '|'.join(namespaces) + '):.+?.\w+? *(|(([[.*?]])|.)*)?]]', re.UNICODE) exceptions.append(pattern) text = pywikibot.replaceExcept(text, u',', u'،', exceptions) @@ -755,7 +756,7 @@ text = pywikibot.replaceExcept(text, u'ك', u'ک', exceptions) text = pywikibot.replaceExcept(text, ur'[ىي]', u'ی', exceptions) # replace persian/arabic digits - for i in xrange(0,10): + 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)
pywikipedia-svn@lists.wikimedia.org