jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1325855?usp=email )

Change subject: upload: Reuse warning response data
......................................................................

upload: Reuse warning response data

Store the warning mapping once when handling an upload warning.
Read the first warning directly from its item iterator.

Change-Id: I7c020c3091558f7fb93922ca58bb237863982cc7
---
M pywikibot/site/_upload.py
1 file changed, 4 insertions(+), 5 deletions(-)

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




diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py
index 2301296..030f5d0 100644
--- a/pywikibot/site/_upload.py
+++ b/pywikibot/site/_upload.py
@@ -460,6 +460,7 @@

             if result['result'] == 'Warning':
                 assert 'warnings' in result and not ignore_all_warnings
+                warnings = result['warnings']

                 if self.filename:
                     if 'filekey' in result:
@@ -487,13 +488,11 @@
                                             offset=offset)
                     return False

-                if len(result['warnings']) > 1:
+                if len(warnings) > 1:
                     warn('The upload returned {} warnings: {}'
-                         .format(len(result['warnings']),
-                                 ', '.join(result['warnings'])),
+                         .format(len(warnings), ', '.join(warnings)),
                          UserWarning, 3)
-                warning = list(result['warnings'].keys())[0]
-                message = result['warnings'][warning]
+                warning, message = next(iter(warnings.items()))
                 warning = warning_keys.get(warning, warning)
                 raise UploadError(warning,
                                   self.upload_warnings[warning]

-- 
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1325855?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7c020c3091558f7fb93922ca58bb237863982cc7
Gerrit-Change-Number: 1325855
Gerrit-PatchSet: 1
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to