jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/367819 )
Change subject: [IMPR] Handle separate line templates in template.py ......................................................................
[IMPR] Handle separate line templates in template.py
If the option is just `-remove` and the template is on a separate line, it is removed completely with preleading list bullet and/or spaces and also with newline and/or spaces behind. Spaces surrounding the template from both sides are reduced as well
Bug: T140572 Bug: T144145 Change-Id: If26adb367bbf91ba6d3689ac655a0655a99fd823 --- M scripts/template.py 1 file changed, 10 insertions(+), 0 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/scripts/template.py b/scripts/template.py index f44f541..f15b447 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -233,6 +233,16 @@ exceptions['inside-tags'] = ['ref', 'gallery', 'poem', 'pagelist', ] elif self.getOption('remove'): + separate_line_regex = re.compile( + r'^[*#:]* *{0} *\n'.format(templateRegex.pattern), + re.DOTALL | re.MULTILINE) + replacements.append((separate_line_regex, '')) + + spaced_regex = re.compile( + r' +{0} +'.format(templateRegex.pattern), + re.DOTALL) + replacements.append((spaced_regex, ' ')) + replacements.append((templateRegex, '')) else: template = pywikibot.Page(self.site, new, ns=10)
pywikibot-commits@lists.wikimedia.org