def get_release_cache(index, dist_name): if dist_name not in index.distributions.keys(): raise RuntimeError("Unknown release: '{0}'".format(dist_name)) dist = index.distributions[dist_name] if 'release_cache' not in dist.keys(): raise RuntimeError("Release has no cache: '{0}'".format(dist_name)) url = dist['release_cache'] logger.debug('Load cache from "%s"' % url) yaml_str = load_url(url) data = yaml.load(yaml_str) return ReleaseCache(dist_name, data)
def get_release_cache(index, dist_name): if dist_name not in index.distributions.keys(): raise RuntimeError("Unknown release: '{0}'".format(dist_name)) dist = index.distributions[dist_name] if 'release_cache' not in dist.keys(): raise RuntimeError("Release has no cache: '{0}'".format(dist_name)) url = dist['release_cache'] logger.debug('Load cache from "%s"' % url) if url.endswith('.yaml'): yaml_str = load_url(url) elif url.endswith('.yaml.gz'): yaml_gz_str = load_url(url) yaml_gz_stream = StringIO(yaml_gz_str) f = gzip.GzipFile(fileobj=yaml_gz_stream, mode='rb') yaml_str = f.read() f.close() else: raise NotImplementedError('The url of the cache must end with either ".yaml" or ".yaml.gz"') data = yaml.load(yaml_str) return ReleaseCache(dist_name, data)
def get_index(url): logger.debug('Load index from "%s"' % url) yaml_str = load_url(url) data = yaml.load(yaml_str) base_url = os.path.dirname(url) return Index(data, base_url)
def _load_yaml_data(url): logger.debug('Load file from "%s"' % url) yaml_str = load_url(url) return yaml.load(yaml_str)