jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/591393 )
Change subject: template.py: Allow users to use safesubst
......................................................................
template.py: Allow users to use safesubst
Bug: T221344
Change-Id: Ib9ca40a45efbf3f8f17c38f46a9652a2d6998f37
---
M scripts/template.py
1 file changed, 13 insertions(+), 10 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/template.py b/scripts/template.py
index 50f02c6..b21581f 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -20,10 +20,10 @@
-subst Resolves the template by putting its text directly into the
article. This is done by changing {{...}} or {{msg:...}} into
- {{subst:...}}.
- Substitution is not available inside <ref>...</ref>,
- <gallery>...</gallery>, <poem>...</poem> and
<pagelist ... />
- tags.
+ {{subst:...}}. If you want to use safesubst, you
+ can do -subst:safe. Substitution is not available inside
+ <ref>...</ref>, <gallery>...</gallery>,
<poem>...</poem>
+ and <pagelist ... /> tags.
-assubst Replaces the first argument as old template with the second
argument as new template but substitutes it like -subst does.
@@ -230,8 +230,9 @@
exceptions['inside-tags'] = ['ref', 'gallery',
'poem',
'pagelist', ]
elif self.getOption('subst'):
- replacements.append((template_regex,
- r'{{subst:%s\g<parameters>}}' % old))
+ replacements.append(
+ (template_regex, r'{{%s:%s\g<parameters>}}' %
+ (self.getOption('subst'), old)))
exceptions['inside-tags'] = ['ref', 'gallery',
'poem',
'pagelist', ]
elif self.getOption('remove'):
@@ -297,10 +298,12 @@
for arg in local_args:
if arg == '-remove':
options['remove'] = True
- elif arg == '-subst':
- options['subst'] = True
+ elif arg.startswith('-subst'):
+ options['subst'] = arg[len('-subst:'):] + 'subst'
+ assert options['subst'] in ('subst', 'safesubst')
elif arg == '-assubst':
- options['subst'] = options['remove'] = True
+ options['subst'] = 'subst'
+ options['remove'] = True
elif arg == '-always':
options['always'] = True
elif arg.startswith('-xml'):
@@ -329,7 +332,7 @@
pywikibot.bot.suggest_help(missing_parameters=['templates'])
return False
- if options.get('subst', False) ^ options.get('remove', False):
+ if bool(options.get('subst', False)) ^ options.get('remove', False):
for template_name in template_names:
templates[template_name] = None
else:
--
To view, visit
https://gerrit.wikimedia.org/r/591393
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: Ib9ca40a45efbf3f8f17c38f46a9652a2d6998f37
Gerrit-Change-Number: 591393
Gerrit-PatchSet: 9
Gerrit-Owner: Urbanecm <martin.urbanec(a)wikimedia.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Urbanecm <martin.urbanec(a)wikimedia.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)