http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10452
Revision: 10452
Author: xqt
Date: 2012-07-09 13:18:08 +0000 (Mon, 09 Jul 2012)
Log Message:
-----------
enable fixArabicLetters() without fixing digits,
fix for fa pipe andlinkstrails moved to cleanUpLinks()
Modified Paths:
--------------
trunk/pywikipedia/cosmetic_changes.py
Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py 2012-07-09 13:06:27 UTC (rev 10451)
+++ trunk/pywikipedia/cosmetic_changes.py 2012-07-09 13:18:08 UTC (rev 10452)
@@ -178,8 +178,8 @@
text = self.fixReferences(text)
text = self.fixStyle(text)
text = self.fixTypo(text)
-## if self.site.lang in ['ckb', 'fa']:
-## text = self.fixArabicLetters(text)
+ if self.site.lang in ['ckb', 'fa']:
+ text = self.fixArabicLetters(text)
try:
text = isbn.hyphenateIsbnNumbers(text)
except isbn.InvalidIsbnException, error:
@@ -515,6 +515,13 @@
text = pywikibot.replaceExcept(text, linkR, handleOneLink,
['comment', 'math',
'nowiki', 'pre',
'startspace'])
+ ##fixing pipe and trailing for fa. Thanks ZxxZxxZ
+ if self.site.lang == 'fa':
+ faChrs = u'ءاآأإئؤبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیةيك' +
u'ًٌٍَُِّْٓٔ'
+ text = re.sub(u'\[\[([^\]\|]*)]]([%s]+)' % faChrs,
+ ur'[[\1|\1\2]]', text)
+ text = re.sub(u'\[\[([^\]\|]*)\|(.+?)]]([%s]+)' % faChrs,
+ ur'[[\1|\2\3]]', text)
return text
def resolveHtmlEntities(self, text):
@@ -739,7 +746,9 @@
text = pywikibot.replaceExcept(text, u'ه', u'ھ', exceptions)
text = pywikibot.replaceExcept(text, u'ك', u'ک', exceptions)
text = pywikibot.replaceExcept(text, ur'[ىي]', u'ی', exceptions)
+ return text
# replace persian/arabic digits
+ ## deactivated due to bug #3539407
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
@@ -752,11 +761,6 @@
# replace digits
for i in xrange(0, 10):
text = pywikibot.replaceExcept(text, str(i), new[i], exceptions)
- ##fixing pipe and trailing for fa. Thanks ZxxZxxZ
- if self.site.lang=='fa':
- faChrs = u'ءاآأإئؤبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیةيك' +
u'ًٌٍَُِّْٓٔ'
- text = re.sub(u'\[\[([^\]\|]*)]]([%s]+)' % faChrs,
ur'[[\1|\1\2]]', text)
- text = re.sub(u'\[\[([^\]\|]*)\|(.+?)]]([%s]+)' % faChrs,
ur'[[\1|\2\3]]', text)
return text
# Retrieved from
"http://commons.wikimedia.org/wiki/Commons:Tools/pywiki_file_description_cleanup"