예제 #1
0
 def get_request_data(response: Response) -> JsonType:
     try:
         response_yaml = yaml.load(response.text)
     except yaml.YAMLError as error:
         LOG.error("Unable to parse response data to yaml. data=%s", response.text)
         raise ResponseParseError(
             f"Unable to parse response data to yaml. data='{response.text}'"
         ) from error
     return response_yaml
예제 #2
0
 def get_request_data(response: Response) -> XmlType:
     try:
         xml_element = ElementTree.fromstring(response.text)
     except ElementTree.ParseError as error:
         LOG.error("Unable to parse response data to xml. data=%s", response.text)
         raise ResponseParseError(
             f"Unable to parse response data to xml. data='{response.text}'"
         ) from error
     return xml_element
예제 #3
0
 def get_request_data(response: Response) -> JsonType:
     try:
         response_json = response.json()
     except JSONDecodeError as error:
         LOG.error("Unable to decode response data to json. data=%s",
                   response.text)
         raise ResponseParseError(
             f"Unable to decode response data to json. data='{response.text}'"
         ) from error
     return response_json
예제 #4
0
    def get_request_data(response: Response) -> JsonType:
        deprecation_warning(
            "YamlResponseHandler will be removed in version 1.3.0")

        try:
            response_yaml = yaml.load(response.text)
        except yaml.YAMLError as error:
            raise ResponseParseError(
                f"Unable to parse response data to yaml. data='{response.text}'"
            ) from error
        return response_yaml
예제 #5
0
    def get_request_data(response: Response) -> Optional[XmlType]:
        if response.text == "":
            return None

        try:
            xml_element = ElementTree.fromstring(response.text)
        except ElementTree.ParseError as error:
            raise ResponseParseError(
                f"Unable to parse response data to xml. data='{response.text}'"
            ) from error
        return xml_element
예제 #6
0
    def get_request_data(response: Response) -> Optional[JsonType]:
        if response.text == "":
            return None

        try:
            response_json = response.json()
        except JSONDecodeError as error:
            raise ResponseParseError(
                f"Unable to decode response data to json. data='{response.text}'"
            ) from error
        return response_json