jenkins-bot has submitted this change and it was merged.
Change subject: BREAKING: make APISite.has_extension() case-sensitive ......................................................................
BREAKING: make APISite.has_extension() case-sensitive
MediaWiki handles extension names case-sensitively, in fact some extensions' names only differ in capitalization:
* https://www.mediawiki.org/wiki/Extension:BootStrap https://www.mediawiki.org/wiki/Extension:Bootstrap
* https://www.mediawiki.org/wiki/Extension:WikiTeX https://www.mediawiki.org/wiki/Extension:WikiTex
TestSiteExtensions.testExtensions() has been updated accordingly.
Note: the now deprecated hasExtension() method has behaved case-insensitively since Merlijn van Deen's commit 149a90bfc0f53996ff6e6201e7ec0233cb2d78b1. It has been kept case insensitive.
Change-Id: I1d7aeaac0391693bb5a4b1a229205fabf3bba7e2 --- M pywikibot/site.py M tests/site_tests.py 2 files changed, 9 insertions(+), 4 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved XZise: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 457a917..5aa5969 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -2167,20 +2167,25 @@ if unknown is not None: pywikibot.debug(u'unknown argument of hasExtension is deprecated.', _logger) - return self.has_extension(name) + extensions = self.siteinfo['extensions'] + name = name.lower() + for ext in extensions: + if ext['name'].lower() == name: + return True + return False
@need_version("1.14") def has_extension(self, name): """Determine whether extension `name` is loaded.
- @param name: The extension to check for, case insensitive + @param name: The extension to check for, case sensitive @type name: str @return: If the extension is loaded @rtype: bool """ extensions = self.siteinfo['extensions'] for ext in extensions: - if ext['name'].lower() == name.lower(): + if ext['name'] == name: return True return False
diff --git a/tests/site_tests.py b/tests/site_tests.py index 322f1ef..ffc18a9 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -1531,7 +1531,7 @@ self.assertTrue(mysite.has_extension('Disambiguator'))
# test case-sensitivity - self.assertTrue(mysite.has_extension('disambiguator')) + self.assertFalse(mysite.has_extension('disambiguator'))
self.assertFalse(mysite.has_extension('ThisExtensionDoesNotExist'))
pywikibot-commits@lists.wikimedia.org