def _retrieve_discovery_doc(url, http, cache_discovery, cache=None):
 if cache_discovery:
  from . import discovery_cache
  from .discovery_cache import base
  if (cache is None):
   cache = discovery_cache.autodetect()
  if cache:
   content = cache.get(url)
   if content:
    return content
 actual_url = url
 if ('REMOTE_ADDR' in os.environ):
  actual_url = _add_query_parameter(url, 'userIp', os.environ['REMOTE_ADDR'])
 logger.info('URL being requested: GET %s', actual_url)
 (resp, content) = http.request(actual_url)
 if (resp.status >= 400):
  raise HttpError(resp, content, uri=actual_url)
 try:
  content = content.decode('utf-8')
 except AttributeError:
  pass
 try:
  service = json.loads(content)
 except ValueError as e:
  logger.error(('Failed to parse as JSON: ' + content))
  raise InvalidJsonError()
 if (cache_discovery and cache):
  cache.set(url, content)
 return content

def _retrieve_discovery_doc ( url , http , cache_discovery , cache = None ) : if cache_discovery : from . import discovery_cache from . discovery_cache import base if ( cache is None ) : cache = discovery_cache . autodetect ( ) if cache : content = cache . get ( url ) if content : return content actual_url = url if ( 'REMOTE_ADDR' in os . environ ) : actual_url = _add_query_parameter ( url , 'userIp' , os . environ [ 'REMOTE_ADDR' ] ) logger . info ( 'URL being requested: GET %s' , actual_url ) ( resp , content ) = http . request ( actual_url ) if ( resp . status >= 400 ) : raise HttpError ( resp , content , uri = actual_url ) try : content = content . decode ( 'utf-8' ) except AttributeError : pass try : service = json . loads ( content ) except ValueError as e : logger . error ( ( 'Failed to parse as JSON: ' + content ) ) raise InvalidJsonError ( ) if ( cache_discovery and cache ) : cache . set ( url , content ) return content
retrieves the discovery_doc from cache or the internet .