3939 PermissionRequiredError )
4040
4141
42- class Client ( object ) :
42+ class Client :
4343 """Creates a new client object.
4444
4545 It accepts the following required arguments:
@@ -176,10 +176,10 @@ def _handle_success(self, response, uri):
176176 try :
177177 return response .json ()
178178 except ValueError as ex :
179- raise GeoIP2Error ('Received a 200 response for %(uri)s'
180- ' but could not decode the response as '
181- 'JSON: ' % locals () + ', ' . join ( ex . args ), 200 ,
182- uri )
179+ raise GeoIP2Error (
180+ 'Received a 200 response for %(uri)s '
181+ ' but could not decode the response as '
182+ 'JSON: ' % locals () + ', ' . join ( ex . args ), 200 , uri )
183183
184184 def _exception_for_error (self , response , uri ):
185185 status = response .status_code
@@ -192,25 +192,27 @@ def _exception_for_error(self, response, uri):
192192
193193 def _exception_for_4xx_status (self , response , status , uri ):
194194 if not response .content :
195- return HTTPError ('Received a %(status)i error for %(uri)s '
196- 'with no body.' % locals (), status , uri )
195+ return HTTPError (
196+ 'Received a %(status)i error for %(uri)s '
197+ 'with no body.' % locals (), status , uri )
197198 elif response .headers ['Content-Type' ].find ('json' ) == - 1 :
198- return HTTPError ('Received a %i for %s with the following '
199- 'body: %s' % ( status , uri , response . content ),
200- status , uri )
199+ return HTTPError (
200+ 'Received a %i for %s with the following '
201+ 'body: %s' % ( status , uri , response . content ), status , uri )
201202 try :
202203 body = response .json ()
203204 except ValueError as ex :
204205 return HTTPError (
205206 'Received a %(status)i error for %(uri)s but it did'
206- ' not include the expected JSON body: ' % locals () +
207- ', ' . join ( ex .args ), status , uri )
207+ ' not include the expected JSON body: ' % locals () + ', ' . join (
208+ ex .args ), status , uri )
208209 else :
209210 if 'code' in body and 'error' in body :
210211 return self ._exception_for_web_service_error (
211212 body .get ('error' ), body .get ('code' ), status , uri )
212- return HTTPError ('Response contains JSON but it does not specify '
213- 'code or error keys' , status , uri )
213+ return HTTPError (
214+ 'Response contains JSON but it does not specify '
215+ 'code or error keys' , status , uri )
214216
215217 def _exception_for_web_service_error (self , message , code , status , uri ):
216218 if code in ('IP_ADDRESS_NOT_FOUND' , 'IP_ADDRESS_RESERVED' ):
@@ -227,9 +229,11 @@ def _exception_for_web_service_error(self, message, code, status, uri):
227229 return InvalidRequestError (message , code , status , uri )
228230
229231 def _exception_for_5xx_status (self , status , uri ):
230- return HTTPError ('Received a server error (%(status)i) for '
231- '%(uri)s' % locals (), status , uri )
232+ return HTTPError (
233+ 'Received a server error (%(status)i) for '
234+ '%(uri)s' % locals (), status , uri )
232235
233236 def _exception_for_non_200_status (self , status , uri ):
234- return HTTPError ('Received a very surprising HTTP status '
235- '(%(status)i) for %(uri)s' % locals (), status , uri )
237+ return HTTPError (
238+ 'Received a very surprising HTTP status '
239+ '(%(status)i) for %(uri)s' % locals (), status , uri )
0 commit comments