jenkins-bot has submitted this change and it was merged.
Change subject: archivebot: allow the config template written with canonical namespace ......................................................................
archivebot: allow the config template written with canonical namespace
* both English and localized (canonical) namespace are supported * when rewriting the header, the bot will canonicalize the template name
Change-Id: I0229ab67d7fcea7007054d249112a818b5ff4e9c --- M scripts/archivebot.py 1 file changed, 11 insertions(+), 5 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py index e0e607e..2898e14 100644 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -397,10 +397,10 @@ 'counter': ['1', False], 'key': ['', False], } - self.tpl = tpl self.salt = salt self.force = force self.site = page.site + self.tpl = pywikibot.Page(self.site, tpl) self.timestripper = TimeStripper(site=self.site) self.page = DiscussionPage(page, self) self.load_config() @@ -427,7 +427,7 @@
def attr2text(self): return '{{%s\n%s\n}}' \ - % (self.tpl, + % (self.tpl.title(), '\n'.join(['|%s = %s' % (a, self.get_attr(a)) for a in self.saveables()]))
@@ -438,9 +438,9 @@ return self.get_attr('key') == s.hexdigest()
def load_config(self): - pywikibot.output(u'Looking for: {{%s}} in %s' % (self.tpl, self.page)) + pywikibot.output(u'Looking for: {{%s}} in %s' % (self.tpl.title(), self.page)) for tpl in self.page.templatesWithParams(): - if tpl[0] == pywikibot.Page(self.site, self.tpl, ns=10): + if tpl[0] == pywikibot.Page(self.site, self.tpl.title(), ns=10): for param in tpl[1]: item, value = param.split('=', 1) self.set_attr(item.strip(), value.strip()) @@ -535,7 +535,12 @@ self.archives[a].update(comment)
# Save the page itself - rx = re.compile('{{' + self.tpl + '\n.*?\n}}', re.DOTALL) + rx = re.compile(r"{{(?:%s)?:?%s\n.*?\n}}" % (u'|'.join( + set(self.site.namespaces[self.tpl.namespace()])), + re.escape(self.tpl.title(withNamespace=False))), re.DOTALL) + if not rx.search(self.page.header): + pywikibot.error("Couldn't find the template in the header") + return self.page.header = rx.sub(self.attr2text(), self.page.header) self.comment_params['count'] = self.archived_threads self.comment_params['archives'] \ @@ -627,6 +632,7 @@
for a in args: pagelist = [] + a = pywikibot.Page(site, a, ns=10).title() if not filename and not pagename: if namespace is not None: ns = [str(namespace)]
pywikibot-commits@lists.wikimedia.org