def _fetch_raw_metadata(api_key, cache, retries, environ):
 for page_number in count(1):
  key = ('metadata-page-%d' % page_number)
  try:
   raw = cache[key]
  except KeyError:
   for _ in range(retries):
    try:
     raw = pd.read_csv(format_metadata_url(api_key, page_number), parse_dates=['oldest_available_date', 'newest_available_date'], usecols=['dataset_code', 'name', 'oldest_available_date', 'newest_available_date'])
     break
    except ValueError:
     raw = pd.DataFrame([])
     break
    except Exception:
     pass
   else:
    raise ValueError(('Failed to download metadata page %d after %d attempts.' % (page_number, retries)))
   cache[key] = raw
  if raw.empty:
   break
  (yield raw)

def _fetch_raw_metadata ( api_key , cache , retries , environ ) : for page_number in count ( 1 ) : key = ( 'metadata-page-%d' % page_number ) try : raw = cache [ key ] except KeyError : for _ in range ( retries ) : try : raw = pd . read_csv ( format_metadata_url ( api_key , page_number ) , parse_dates = [ 'oldest_available_date' , 'newest_available_date' ] , usecols = [ 'dataset_code' , 'name' , 'oldest_available_date' , 'newest_available_date' ] ) break except ValueError : raw = pd . DataFrame ( [ ] ) break except Exception : pass else : raise ValueError ( ( 'Failed to download metadata page %d after %d attempts.' % ( page_number , retries ) ) ) cache [ key ] = raw if raw . empty : break ( yield raw )
generator that yields each page of data from the metadata endpoint as a dataframe .