def _parse_uri_map(cpv, metadata, use=None): myuris = use_reduce(metadata.get('SRC_URI', ''), uselist=use, matchall=(use is None), is_src_uri=True, eapi=metadata['EAPI']) uri_map = OrderedDict() myuris.reverse() while myuris: uri = myuris.pop() if myuris and myuris[-1] == "->": myuris.pop() distfile = myuris.pop() else: distfile = os.path.basename(uri) if not distfile: raise portage.exception.InvalidDependString( ("getFetchMap(): '%s' SRC_URI has no file " + \ "name: '%s'") % (cpv, uri)) uri_set = uri_map.get(distfile) if uri_set is None: uri_set = set() uri_map[distfile] = uri_set uri_set.add(uri) uri = None return uri_map
def _parse_uri_map(cpv, metadata, use=None): myuris = use_reduce(metadata.get('SRC_URI', ''), uselist=use, matchall=(use is None), is_src_uri=True, eapi=metadata['EAPI']) uri_map = OrderedDict() myuris.reverse() while myuris: uri = myuris.pop() if myuris and myuris[-1] == "->": myuris.pop() distfile = myuris.pop() else: distfile = os.path.basename(uri) if not distfile: raise portage.exception.InvalidDependString( ("getFetchMap(): '%s' SRC_URI has no file " + \ "name: '%s'") % (cpv, uri)) uri_set = uri_map.get(distfile) if uri_set is None: # Use OrderedDict to preserve order from SRC_URI # while ensuring uniqueness. uri_set = OrderedDict() uri_map[distfile] = uri_set uri_set[uri] = True # Convert OrderedDicts to tuples. for k, v in uri_map.items(): uri_map[k] = tuple(v) return uri_map
def _parse_uri_map(cpv, metadata, use=None): myuris = use_reduce(metadata.get('SRC_URI', ''), uselist=use, matchall=(use is None), is_src_uri=True, eapi=metadata['EAPI']) uri_map = OrderedDict() myuris.reverse() while myuris: uri = myuris.pop() if myuris and myuris[-1] == "->": myuris.pop() distfile = myuris.pop() else: distfile = os.path.basename(uri) if not distfile: raise portage.exception.InvalidDependString( ("getFetchMap(): '%s' SRC_URI has no file " + \ "name: '%s'") % (cpv, uri)) uri_set = uri_map.get(distfile) if uri_set is None: # Use OrderedDict to preserve order from SRC_URI # while ensuring uniqueness. uri_set = OrderedDict() uri_map[distfile] = uri_set # SRC_URI may contain a file name with no scheme, and in # this case it does not belong in uri_set. if urlparse(uri).scheme: uri_set[uri] = True # Convert OrderedDicts to tuples. for k, v in uri_map.items(): uri_map[k] = tuple(v) return uri_map
def getFetchMap(self, mypkg, useflags=None, mytree=None): """ Get the SRC_URI metadata as a dict which maps each file name to a set of alternative URIs. @param mypkg: cpv for an ebuild @type mypkg: String @param useflags: a collection of enabled USE flags, for evaluation of conditionals @type useflags: set, or None to enable all conditionals @param mytree: The canonical path of the tree in which the ebuild is located, or None for automatic lookup @type mypkg: String @returns: A dict which maps each file name to a set of alternative URIs. @rtype: dict """ try: eapi, myuris = self.aux_get(mypkg, ["EAPI", "SRC_URI"], mytree=mytree) except KeyError: # Convert this to an InvalidDependString exception since callers # already handle it. raise portage.exception.InvalidDependString( "getFetchMap(): aux_get() error reading "+mypkg+"; aborting.") if not eapi_is_supported(eapi): # Convert this to an InvalidDependString exception # since callers already handle it. raise portage.exception.InvalidDependString( "getFetchMap(): '%s' has unsupported EAPI: '%s'" % \ (mypkg, eapi.lstrip("-"))) myuris = paren_reduce(myuris) _src_uri_validate(mypkg, eapi, myuris) myuris = use_reduce(myuris, uselist=useflags, matchall=(useflags is None)) myuris = flatten(myuris) uri_map = OrderedDict() myuris.reverse() while myuris: uri = myuris.pop() if myuris and myuris[-1] == "->": operator = myuris.pop() distfile = myuris.pop() else: distfile = os.path.basename(uri) if not distfile: raise portage.exception.InvalidDependString( ("getFetchMap(): '%s' SRC_URI has no file " + \ "name: '%s'") % (mypkg, uri)) uri_set = uri_map.get(distfile) if uri_set is None: uri_set = set() uri_map[distfile] = uri_set uri_set.add(uri) uri = None operator = None return uri_map