def extractSuccessfulJSONResult(response):
 result = readBody(response)
 result.addCallback(loads)
 def getResult(data):
  if (response.code > 299):
   raise AssertionError((response.code, data))
  return data
 result.addCallback(getResult)
 return result

def extractSuccessfulJSONResult ( response ) : result = readBody ( response ) result . addCallback ( loads ) def getResult ( data ) : if ( response . code > 299 ) : raise AssertionError ( ( response . code , data ) ) return data result . addCallback ( getResult ) return result
extract a successful api result from a http response .