Gerrit Patch Uploader has uploaded a new change for review.

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


Change subject: Fix access to the fallback category redirect list.
......................................................................

Fix access to the fallback category redirect list.

Change-Id: Idbf7cf6a262512c354720f5065c81d0ed871c758
---
M pywikibot/family.py
1 file changed, 15 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/21/94621/1

diff --git a/pywikibot/family.py b/pywikibot/family.py
index 4c54c66..3122955 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -873,19 +873,23 @@
         if not hasattr(self, "_catredirtemplates"):
             self._catredirtemplates = {}
         if code in self.category_redirect_templates:
-            cr_template = self.category_redirect_templates[code][0]
+            cr_template_list = self.category_redirect_templates[code]
+            cr_list = list(self.category_redirect_templates[code])
         else:
-            cr_template = self.category_redirect_templates[fallback][0]
-        # start with list of category redirect templates from family file
-        cr_page = pywikibot.Page(pywikibot.Site(code, self),
+            cr_template_list = self.category_redirect_templates[fallback]
+            cr_list = []
+       if len(cr_template_list) > 0:
+            cr_template = cr_template_list[0]
+            
+            # start with list of category redirect templates from family file
+            cr_page = pywikibot.Page(pywikibot.Site(code, self),
                                  "Template:" + cr_template)
-        cr_list = list(self.category_redirect_templates[code])
-        # retrieve all redirects to primary template from API,
-        # add any that are not already on the list
-        for t in cr_page.backlinks(filterRedirects=True, namespaces=10):
-            newtitle = t.title(withNamespace=False)
-            if newtitle not in cr_list:
-                cr_list.append(newtitle)
+            # retrieve all redirects to primary template from API,
+            # add any that are not already on the list
+            for t in cr_page.backlinks(filterRedirects=True, namespaces=10):
+                newtitle = t.title(withNamespace=False)
+                if newtitle not in cr_list:
+                    cr_list.append(newtitle)
         self._catredirtemplates[code] = cr_list
 
     def disambig(self, code, fallback='_default'):

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbf7cf6a262512c354720f5065c81d0ed871c758
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to