def process_response_as_xml(given_server_response):
'''Retrieves the main dictionary from given response. If not possible, it
uses a blank dictionary. Ensures that some essential keys are set in all cases.'''
# Default:
response_dict = {}
# If response is not None:
if given_server_response:
common.print_info("Processing response for XML content.")
try:
response_dict = plistlib.readPlistFromString(given_server_response.read())
common.print_info("Response is a valid XML property list.")
except xml.parsers.expat.ExpatError, NameError:
common.print_error("Response is not an XML property list!")
# Return:
return response_dict
评论列表
文章目录