Russell Blau has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/112312

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, 11 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/12/112312/1

diff --git a/pywikibot/page.py b/pywikibot/page.py
index b75bbc3..972a061 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -483,7 +483,6 @@
 
     def isCategoryRedirect(self):
         """Return True if this is a category redirect page, False otherwise."""
-
         if not self.isCategory():
             return False
         if not hasattr(self, "_catredirect"):
@@ -492,8 +491,17 @@
                 if template.title(withNamespace=False) in catredirs:
                     # Get target (first template argument)
                     try:
-                        self._catredirect = "%s:%s" % (self.site.namespace(14),
-                                                       args[0].strip())
+                        cr = args[0].strip()
+                        if ":" in cr and cr[ : cr.find(":")] \
+                                in self.site.namespaces()[14]:
+                            # {{category redirect|Category:Foo}}
+                            # target is [[Category:Foo]]
+                            self._catredirect = cr
+                        else:
+                            # {{category redirect|Foo}}
+                            # target is [[Category:Foo]]
+                            self._catredirect = "%s:%s" \
+                                            % (self.site.namespace(14), cr)
                         break
                     except IndexError:
                         pywikibot.warning(

-- 
To view, visit https://gerrit.wikimedia.org/r/112312
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id258f16186d14eaaf4e1864799bc9277bf954182
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Russell Blau <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to