@@ -221,6 +221,7 @@ def _elems_to_objs(self, elems):
221
221
yield self ._elem_to_obj (elem )
222
222
223
223
def _elem_to_obj (self , elem ):
224
+ """Convert a single XML element to a single Python object"""
224
225
if not self .returns_elements :
225
226
raise RuntimeError ("Incorrect call to method when 'returns_elements' is False" )
226
227
raise NotImplementedError ()
@@ -335,7 +336,7 @@ def _get_elements(self, payload):
335
336
self .stop_streaming ()
336
337
337
338
def _handle_response_cookies (self , session ):
338
- pass
339
+ """Code to react on response cookies"""
339
340
340
341
def _get_response (self , payload , api_version ):
341
342
"""Send the actual HTTP request and get the response."""
@@ -375,13 +376,13 @@ def _api_versions_to_try(self):
375
376
v for v in self .supported_api_versions () if v != self ._version_hint .api_version
376
377
)
377
378
378
- def _get_response_xml (self , payload , ** parse_opts ):
379
+ def _get_response_xml (self , payload ):
379
380
"""Send the payload to the server and return relevant elements from the result. Several things happen here:
380
- * The payload is wrapped in SOAP headers and sent to the server
381
- * The Exchange API version is negotiated and stored in the protocol object
382
- * Connection errors are handled and possibly reraised as ErrorServerBusy
383
- * SOAP errors are raised
384
- * EWS errors are raised, or passed on to the caller
381
+ * Wraps the payload is wrapped in SOAP headers and sends to the server
382
+ * Negotiates the Exchange API version and stores it in the protocol object
383
+ * Handles connection errors and possibly re-raises them as ErrorServerBusy
384
+ * Raises SOAP errors
385
+ * Raises EWS errors or passes them on to the caller
385
386
386
387
:param payload: The request payload, as an XML object
387
388
:return: A generator of XML objects or None if the service does not return a result
@@ -397,15 +398,15 @@ def _get_response_xml(self, payload, **parse_opts):
397
398
# Let 'requests' decode raw data automatically
398
399
r .raw .decode_content = True
399
400
try :
400
- header , body = self ._get_soap_parts (response = r , ** parse_opts )
401
+ header , body = self ._get_soap_parts (response = r )
401
402
except Exception :
402
403
r .close () # Release memory
403
404
raise
404
405
# The body may contain error messages from Exchange, but we still want to collect version info
405
406
if header is not None :
406
- self ._update_api_version (api_version = api_version , header = header , ** parse_opts )
407
+ self ._update_api_version (api_version = api_version , header = header )
407
408
try :
408
- return self ._get_soap_messages (body = body , ** parse_opts )
409
+ return self ._get_soap_messages (body = body )
409
410
except (
410
411
ErrorInvalidServerVersion ,
411
412
ErrorIncorrectSchemaVersion ,
@@ -438,7 +439,7 @@ def _handle_backoff(self, e):
438
439
self .protocol .retry_policy .back_off (e .back_off )
439
440
# We'll warn about this later if we actually need to sleep
440
441
441
- def _update_api_version (self , api_version , header , ** parse_opts ):
442
+ def _update_api_version (self , api_version , header ):
442
443
"""Parse the server version contained in SOAP headers and update the version hint stored by the caller, if
443
444
necessary.
444
445
"""
@@ -471,7 +472,7 @@ def _response_message_tag(cls):
471
472
return f"{{{ MNS } }}{ cls .SERVICE_NAME } ResponseMessage"
472
473
473
474
@classmethod
474
- def _get_soap_parts (cls , response , ** parse_opts ):
475
+ def _get_soap_parts (cls , response ):
475
476
"""Split the SOAP response into its headers and body elements."""
476
477
try :
477
478
root = to_xml (response .iter_content ())
@@ -486,7 +487,7 @@ def _get_soap_parts(cls, response, **parse_opts):
486
487
raise MalformedResponseError ("No Body element in SOAP response" )
487
488
return header , body
488
489
489
- def _get_soap_messages (self , body , ** parse_opts ):
490
+ def _get_soap_messages (self , body ):
490
491
"""Return the elements in the response containing the response messages. Raises any SOAP exceptions."""
491
492
response = body .find (self ._response_tag ())
492
493
if response is None :
0 commit comments