jenkins-bot has submitted this change and it was merged.
Change subject: [Bug 56873] Fix access to the fallback category redirect list. ......................................................................
[Bug 56873] Fix access to the fallback category redirect list.
Change-Id: Idbf7cf6a262512c354720f5065c81d0ed871c758 --- M pywikibot/family.py 1 file changed, 15 insertions(+), 12 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py index 4c54c66..82f7377 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -873,19 +873,22 @@ 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), - "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) + cr_template_list = self.category_redirect_templates[fallback] + cr_list = [] + if cr_template_list: + 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) + # 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'):
pywikibot-commits@lists.wikimedia.org