jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/606988 )
Change subject: [cleanup] Remove deactivated code in cosmetic_changes.py ......................................................................
[cleanup] Remove deactivated code in cosmetic_changes.py
- remove deactivated code in cosmetic_changes.py but save it in T57185 - use textlib.NON_LATIN_DIGITS for fa-digits - use string.format() in favour of modula operator - return text in commonsfiledesc due to PEP 8
Change-Id: I04c725b3cb93bfcba3c1576eb5775ca359c25e78 --- M pywikibot/cosmetic_changes.py 1 file changed, 8 insertions(+), 32 deletions(-)
Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 2f5666e..1baba11 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -272,8 +272,8 @@ result = method(text) except Exception as e: if self.ignore == CANCEL_METHOD: - pywikibot.warning('Unable to perform "{0}" on "{1}"!'.format( - method.__name__, self.title)) + pywikibot.warning('Unable to perform "{}" on "{}"!' + .format(method.__name__, self.title)) pywikibot.exception(e) else: raise @@ -945,21 +945,13 @@ 'startspace', 'inputbox', ] - # FIXME: use textlib.NON_LATIN_DIGITS - # valid digits - digits = { - 'ckb': ('٠١٢٣٤٥٦٧٨٩', 'fa'), - 'fa': ('۰۱۲۳۴۵۶۷۸۹', 'ckb'), - } - faChrs = 'ءاآأإئؤبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیةيك' + digits['fa'][0]
- # For replacing old digits by new one - new, old_key = digits[self.site.code] - old = digits[old_key][0] + digits = textlib.NON_LATIN_DIGITS + faChrs = 'ءاآأإئؤبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیةيك' + digits['fa']
# not to let bot edits in latin content - exceptions.append(re.compile('[^%(fa)s] *?"*? *?, *?[^%(fa)s]' - % {'fa': faChrs})) + exceptions.append(re.compile('[^{fa}] *?"*? *?, *?[^{fa}]' + .format(fa=faChrs))) text = textlib.replaceExcept(text, ',', '،', exceptions, site=self.site) if self.site.code == 'ckb': @@ -978,23 +970,6 @@
return text
- # FIXME: split this function into two. - # replace persian/arabic digits - # deactivated due to bug T57185 - for i in range(0, 10): - text = textlib.replaceExcept(text, old[i], new[i], exceptions) - # do not change digits in class, style and table params - pattern = re.compile(r'\w+=(".+?"|\d+)', re.UNICODE) - exceptions.append(pattern) - # do not change digits inside html-tags - pattern = re.compile('<[/]*?[^</]+?[/]*?>', re.UNICODE) - exceptions.append(pattern) - exceptions.append('table') # exclude tables for now - # replace digits - for i in range(0, 10): - text = textlib.replaceExcept(text, str(i), new[i], exceptions) - return text - def commonsfiledesc(self, text): """ Clean up file descriptions on the Wikimedia Commons. @@ -1006,7 +981,8 @@ https://commons.wikimedia.org/wiki/Commons:Tools/pywiki_file_description_cle... """ if self.site.sitename != 'commons:commons' or self.namespace == 6: - return + return text + # section headers to {{int:}} versions exceptions = ['comment', 'includeonly', 'math', 'noinclude', 'nowiki', 'pre', 'source', 'ref', 'timeline']
pywikibot-commits@lists.wikimedia.org