jenkins-bot merged this change.

View Change

Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
[FIX] Enable additional edit summary for syntax correction

set the right edit summary
- either the summary that the bot corrects the syntax of a <references /> tag
- or the edit summary that the bot adds the <references /> tag

Also improve doc.

Bug: T183856
Change-Id: I2b8296bdd274fdc6ee60f17420020f18737ed288
---
M scripts/noreferences.py
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index f733389..5f609d2 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -498,7 +498,6 @@

self.generator = pagegenerators.PreloadingGenerator(generator)
self.site = pywikibot.Site()
- self.comment = i18n.twtranslate(self.site, 'noreferences-add-tag')

self.refR = _ref_regex
self.referencesR = _references_regex
@@ -544,11 +543,17 @@
Add a references tag into an existing section where it fits into.

If there is no such section, creates a new section containing
- the references tag.
- * Returns : The modified pagetext
+ the references tag. Also repair malformed references tags.
+ Set the edit summary accordingly.

+ @param oldText: page text to be modified
+ @type oldText: str
+ @return: The modified pagetext
+ @rtype: str
"""
# Do we have a malformed <reference> tag which could be repaired?
+ # Set the edit summary for this case
+ self.comment = i18n.twtranslate(self.site, 'noreferences-fix-tag')

# Repair two opening tags or a opening and an empty tag
pattern = re.compile(r'< *references *>(.*?)'
@@ -563,6 +568,8 @@
return re.sub(pattern, '<references />', oldText)

# Is there an existing section where we can add the references tag?
+ # Set the edit summary for this case
+ self.comment = i18n.twtranslate(self.site, 'noreferences-add-tag')
for section in i18n.translate(self.site, referencesSections):
sectionR = re.compile(r'\r?\n=+ *%s *=+ *\r?\n' % section)
index = 0

To view, visit change 210654. To unsubscribe, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2b8296bdd274fdc6ee60f17420020f18737ed288
Gerrit-Change-Number: 210654
Gerrit-PatchSet: 13
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup@gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw@arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus@gmx.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>