From 7dbbe0e58d287ae03342c9a9dc5c2209e31c3792 Mon Sep 17 00:00:00 2001 From: Peter Potrebic Date: Sat, 7 Feb 2015 00:27:36 -0800 Subject: [PATCH] Add some missing docstrings. Also use the more expressive "x = a or b" instead of an inline conditional. --- boxsdk/client.py | 12 +++++++++++- boxsdk/exception.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/boxsdk/client.py b/boxsdk/client.py index e82e53574..70518df7a 100644 --- a/boxsdk/client.py +++ b/boxsdk/client.py @@ -18,7 +18,17 @@ class Client(object): def __init__(self, oauth, network_layer=None): - network_layer = network_layer if network_layer else DefaultNetwork() + """ + :param oauth: + OAuth2 object used by the session to authorize requests. + :type oauth: + :class:`OAuth2` + :param network_layer: + The Network layer to use. If none is provided then an instance of :class:`DefaultNetwork` will be used. + :type network_layer: + :class:`Network` + """ + network_layer = network_layer or DefaultNetwork() self._session = BoxSession(oauth=oauth, network_layer=network_layer) def folder(self, folder_id): diff --git a/boxsdk/exception.py b/boxsdk/exception.py index 38c9bd0bd..ae012d7fb 100644 --- a/boxsdk/exception.py +++ b/boxsdk/exception.py @@ -24,6 +24,36 @@ class BoxAPIException(BoxException): Exception raised from the box session layer. """ def __init__(self, status, code=None, message=None, request_id=None, headers=None, url=None, method=None): + """ + :param status: + HTTP status code of the failed response + :type status: + `int` + :param code: + The 'code' field of the failed response + :type code: + `unicode` + :param message: + A message to associate with the exception, e.g. 'message' field of the json in the failed response + :type message: + `unicode` + :param request_id: + The 'request_id' field of the json in the failed response + :type request_id: + `unicode` + :param headers: + The HTTP headers in the failed response + :type headers: + `dict` + :param url: + The url which raised the exception + :type url: + `unicode` + :param method: + The HTTP verb used to make the request. + :type method: + `unicode` + """ super(BoxAPIException, self).__init__() self._status = status self._code = code @@ -94,6 +124,24 @@ class BoxOAuthException(BoxException): Exception raised during auth. """ def __init__(self, status, message=None, url=None, method=None): + """ + :param status: + HTTP status code of the auth response + :type status: + `int` + :param message: + A message to associate with the exception, e.g. HTTP content of the auth response + :type message: + `unicode` + :param url: + The url which raised the exception + :type url: + `unicode` + :param method: + The HTTP verb used to make the request. + :type method: + `unicode` + """ super(BoxOAuthException, self).__init__() self._status = status self._message = message