1313# under the License.
1414#
1515
16- """
17- Exception definitions.
18- """
16+ """Exception definitions."""
1917
2018
2119class CommandError (Exception ):
@@ -27,8 +25,7 @@ class AuthorizationFailure(Exception):
2725
2826
2927class NoTokenLookupException (Exception ):
30- """This form of authentication does not support looking up
31- endpoints from an existing token."""
28+ """This does not support looking up endpoints from an existing token."""
3229 pass
3330
3431
@@ -38,15 +35,12 @@ class EndpointNotFound(Exception):
3835
3936
4037class UnsupportedVersion (Exception ):
41- """Indicates that the user is trying to use an unsupported
42- version of the API"""
38+ """The user is trying to use an unsupported version of the API"""
4339 pass
4440
4541
4642class ClientException (Exception ):
47- """
48- The base exception class for all exceptions this library raises.
49- """
43+ """The base exception class for all exceptions this library raises."""
5044 def __init__ (self , code , message = None , details = None ):
5145 self .code = code
5246 self .message = message or self .__class__ .message
@@ -57,59 +51,44 @@ def __str__(self):
5751
5852
5953class BadRequest (ClientException ):
60- """
61- HTTP 400 - Bad request: you sent some malformed data.
62- """
54+ """HTTP 400 - Bad request: you sent some malformed data."""
6355 http_status = 400
6456 message = "Bad request"
6557
6658
6759class Unauthorized (ClientException ):
68- """
69- HTTP 401 - Unauthorized: bad credentials.
70- """
60+ """HTTP 401 - Unauthorized: bad credentials."""
7161 http_status = 401
7262 message = "Unauthorized"
7363
7464
7565class Forbidden (ClientException ):
76- """
77- HTTP 403 - Forbidden: your credentials don't give you access to this
78- resource.
79- """
66+ """HTTP 403 - Forbidden: not authorized to access to this resource."""
8067 http_status = 403
8168 message = "Forbidden"
8269
8370
8471class NotFound (ClientException ):
85- """
86- HTTP 404 - Not found
87- """
72+ """HTTP 404 - Not found"""
8873 http_status = 404
8974 message = "Not found"
9075
9176
9277class Conflict (ClientException ):
93- """
94- HTTP 409 - Conflict
95- """
78+ """HTTP 409 - Conflict"""
9679 http_status = 409
9780 message = "Conflict"
9881
9982
10083class OverLimit (ClientException ):
101- """
102- HTTP 413 - Over limit: you're over the API limits for this time period.
103- """
84+ """HTTP 413 - Over limit: reached the API limits for this time period."""
10485 http_status = 413
10586 message = "Over limit"
10687
10788
10889# NotImplemented is a python keyword.
10990class HTTPNotImplemented (ClientException ):
110- """
111- HTTP 501 - Not Implemented: the server does not support this operation.
112- """
91+ """HTTP 501 - Not Implemented: server does not support this operation."""
11392 http_status = 501
11493 message = "Not Implemented"
11594
@@ -120,14 +99,18 @@ class HTTPNotImplemented(ClientException):
12099# for c in ClientException.__subclasses__())
121100#
122101# Instead, we have to hardcode it:
123- _code_map = dict ((c .http_status , c ) for c in [BadRequest , Unauthorized ,
124- Forbidden , NotFound , OverLimit , HTTPNotImplemented ])
102+ _code_map = dict ((c .http_status , c ) for c in [
103+ BadRequest ,
104+ Unauthorized ,
105+ Forbidden ,
106+ NotFound ,
107+ OverLimit ,
108+ HTTPNotImplemented
109+ ])
125110
126111
127112def from_response (response , body ):
128- """
129- Return an instance of a ClientException or subclass
130- based on an httplib2 response.
113+ """Return an instance of a ClientException based on an httplib2 response.
131114
132115 Usage::
133116
0 commit comments