kitir/kits/restful_api.py
def _get_content_from_response(cls, response, prefer_json=False):
        """attempts to extract content from response as json, if fails, gets raw content"""
        try:
            content = response.json()
        # except json.JSONDecodeError as jde:
        except ValueError as vexc:
            if not any([ignored_msg in str(vexc) for ignored_msg in cls._ignored_json_convert_error_messages]):
                raise
            elif response.content:
                content = response.content.decode('utf-8', errors='replace')
            else:
                content = None
        else:
            if not prefer_json:
                content = json.dumps(content, indent=4)
        return content
attempts to extract content from response as json, if fails, gets raw content
attempts to extract content from response as json, if fails, gets raw content
attempts to extract content from response as json if fails gets raw content
def _get_content_from_response(cls, response, prefer_json=False):
        try:
            content = response.json()
        except ValueError as vexc:
            if not any([ignored_msg in str(vexc) for ignored_msg in cls._ignored_json_convert_error_messages]):
                raise
            elif response.content:
                content = response.content.decode('utf-8', errors='replace')
            else:
                content = None
        else:
            if not prefer_json:
                content = json.dumps(content, indent=4)
        return content
def _get_content_from_response ( cls , response , prefer_json = False ) : try : content = response . json ( ) except ValueError as vexc : if not any ( [ ignored_msg in str ( vexc ) for ignored_msg in cls . _ignored_json_convert_error_messages ] ) : raise elif response . content : content = response . content . decode ( 'utf-8' , errors = 'replace' ) else : content = None else : if not prefer_json : content = json . dumps ( content , indent = 4 ) return content
attempts to extract content from response as json, if fails, gets raw content
attempts to extract content from response as json if fails gets raw content
"""attempts to extract content from response as json, if fails, gets raw content""" # except json.JSONDecodeError as jde:
cls
response
prefer_json