jenkins-bot merged this change.

View Change

Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
[IMPR] upload.py: Allow to use a file for description

Creation of the -descriptionfile: argument

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

diff --git a/scripts/upload.py b/scripts/upload.py
index f729d51..8e81522 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -33,6 +33,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.
+ -descfile: 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 @@
#
from __future__ import absolute_import, unicode_literals

+import codecs
import math
import os
import re
@@ -114,6 +116,7 @@
chunk_size_regex = re.compile(
r'^-chunked(?::(\d+(?:\.\d+)?)[ \t]*(k|ki|m|mi)?b?)?$', re.I)
recursive = False
+ description_file = None

# process all global bot args
# returns a list of non-global args, i.e. args for upload.py
@@ -149,13 +152,25 @@
elif arg == '-chunked':
match = chunk_size_regex.match(option)
chunk_size = get_chunk_size(match)
+ elif arg == '-descfile':
+ description_file = value
elif arg and not value:
if not url:
url = arg
else:
description.append(arg)

- description = u' '.join(description)
+ description = ' '.join(description)
+
+ if description_file:
+ if description:
+ pywikibot.error('Both a description and a -descfile were '
+ 'provided. Please specify only one of those.')
+ return False
+ with codecs.open(description_file,
+ encoding=pywikibot.config.textfile_encoding) as f:
+ description = f.read().replace('\r\n', '\n')
+
while not ("://" in url or os.path.exists(url)):
if not url:
error = 'No input filename given.'

To view, visit change 374088. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia30bba7b19a70168485b554ea1dadfaba81caee4
Gerrit-Change-Number: 374088
Gerrit-PatchSet: 15
Gerrit-Owner: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot