jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/387160 )
Change subject: noreferences.py: Make sure there is an empty line before the
references section
......................................................................
noreferences.py: Make sure there is an empty line before the references section
Add param info to the docstring of createReferenceSection.
Add another newline before the ref_section (this is to create an empty line).
Make sure there won't be any extra newlines by rstripping the oldText[:index].
Bug: T179255
Change-Id: Ic3a225f727b658c766b6ec80a5c959a5cda39161
---
M scripts/noreferences.py
1 file changed, 18 insertions(+), 8 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 504c638..9846df2 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -635,16 +635,26 @@
return self.createReferenceSection(oldText, index)
def createReferenceSection(self, oldText, index, ident='=='):
- """Create a reference section and insert it into the given text."""
+ """Create a reference section and insert it into the given text.
+
+ @param oldText: page text that is going to be be amended
+ @type oldText: str
+ @param index: the index of oldText where the reference section should
+ be inserted at
+ @type index: int
+ @param ident: symbols to be inserted before and after reference section
+ title
+ @type ident: str
+ @return: the amended page text with reference section added
+ @rtype: str
+ """
if self.site.code in noTitleRequired:
- newSection = u'\n%s\n' % (self.referencesText)
+ ref_section = '\n\n%s\n' % self.referencesText
else:
- newSection = u'\n%s %s %s\n%s\n' % (ident,
- i18n.translate(
- self.site,
- referencesSections)[0],
- ident, self.referencesText)
- return oldText[:index] + newSection + oldText[index:]
+ ref_section = '\n\n{ident} {title} {ident}\n{text}\n'.format(
+ title=i18n.translate(self.site, referencesSections)[0],
+ ident=ident, text=self.referencesText)
+ return oldText[:index].rstrip() + ref_section + oldText[index:]
def run(self):
"""Run the bot."""
--
To view, visit https://gerrit.wikimedia.org/r/387160
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic3a225f727b658c766b6ec80a5c959a5cda39161
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Magul <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: Zoranzoki21 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits