From: Marek Marecki Date: Sat, 6 Apr 2013 10:01:48 +0000 (+0200) Subject: _sessionpost() and _sessiondelete() are now more readable X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7db14a691e5e18bc3a42ec351deaefe74d931984;p=diaspy.git _sessionpost() and _sessiondelete() are now more readable --- diff --git a/diaspy/client.py b/diaspy/client.py index 74a3769..a255a26 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -45,17 +45,21 @@ class Client: :param string: URL to post without the pod's URL and slash eg. 'status_messages'. :type string: str :param data: Data to post. - :param headers: Headers. + :param headers: Headers (optional). :type headers: dict - :param params: Optional parameters. + :param params: Parameters (optional). :type params: dict """ string = '{0}/{1}'.format(self.pod, string) - if headers and params: r = self.session.post(string, data=data, headers=headers, params=params) - elif headers and not params: r = self.session.post(string, data=data, headers=headers) - elif not headers and params: r = self.session.post(string, data=data, params=params) - else: r = self.session.post(string, data=data) - return r + if headers and params: + request = self.session.post(string, data=data, headers=headers, params=params) + elif headers and not params: + request = self.session.post(string, data=data, headers=headers) + elif not headers and params: + request = self.session.post(string, data=data, params=params) + else: + request = self.session.post(string, data=data) + return request def _sessiondelete(self, string, data, headers={}): """This method lets you send delete request to session. @@ -64,11 +68,15 @@ class Client: :param string: URL to use. :type string: str :param data: Data to use. + :param headers: Headers to use (optional). + :type headers: dict """ string = '{0}/{1}'.format(self.pod, string) - if headers: r = self.session.delete(string, data=data, headers=headers) - else: r = self.session.delete(string, data=data) - return r + if headers: + request = self.session.delete(string, data=data, headers=headers) + else: + request = self.session.delete(string, data=data) + return request def get_token(self): """This function gets a token needed for authentication in most cases