jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Namespace: Use default and fixed case
......................................................................
[IMPROV] Namespace: Use default and fixed case
For certain namespaces the case sensitivity is fixed and can't be
changed. This either asserts that the case or if the server doesn't
report the case sensitivity for the namespaces specifically uses that
default value.
This also applies to all namespaces created without the help of the API.
Change-Id: I097c4e52ad41bf531f2685e712bb0be27a225661
---
M pywikibot/site.py
1 file changed, 17 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5848169..2becc09 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -368,10 +368,22 @@
% (self.__class__.__name__, self.id, self.custom_name,
self.canonical_name, self.aliases, kwargs)
+ @staticmethod
+ def default_case(id, default_case=None):
+ """Return the default fixed case value for the namespace
ID."""
+ #
https://www.mediawiki.org/wiki/Manual:$wgCapitalLinkOverrides#Warning
+ if id > 0 and id % 2 == 1: # the talk ns has the non-talk ns case
+ id -= 1
+ if id in (-1, 2, 8):
+ return 'first-letter'
+ else:
+ return default_case
+
@classmethod
def builtin_namespaces(cls, use_image_name=False, case='first-letter'):
"""Return a dict of the builtin namespaces."""
- return dict((i, cls(i, use_image_name=use_image_name, case=case))
+ return dict((i, cls(i, use_image_name=use_image_name,
+ case=cls.default_case(i, case)))
for i in range(-2, 16))
@staticmethod
@@ -2139,8 +2151,11 @@
if is_mw114:
canonical_name = nsdata.pop('canonical')
+ default_case = Namespace.default_case(ns)
if 'case' not in nsdata:
- nsdata['case'] = self.siteinfo['case']
+ nsdata['case'] = default_case or self.siteinfo['case']
+ elif default_case is not None:
+ assert(default_case == nsdata['case'])
namespace = Namespace(ns, canonical_name, custom_name,
use_image_name=not is_mw114,
--
To view, visit
https://gerrit.wikimedia.org/r/205596
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I097c4e52ad41bf531f2685e712bb0be27a225661
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>