Framawiki has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374088 )

Change subject: [IMPR] upload.py: Allow to use a file for description
......................................................................

[IMPR] upload.py: Allow to use a file for description

Bug: T170125
Change-Id: Ia30bba7b19a70168485b554ea1dadfaba81caee4
---
M scripts/upload.py
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/88/374088/1

diff --git a/scripts/upload.py b/scripts/upload.py
index 9c27b78..5650e79 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -30,6 +30,7 @@
   -recursive    When the filename is a directory it also uploads the files from
                 the subdirectories.
   -summary      Pick a custom edit summary for the bot.
+  -descriptionfile  Specify a filename where the description is stored
 
 It is possible to combine -abortonwarn and -ignorewarn so that if the specific
 warning is given it won't apply the general one but more specific one. So if it
@@ -57,6 +58,7 @@
 import math
 import os
 import re
+import codecs
 
 import pywikibot
 from pywikibot.bot import suggest_help
@@ -85,6 +87,7 @@
     chunk_size_regex = r'^-chunked(?::(\d+(?:\.\d+)?)[ \t]*(k|ki|m|mi)?b?)?$'
     chunk_size_regex = re.compile(chunk_size_regex, re.I)
     recursive = False
+    descriptionFile = None
 
     # process all global bot args
     # returns a list of non-global args, i.e. args for upload.py
@@ -138,6 +141,8 @@
                         chunk_size = 1 << 20  # default to 1 MiB
                 else:
                     pywikibot.error('Chunk size parameter is not valid.')
+            elif arg.startswith('-descriptionfile:'):
+                descriptionFile = arg[len('-descriptionfile:'):]
             elif url == u'':
                 url = arg
             else:
@@ -156,6 +161,9 @@
         else:
             pywikibot.output(error)
         url = pywikibot.input(u'URL, file or directory where files are now:')
+    if descriptionFile:
+        with codecs.open(descriptionFile, encoding='utf-8') as f:
+            description = '\n'.join(f.readlines())
     if always and ((aborts is not True and ignorewarn is not True) or
                    not description or url is None):
         additional = ''

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia30bba7b19a70168485b554ea1dadfaba81caee4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Framawiki <framaw...@tools.wmflabs.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to