jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/445942 )
Change subject: [bugfix] Allow different projects to have different L10N entries
......................................................................
[bugfix] Allow different projects to have different L10N entries
- i18n.translate is used to get the L10N message for a project but in
initialzer a single <dict>.get() was used which cannot extract xdict
settings. This patch uses i18n.translate to get the localizes entry,
stores it as a bot attribute and confirms in the initializer if the
script is localized for the given project.
Bug: T198889
Change-Id: I3022df047a46d4ea43ae66a3459ab1cc93b69d31
---
M scripts/clean_sandbox.py
1 file changed, 11 insertions(+), 12 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index b5d527b..c2acb17 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -143,7 +143,9 @@
self.availableOptions['delay_td'] = datetime.timedelta(minutes=d)
self.site = pywikibot.Site()
- if not content.get(self.site.code) and not self.getOption('text'):
+ self.translated_content = self.getOption('text') or i18n.translate(
+ self.site, content)
+ if not self.translated_content:
pywikibot.error(u'No content is given for pages, exiting.')
raise RuntimeError
if not self.generator:
@@ -172,26 +174,23 @@
% sandbox_page.title(as_link=True))
try:
text = sandbox_page.text
- if not self.getOption('text'):
- translated_content = i18n.translate(self.site, content)
- else:
- translated_content = self.getOption('text')
if self.getOption('summary'):
translated_msg = self.getOption('summary')
else:
translated_msg = i18n.twtranslate(
self.site, 'clean_sandbox-cleaned')
- subst = 'subst:' in translated_content
- pos = text.find(translated_content.strip())
- if text.strip() == translated_content.strip():
+ subst = 'subst:' in self.translated_content
+ pos = text.find(self.translated_content.strip())
+ if text.strip() == self.translated_content.strip():
pywikibot.output(
u'The sandbox is still clean, no change necessary.')
elif subst and sandbox_page.userName() == self.site.user():
pywikibot.output(
u'The sandbox might be clean, no change necessary.')
elif pos != 0 and not subst:
- sandbox_page.put(translated_content, translated_msg)
- pywikibot.showDiff(text, translated_content)
+ sandbox_page.put(self.translated_content,
+ translated_msg)
+ pywikibot.showDiff(text, self.translated_content)
pywikibot.output(u'Standard content was changed, '
u'sandbox cleaned.')
else:
@@ -201,8 +200,8 @@
# Is the last edit more than 'delay' minutes ago?
if delta <= datetime.timedelta(0):
sandbox_page.put(
- translated_content, translated_msg)
- pywikibot.showDiff(text, translated_content)
+ self.translated_content, translated_msg)
+ pywikibot.showDiff(text, self.translated_content)
pywikibot.output(u'Standard content was changed, '
u'sandbox cleaned.')
else: # wait for the rest
--
To view, visit
https://gerrit.wikimedia.org/r/445942
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3022df047a46d4ea43ae66a3459ab1cc93b69d31
Gerrit-Change-Number: 445942
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: MarcoAurelio <maurelio(a)tools.wmflabs.org>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot