From 0d7caab804cd13c0d1db6bf360471315a2ff80f0 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh <bryan.tongminh@gmail.com> Date: Thu, 27 Aug 2009 20:23:42 +0000 Subject: [PATCH] Return the upload part of the dict only. --- mwclient/client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mwclient/client.py b/mwclient/client.py index e98afee..cfb6277 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -143,12 +143,15 @@ class Site(object): while True: info = self.raw_api(action, **kwargs) if not info: info = {} - res = self.handle_api_result(info) + res = self.handle_api_result(info, token = token) if res: return info - def handle_api_result(self, info, kwargs = None): + def handle_api_result(self, info, kwargs = None, token = None): + if token is None: + token = self.wait_token() + try: userinfo = compatibility.userinfo(info, self.require(1, 12, raise_error = None)) except KeyError: @@ -361,7 +364,7 @@ class Site(object): if not info: info = {} if self.handle_api_result(info): - return info + return info.get('upload', {}) except errors.HTTPStatusError, e: if e[0] == 503 and e[1].getheader('X-Database-Lag'): self.wait(wait_token, int(e[1].getheader('Retry-After'))) -- GitLab