jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/507974 )
Change subject: [IMPR] use i18n.translate instead of getCommonscatTemplate class method ......................................................................
[IMPR] use i18n.translate instead of getCommonscatTemplate class method
Bug: T219094 Change-Id: Ib6efa9752c8fa8b9323006fd72a38ff4c1a35e6f --- M scripts/commonscat.py 1 file changed, 8 insertions(+), 19 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/commonscat.py b/scripts/commonscat.py index 1be4a49..fc8c86e 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -255,18 +255,6 @@ else: self.addCommonscat(page)
- @classmethod - def getCommonscatTemplate(cls, code=None): - """Get the template name of a site. Expects the site code. - - Return as tuple containing the primary template and its alternatives. - - """ - if code in commonscatTemplates: - return commonscatTemplates[code] - else: - return commonscatTemplates['_default'] - def skipPage(self, page): """Determine if the page should be skipped.""" if page.site.code in ignoreTemplates: @@ -295,8 +283,9 @@ """ self.current_page = page # Get the right templates for this page - primaryCommonscat, commonscatAlternatives = self.getCommonscatTemplate( - page.site.code) + primaryCommonscat, commonscatAlternatives = i18n.translate( + page.site.code, commonscatTemplates, + fallback=i18n.DEFAULT_FALLBACK) commonscatLink = self.getCommonscatLink(page) if commonscatLink: pywikibot.output('Commonscat template is already on ' @@ -421,8 +410,9 @@
@rtype: tuple of (<templatename>, <target>, <linktext>, <note>) """ - primaryCommonscat, commonscatAlternatives = self.getCommonscatTemplate( - wikipediaPage.site.code) + primaryCommonscat, commonscatAlternatives = i18n.translate( + wikipediaPage.site.code, commonscatTemplates, + fallback=i18n.DEFAULT_FALLBACK) commonscatTemplate = '' commonscatTarget = '' commonscatLinktext = '' @@ -541,9 +531,8 @@
if checkcurrent: site = pywikibot.Site() - primaryCommonscat, commonscatAlternatives = \ - CommonscatBot.getCommonscatTemplate( - site.code) + primaryCommonscat, commonscatAlternatives = i18n.translate( + site.code, commonscatTemplates, fallback=i18n.DEFAULT_FALLBACK) template_page = pywikibot.Page(site, 'Template:' + primaryCommonscat) generator = template_page.getReferences(namespaces=14, only_template_inclusion=True)
pywikibot-commits@lists.wikimedia.org