jenkins-bot has submitted this change and it was merged.

Change subject: [FIX] Sensible error message when no text to add was given
......................................................................


[FIX] Sensible error message when no text to add was given

Change-Id: I86c3bd796db9d335e2a860784d7c483ca374c053
---
M scripts/add_text.py
1 file changed, 5 insertions(+), 3 deletions(-)

Approvals:
  Mpaa: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/add_text.py b/scripts/add_text.py
index 00c9837..77e73eb 100644
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -341,9 +341,11 @@
         else:
             genFactory.handleArg(arg)
     if textfile and not addText:
-        f = codecs.open(textfile, 'r', config.textfile_encoding)
-        addText = f.read()
-        f.close()
+        with codecs.open(textfile, 'r', config.textfile_encoding) as f:
+            addText = f.read()
+    if not addText:
+        pywikibot.error("The text to add wasn't given.")
+        return
     if not generator:
         generator = genFactory.getCombinedGenerator()
     if not generator:

-- 
To view, visit https://gerrit.wikimedia.org/r/156555
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I86c3bd796db9d335e2a860784d7c483ca374c053
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to