Russell Blau has uploaded a new change for review.
https://gerrit.wikimedia.org/r/83054
Change subject: Use API to retrieve all current redirects to the primary
category-redirect template, instead of having to maintain a list of all such
redirects in the family file.
......................................................................
Use API to retrieve all current redirects to the primary category-redirect
template, instead of having to maintain a list of all such redirects in
the family file.
Change-Id: I54ab3ff585236416249d9e31457cd852a1b54408
---
M pywikibot/families/wikipedia_family.py
M pywikibot/family.py
M scripts/i18n
3 files changed, 15 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/54/83054/1
diff --git a/pywikibot/families/wikipedia_family.py
b/pywikibot/families/wikipedia_family.py
index 9624a92..3a36369 100644
--- a/pywikibot/families/wikipedia_family.py
+++ b/pywikibot/families/wikipedia_family.py
@@ -54,11 +54,7 @@
'arz': (u'تحويل تصنيف',),
'cs': (u'Zastaralá kategorie',),
'da': (u'Kategoriomdirigering',),
- 'en': (u'Category redirect',
- u'Category Redirect',
- u"Categoryredirect",
- u'Catredirect',
- u'Cat redirect',),
+ 'en': (u'Category redirect',),
'es': (u'Categoría redirigida',),
'eu': (u'Kategoria redirect',),
'fa': (u'رده بهتر',
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 88eb3d3..f421399 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -751,13 +751,24 @@
def category_redirects(self, code, fallback="_default"):
if code in self.category_redirect_templates:
- return self.category_redirect_templates[code]
+ cr_template = self.category_redirect_templates[code][0]
elif fallback:
- return self.category_redirect_templates[fallback]
+ cr_template = self.category_redirect_templates[fallback][0]
else:
raise KeyError(
"ERROR: title for category redirect template in language '%s' unknown"
% code)
+ # 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)
+ return cr_list
def disambig(self, code, fallback='_default'):
if code in self.disambiguationTemplates:
@@ -769,6 +780,7 @@
"ERROR: title for disambig template in language %s unknown"
% code)
+
# Methods
def protocol(self, code):
"""
diff --git a/scripts/i18n b/scripts/i18n
index 0dcc4d6..9199b7d 160000
--- a/scripts/i18n
+++ b/scripts/i18n
-Subproject commit 0dcc4d63546b038f61e4a5901fda756d0938ea3a
+Subproject commit 9199b7d0d5b5cc987c9089972d401e9ccba0f99a
--
To view, visit https://gerrit.wikimedia.org/r/83054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I54ab3ff585236416249d9e31457cd852a1b54408
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