From 0aa748f8f14545228437a106ca7e59c9ad54add2 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh <bryan.tongminh@gmail.com> Date: Thu, 30 Aug 2012 21:17:03 +0000 Subject: [PATCH] Allow setting both the upload description and the page content separately --- mwclient/RELEASE-NOTES.txt | 2 +- mwclient/client.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mwclient/RELEASE-NOTES.txt b/mwclient/RELEASE-NOTES.txt index 9b66adb..6491011 100644 --- a/mwclient/RELEASE-NOTES.txt +++ b/mwclient/RELEASE-NOTES.txt @@ -3,7 +3,7 @@ RELEASE NOTES FOR MWCLIENT This is mwclient 0.6.6. The following are the release notes for this version. == Changes in version 0.6.6 == -No changes yet. +* Allow setting both the upload description and the page content separately == Changes in version 0.6.5 == * Explicitly convert the Content-Length header to str, avoiding a TypeError diff --git a/mwclient/client.py b/mwclient/client.py index 6dc7235..ccf1793 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -353,7 +353,7 @@ class Site(object): def upload(self, file = None, filename = None, description = '', ignore = False, file_size = None, - url = None, session_key = None): + url = None, session_key = None, comment = None): """Upload a file to the wiki.""" if self.version[:2] < (1, 16): return compatibility.old_upload(self, file = file, filename = filename, @@ -368,7 +368,12 @@ class Site(object): predata = {} - predata['comment'] = description + if comment is None: + predata['comment'] = description + else: + predata['comment'] = comment + predata['text'] = description + if ignore: predata['ignorewarnings'] = 'true' predata['token'] = image.get_token('edit') -- GitLab