jenkins-bot has submitted this change and it was merged.
Change subject: Allow category redirects with or without the namespace prefix. ......................................................................
Allow category redirects with or without the namespace prefix.
Change-Id: Id258f16186d14eaaf4e1864799bc9277bf954182 --- M pywikibot/page.py 1 file changed, 10 insertions(+), 4 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index b75bbc3..4e3aab6 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -492,15 +492,21 @@ if template.title(withNamespace=False) in catredirs: # Get target (first template argument) try: - self._catredirect = "%s:%s" % (self.site.namespace(14), - args[0].strip()) - break + p = pywikibot.Page(self.site, args[0].strip(), ns=14) + if p.namespace() == 14: + self._catredirect = p.title() + else: + pywikibot.warning( + u"Target %s on %s is not a category" + % (p.title(asLink=True), + self.title(asLink=True))) + self._catredirect = False except IndexError: pywikibot.warning( u"No target for category redirect on %s" % self.title(asLink=True)) self._catredirect = False - break + break else: self._catredirect = False return bool(self._catredirect)
pywikibot-commits@lists.wikimedia.org