jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342000 )
Change subject: Revert "Improve and re-enable translateMagicWords" ......................................................................
Revert "Improve and re-enable translateMagicWords"
This reverts commit 911d9359256bfbb0742e1159457d5a5633f76433.
Bug: 159997 Change-Id: I6fbecbee2d3dd09ad3dcd8ae76bc4e0cbf857f9e --- M pywikibot/cosmetic_changes.py M tests/cosmetic_changes_tests.py 2 files changed, 8 insertions(+), 22 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 07fb95c..f1923a8 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -50,7 +50,7 @@ """ # # (C) xqt, 2009-2016 -# (C) Pywikibot team, 2006-2017 +# (C) Pywikibot team, 2006-2016 # # Distributed under the terms of the MIT license. # @@ -221,7 +221,8 @@ self.cleanUpSectionHeaders, self.putSpacesInLists, self.translateAndCapitalizeNamespaces, - self.translateMagicWords, + # FIXME: fix bugs and re-enable + # self.translateMagicWords, self.replaceDeprecatedTemplates, # FIXME: fix bugs and re-enable # self.resolveHtmlEntities, @@ -405,22 +406,19 @@ """Use localized magic words.""" # not wanted at ru # arz uses english stylish codes - # no need to run on English wikis - if self.site.code not in ['arz', 'en', 'ru']: + if self.site.code not in ['arz', 'ru']: exceptions = ['nowiki', 'comment', 'math', 'pre'] for magicWord in ['img_thumbnail', 'img_left', 'img_center', 'img_right', 'img_none', 'img_framed', 'img_frameless', 'img_border', 'img_upright', ]: - aliases = list(self.site.getmagicwords(magicWord)) - preferred = aliases.pop(0) + aliases = self.site.getmagicwords(magicWord) if not aliases: continue text = textlib.replaceExcept( text, - r'[[(?P<left>.+?:.+?..+?|(.*?|)*?) *(' + - '|'.join(aliases) + - r') *(?P<right>(|.*?)*?]])', - r'[[\g<left>' + preferred + r'\g<right>', exceptions) + r'[[(?P<left>.+?:.+?..+?|) *(' + '|'.join(aliases) + + r') *(?P<right>(|.*?)?]])', + r'[[\g<left>' + aliases[0] + r'\g<right>', exceptions) return text
def cleanUpLinks(self, text): diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py index 5db7281..cc3947c 100644 --- a/tests/cosmetic_changes_tests.py +++ b/tests/cosmetic_changes_tests.py @@ -244,18 +244,6 @@ self.assertEqual( '[[File:Foo.bar|miniatur]]', self.cct.translateMagicWords('[[File:Foo.bar|mini]]')) - self.assertEqual( - '[[File:Foo.bar|links|miniatur]]', - self.cct.translateMagicWords('[[File:Foo.bar|left|thumb]]')) - self.assertEqual( - '[[File:Foo.bar|250px|links]]', - self.cct.translateMagicWords('[[File:Foo.bar|250px|left]]')) - self.assertEqual( - '[[File:Foo.bar|links|250px]]', - self.cct.translateMagicWords('[[File:Foo.bar| left |250px]]')) - self.assertEqual( - '[[File:Foo.bar|250px|zentriert|Baz]]', - self.cct.translateMagicWords('[[File:Foo.bar|250px|center|Baz]]'))
def test_cleanUpLinks_pipes(self): """Test cleanUpLinks method."""
pywikibot-commits@lists.wikimedia.org