jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Only apply uppercase to Link title if namespace dictates so ......................................................................
[FIX] Only apply uppercase to Link title if namespace dictates so
The namespace defines if a Link title begins with an uppercase character. The main namespace of Wiktionary, for example requires an exact match. As the namespace always define the case, using the site case isn't necessary.
If the namespace doesn't report the case property it choses the site global case property.
Bug: 69118 (partially) Change-Id: If86346dc203c54d2e6631e3dddd106add3c34d30 --- M pywikibot/page.py M tests/wikibase_tests.py 2 files changed, 8 insertions(+), 1 deletion(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index 13a5010..1096166 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -4118,7 +4118,12 @@ if self._namespace != -1 and len(t) > 255: raise pywikibot.InvalidTitle("(over 255 bytes): '%s'" % t)
- if self._site.case() == 'first-letter': + if hasattr(self._site.namespaces()[self._namespace], 'case'): + case = self._site.namespaces()[self._namespace].case + else: + case = self._site.case() + + if case == 'first-letter': t = t[:1].upper() + t[1:]
# Can't make a link to a namespace alone... diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index 7726433..0231f55 100644 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -732,9 +732,11 @@ class DrySite(pywikibot.site.DataSite): _namespaces = { 90: Namespace(id=90, + case='first-letter', canonical_name='Item', defaultcontentmodel='wikibase-item'), 92: Namespace(id=92, + case='first-letter', canonical_name='Prop', defaultcontentmodel='wikibase-property') }
pywikibot-commits@lists.wikimedia.org