Dalba has uploaded a new change for review. ( 
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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/60/387160/1

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: newchange
Gerrit-Change-Id: Ic3a225f727b658c766b6ec80a5c959a5cda39161
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to