def wrapper(obj, *args, **kwargs): result = f(obj, *args, **kwargs) if isinstance(result, response_class): return result try: return response_class(result.text) except Exception: logger.debug("Exception during response parsing.", exc_info=True) raise APIError("Exception during response parsing")
def wrapper(obj, *args, **kwargs): simple_response = obj._SIMPLE_RESPONSES or kwargs.pop( "SIMPLE_RESPONSES", kwargs.pop("SIMPLE_RESPONSE", False) ) response = f(obj, *args, **kwargs) try: if isinstance(response, response_class): return response else: try: result = response.json() except AttributeError: # just in case the requests package is old and doesn't contain json() result = loads(response.text) if simple_response: return result return response_class(result, obj) except Exception as e: logger.debug("Exception during response parsing.", exc_info=True) raise APIError("Exception during response parsing. Error: %s" % repr(e))