当前位置: 首页>>代码示例>>Python>>正文


Python ExtendedAtomDict.setdefault方法代码示例

本文整理汇总了Python中portage.dep.ExtendedAtomDict.setdefault方法的典型用法代码示例。如果您正苦于以下问题:Python ExtendedAtomDict.setdefault方法的具体用法?Python ExtendedAtomDict.setdefault怎么用?Python ExtendedAtomDict.setdefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在portage.dep.ExtendedAtomDict的用法示例。


在下文中一共展示了ExtendedAtomDict.setdefault方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MaskManager

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
class MaskManager(object):

	def __init__(self, pmask_locations, abs_user_config, user_config=True):
		self._punmaskdict = ExtendedAtomDict(list)
		self._pmaskdict = ExtendedAtomDict(list)

		pkgmasklines = []
		pkgunmasklines = []
		for x in pmask_locations:
			pkgmasklines.append(grabfile_package(
				os.path.join(x, "package.mask"), recursive=1))
			pkgunmasklines.append(grabfile_package(
				os.path.join(x, "package.unmask"), recursive=1))

		if user_config:
			pkgmasklines.append(grabfile_package(
				os.path.join(abs_user_config, "package.mask"), recursive=1, allow_wildcard=True))
			pkgunmasklines.append(grabfile_package(
				os.path.join(abs_user_config, "package.unmask"), recursive=1, allow_wildcard=True))

		pkgmasklines = stack_lists(pkgmasklines, incremental=1)
		pkgunmasklines = stack_lists(pkgunmasklines, incremental=1)

		for x in pkgmasklines:
			self._pmaskdict.setdefault(x.cp, []).append(x)

		for x in pkgunmasklines:
			self._punmaskdict.setdefault(x.cp, []).append(x)

	def getMaskAtom(self, cpv, slot):
		"""
		Take a package and return a matching package.mask atom, or None if no
		such atom exists or it has been cancelled by package.unmask. PROVIDE
		is not checked, so atoms will not be found for old-style virtuals.

		@param cpv: The package name
		@type cpv: String
		@param slot: The package's slot
		@type slot: String
		@rtype: String
		@return: An matching atom string or None if one is not found.
		"""

		cp = cpv_getkey(cpv)
		mask_atoms = self._pmaskdict.get(cp)
		if mask_atoms:
			pkg_list = ["%s:%s" % (cpv, slot)]
			unmask_atoms = self._punmaskdict.get(cp)
			for x in mask_atoms:
				if not match_from_list(x, pkg_list):
					continue
				if unmask_atoms:
					for y in unmask_atoms:
						if match_from_list(y, pkg_list):
							return None
				return x
		return None
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:59,代码来源:MaskManager.py

示例2: _parse_user_files_to_extatomdict

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
	def _parse_user_files_to_extatomdict(self, file_name, location, user_config):
		ret = ExtendedAtomDict(dict)
		if user_config:
			pusedict = grabdict_package(
				os.path.join(location, file_name),
				recursive=1, newlines=1, allow_wildcard=True,
				allow_repo=True, verify_eapi=False,
				allow_build_id=True, allow_use=False)
			for k, v in pusedict.items():
				l = []
				use_expand_prefix = ''
				for flag in v:
					if flag == "\n":
						use_expand_prefix = ""
						continue
					if flag[-1] == ":":
						use_expand_prefix = flag[:-1].lower() + "_"
						continue
					if flag[0] == "-":
						nv = "-" + use_expand_prefix + flag[1:]
					else:
						nv = use_expand_prefix + flag
					l.append(nv)
				ret.setdefault(k.cp, {})[k] = tuple(l)

		return ret
开发者ID:gentoo,项目名称:portage,代码行数:28,代码来源:UseManager.py

示例3: _parse_user_files_to_extatomdict

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
	def _parse_user_files_to_extatomdict(self, file_name, location, user_config):
		ret = ExtendedAtomDict(dict)
		if user_config:
			pusedict = grabdict_package(
				os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
			for k, v in pusedict.items():
				ret.setdefault(k.cp, {})[k] = tuple(v)

		return ret
开发者ID:devurandom,项目名称:portage,代码行数:11,代码来源:UseManager.py

示例4: testExtendedAtomDict

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
	def testExtendedAtomDict(self):
		d = ExtendedAtomDict(dict)
		d["*/*"] = { "test1": "x" }
		d["dev-libs/*"] = { "test2": "y" }
		d.setdefault("sys-apps/portage", {})["test3"] = "z"
		self.assertEqual(d.get("dev-libs/A"), { "test1": "x", "test2": "y" })
		self.assertEqual(d.get("sys-apps/portage"), { "test1": "x", "test3": "z" })
		self.assertEqual(d["dev-libs/*"], { "test2": "y" })
		self.assertEqual(d["sys-apps/portage"], {'test1': 'x', 'test3': 'z'})
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:11,代码来源:testExtendedAtomDict.py

示例5: _parse_file_to_dict

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
 def _parse_file_to_dict(self, file_name, juststrings=False, recursive=True, eapi_filter=None, user_config=False):
     ret = {}
     location_dict = {}
     eapi = read_corresponding_eapi_file(file_name, default=None)
     if eapi is None and not user_config:
         eapi = "0"
     if eapi is None:
         ret = ExtendedAtomDict(dict)
     else:
         ret = {}
     file_dict = grabdict_package(
         file_name,
         recursive=recursive,
         allow_wildcard=(eapi is None),
         allow_repo=(eapi is None),
         verify_eapi=(eapi is not None),
     )
     if eapi is not None and eapi_filter is not None and not eapi_filter(eapi):
         if file_dict:
             writemsg(
                 _("--- EAPI '%s' does not support '%s': '%s'\n") % (eapi, os.path.basename(file_name), file_name),
                 noiselevel=-1,
             )
         return ret
     useflag_re = _get_useflag_re(eapi)
     for k, v in file_dict.items():
         useflags = []
         for prefixed_useflag in v:
             if prefixed_useflag[:1] == "-":
                 useflag = prefixed_useflag[1:]
             else:
                 useflag = prefixed_useflag
             if useflag_re.match(useflag) is None:
                 writemsg(
                     _("--- Invalid USE flag for '%s' in '%s': '%s'\n") % (k, file_name, prefixed_useflag),
                     noiselevel=-1,
                 )
             else:
                 useflags.append(prefixed_useflag)
         location_dict.setdefault(k, []).extend(useflags)
     for k, v in location_dict.items():
         if juststrings:
             v = " ".join(v)
         else:
             v = tuple(v)
         ret.setdefault(k.cp, {})[k] = v
     return ret
开发者ID:rafaelmartins,项目名称:portage,代码行数:49,代码来源:UseManager.py

示例6: PackageSet

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]

#.........这里部分代码省略.........
        for a in atoms:
            if not isinstance(a, Atom):
                if isinstance(a, basestring):
                    a = a.strip()
                if not a:
                    continue
                try:
                    a = Atom(a, allow_wildcard=True, allow_repo=True)
                except InvalidAtom:
                    self._nonatoms.add(a)
                    continue
            if not self._allow_wildcard and a.extended_syntax:
                raise InvalidAtom("extended atom syntax not allowed here")
            if not self._allow_repo and a.repo:
                raise InvalidAtom("repository specification not allowed here")
            self._atoms.add(a)

        self._updateAtomMap()

    def load(self):
        # This method must be overwritten by subclasses
        # Editable sets should use the value of self._mtime to determine if they
        # need to reload themselves
        raise NotImplementedError()

    def containsCPV(self, cpv):
        self._load()
        for a in self._atoms:
            if match_from_list(a, [cpv]):
                return True
        return False

    def getMetadata(self, key):
        if hasattr(self, key.lower()):
            return getattr(self, key.lower())
        else:
            return ""

    def _updateAtomMap(self, atoms=None):
        """Update self._atommap for specific atoms or all atoms."""
        if not atoms:
            self._atommap.clear()
            atoms = self._atoms
        for a in atoms:
            self._atommap.setdefault(a.cp, set()).add(a)

            # Not sure if this one should really be in PackageSet

    def findAtomForPackage(self, pkg, modified_use=None):
        """Return the best match for a given package from the arguments, or
		None if there are no matches.  This matches virtual arguments against
		the PROVIDE metadata.  This can raise an InvalidDependString exception
		if an error occurs while parsing PROVIDE."""

        if modified_use is not None and modified_use is not pkg.use.enabled:
            pkg = pkg.copy()
            pkg._metadata["USE"] = " ".join(modified_use)

            # Atoms matched via PROVIDE must be temporarily transformed since
            # match_from_list() only works correctly when atom.cp == pkg.cp.
        rev_transform = {}
        for atom in self.iterAtomsForPackage(pkg):
            if atom.cp == pkg.cp:
                rev_transform[atom] = atom
            else:
                rev_transform[Atom(atom.replace(atom.cp, pkg.cp, 1), allow_wildcard=True, allow_repo=True)] = atom
        best_match = best_match_to_list(pkg, iter(rev_transform))
        if best_match:
            return rev_transform[best_match]
        return None

    def iterAtomsForPackage(self, pkg):
        """
		Find all matching atoms for a given package. This matches virtual
		arguments against the PROVIDE metadata.  This will raise an
		InvalidDependString exception if PROVIDE is invalid.
		"""
        cpv_slot_list = [pkg]
        cp = cpv_getkey(pkg.cpv)
        self._load()  # make sure the atoms are loaded

        atoms = self._atommap.get(cp)
        if atoms:
            for atom in atoms:
                if match_from_list(atom, cpv_slot_list):
                    yield atom
        provides = pkg._metadata["PROVIDE"]
        if not provides:
            return
        provides = provides.split()
        for provide in provides:
            try:
                provided_cp = Atom(provide).cp
            except InvalidAtom:
                continue
            atoms = self._atommap.get(provided_cp)
            if atoms:
                for atom in atoms:
                    if match_from_list(atom.replace(provided_cp, cp), cpv_slot_list):
                        yield atom
开发者ID:entoo,项目名称:portage-src,代码行数:104,代码来源:base.py

示例7: MaskManager

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]

#.........这里部分代码省略.........
		profile_pkgmasklines = stack_lists(profile_pkgmasklines, incremental=1, \
			remember_source_file=True, warn_for_unmatched_removal=True,
			strict_warn_for_unmatched_removal=strict_umatched_removal)
		profile_pkgunmasklines = stack_lists(profile_pkgunmasklines, incremental=1, \
			remember_source_file=True, warn_for_unmatched_removal=True,
			strict_warn_for_unmatched_removal=strict_umatched_removal)

		#Read /etc/portage/package.mask. Don't stack it to allow the user to
		#remove mask atoms from everywhere with -atoms.
		user_pkgmasklines = []
		user_pkgunmasklines = []
		if user_config:
			user_pkgmasklines = grabfile_package(
				os.path.join(abs_user_config, "package.mask"), recursive=1, \
				allow_wildcard=True, allow_repo=True,
				remember_source_file=True, verify_eapi=False,
				allow_build_id=True)
			user_pkgunmasklines = grabfile_package(
				os.path.join(abs_user_config, "package.unmask"), recursive=1, \
				allow_wildcard=True, allow_repo=True,
				remember_source_file=True, verify_eapi=False,
				allow_build_id=True)

		#Stack everything together. At this point, only user_pkgmasklines may contain -atoms.
		#Don't warn for unmatched -atoms here, since we don't do it for any other user config file.
		raw_pkgmasklines = stack_lists([repo_pkgmasklines, profile_pkgmasklines], \
			incremental=1, remember_source_file=True, warn_for_unmatched_removal=False, ignore_repo=True)
		pkgmasklines = stack_lists([repo_pkgmasklines, profile_pkgmasklines, user_pkgmasklines], \
			incremental=1, remember_source_file=True, warn_for_unmatched_removal=False, ignore_repo=True)
		pkgunmasklines = stack_lists([repo_pkgunmasklines, profile_pkgunmasklines, user_pkgunmasklines], \
			incremental=1, remember_source_file=True, warn_for_unmatched_removal=False, ignore_repo=True)

		for x, source_file in raw_pkgmasklines:
			self._pmaskdict_raw.setdefault(x.cp, []).append(x)

		for x, source_file in pkgmasklines:
			self._pmaskdict.setdefault(x.cp, []).append(x)

		for x, source_file in pkgunmasklines:
			self._punmaskdict.setdefault(x.cp, []).append(x)

		for d in (self._pmaskdict_raw, self._pmaskdict, self._punmaskdict):
			for k, v in d.items():
				d[k] = tuple(v)

	def _getMaskAtom(self, cpv, slot, repo, unmask_atoms=None):
		"""
		Take a package and return a matching package.mask atom, or None if no
		such atom exists or it has been cancelled by package.unmask. PROVIDE
		is not checked, so atoms will not be found for old-style virtuals.

		@param cpv: The package name
		@type cpv: String
		@param slot: The package's slot
		@type slot: String
		@param repo: The package's repository [optional]
		@type repo: String
		@param unmask_atoms: if desired pass in self._punmaskdict.get(cp)
		@type unmask_atoms: list
		@rtype: String
		@return: A matching atom string or None if one is not found.
		"""

		try:
			cpv.slot
		except AttributeError:
开发者ID:aeroniero33,项目名称:portage,代码行数:70,代码来源:MaskManager.py

示例8: LicenseManager

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
class LicenseManager(object):

	def __init__(self, license_group_locations, abs_user_config, user_config=True):

		self._accept_license_str = None
		self._accept_license = None
		self._license_groups = {}
		self._plicensedict = ExtendedAtomDict(dict)
		self._undef_lic_groups = set()

		if user_config:
			license_group_locations = list(license_group_locations) + [abs_user_config]

		self._read_license_groups(license_group_locations)

		if user_config:
			self._read_user_config(abs_user_config)

	def _read_user_config(self, abs_user_config):
		licdict = grabdict_package(os.path.join(
			abs_user_config, "package.license"), recursive=1, allow_wildcard=True)
		for k, v in licdict.items():
			self._plicensedict.setdefault(k.cp, {})[k] = \
				self.expandLicenseTokens(v)

	def _read_license_groups(self, locations):
		for loc in locations:
			for k, v in grabdict(
				os.path.join(loc, "license_groups")).items():
				self._license_groups.setdefault(k, []).extend(v)

	def extract_global_changes(self, old=""):
		ret = old
		atom_license_map = self._plicensedict.get("*/*")
		if atom_license_map is not None:
			v = atom_license_map.pop("*/*", None)
			if v is not None:
				ret = " ".join(v)
				if old:
					ret = old + " " + ret
				if not atom_license_map:
					#No tokens left in atom_license_map, remove it.
					del self._plicensedict["*/*"]
		return ret
	
	def expandLicenseTokens(self, tokens):
		""" Take a token from ACCEPT_LICENSE or package.license and expand it
		if it's a group token (indicated by @) or just return it if it's not a
		group.  If a group is negated then negate all group elements."""
		expanded_tokens = []
		for x in tokens:
			expanded_tokens.extend(self._expandLicenseToken(x, None))
		return expanded_tokens

	def _expandLicenseToken(self, token, traversed_groups):
		negate = False
		rValue = []
		if token.startswith("-"):
			negate = True
			license_name = token[1:]
		else:
			license_name = token
		if not license_name.startswith("@"):
			rValue.append(token)
			return rValue
		group_name = license_name[1:]
		if traversed_groups is None:
			traversed_groups = set()
		license_group = self._license_groups.get(group_name)
		if group_name in traversed_groups:
			writemsg(_("Circular license group reference"
				" detected in '%s'\n") % group_name, noiselevel=-1)
			rValue.append("@"+group_name)
		elif license_group:
			traversed_groups.add(group_name)
			for l in license_group:
				if l.startswith("-"):
					writemsg(_("Skipping invalid element %s"
						" in license group '%s'\n") % (l, group_name),
						noiselevel=-1)
				else:
					rValue.extend(self._expandLicenseToken(l, traversed_groups))
		else:
			if self._license_groups and \
				group_name not in self._undef_lic_groups:
				self._undef_lic_groups.add(group_name)
				writemsg(_("Undefined license group '%s'\n") % group_name,
					noiselevel=-1)
			rValue.append("@"+group_name)
		if negate:
			rValue = ["-" + token for token in rValue]
		return rValue

	def _getPkgAcceptLicense(self, cpv, slot):
		"""
		Get an ACCEPT_LICENSE list, accounting for package.license.
		"""
		accept_license = self._accept_license
		cp = cpv_getkey(cpv)
		cpdict = self._plicensedict.get(cp)
#.........这里部分代码省略.........
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:103,代码来源:LicenseManager.py

示例9: KeywordsManager

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
class KeywordsManager(object):
	"""Manager class to handle keywords processing and validation"""

	def __init__(self, profiles, abs_user_config, user_config=True,
				global_accept_keywords=""):
		self._pkeywords_list = []
		rawpkeywords = [grabdict_package(
			os.path.join(x.location, "package.keywords"),
			recursive=x.portage1_directories,
			verify_eapi=True, eapi=x.eapi, eapi_default=None,
			allow_build_id=x.allow_build_id)
			for x in profiles]
		for pkeyworddict in rawpkeywords:
			if not pkeyworddict:
				# Omit non-existent files from the stack.
				continue
			cpdict = {}
			for k, v in pkeyworddict.items():
				cpdict.setdefault(k.cp, {})[k] = v
			self._pkeywords_list.append(cpdict)
		self._pkeywords_list = tuple(self._pkeywords_list)

		self._p_accept_keywords = []
		raw_p_accept_keywords = [grabdict_package(
			os.path.join(x.location, "package.accept_keywords"),
			recursive=x.portage1_directories,
			verify_eapi=True, eapi=x.eapi, eapi_default=None)
			for x in profiles]
		for d in raw_p_accept_keywords:
			if not d:
				# Omit non-existent files from the stack.
				continue
			cpdict = {}
			for k, v in d.items():
				cpdict.setdefault(k.cp, {})[k] = tuple(v)
			self._p_accept_keywords.append(cpdict)
		self._p_accept_keywords = tuple(self._p_accept_keywords)

		self.pkeywordsdict = ExtendedAtomDict(dict)

		if user_config:
			pkgdict = grabdict_package(
				os.path.join(abs_user_config, "package.keywords"),
				recursive=1, allow_wildcard=True, allow_repo=True,
				verify_eapi=False, allow_build_id=True)

			for k, v in grabdict_package(
				os.path.join(abs_user_config, "package.accept_keywords"),
				recursive=1, allow_wildcard=True, allow_repo=True,
				verify_eapi=False, allow_build_id=True).items():
				pkgdict.setdefault(k, []).extend(v)

			accept_keywords_defaults = global_accept_keywords.split()
			accept_keywords_defaults = tuple('~' + keyword for keyword in \
				accept_keywords_defaults if keyword[:1] not in "~-")
			for k, v in pkgdict.items():
				# default to ~arch if no specific keyword is given
				if not v:
					v = accept_keywords_defaults
				else:
					v = tuple(v)
				self.pkeywordsdict.setdefault(k.cp, {})[k] = v


	def getKeywords(self, cpv, slot, keywords, repo):
		try:
			cpv.slot
		except AttributeError:
			pkg = _pkg_str(cpv, slot=slot, repo=repo)
		else:
			pkg = cpv
		cp = pkg.cp
		keywords = [[x for x in keywords.split() if x != "-*"]]
		for pkeywords_dict in self._pkeywords_list:
			cpdict = pkeywords_dict.get(cp)
			if cpdict:
				pkg_keywords = ordered_by_atom_specificity(cpdict, pkg)
				if pkg_keywords:
					keywords.extend(pkg_keywords)
		return stack_lists(keywords, incremental=True)

	def isStable(self, pkg, global_accept_keywords, backuped_accept_keywords):
		mygroups = self.getKeywords(pkg, None, pkg._metadata["KEYWORDS"], None)
		pgroups = global_accept_keywords.split()

		unmaskgroups = self.getPKeywords(pkg, None, None,
			global_accept_keywords)
		pgroups.extend(unmaskgroups)

		egroups = backuped_accept_keywords.split()

		if unmaskgroups or egroups:
			pgroups = self._getEgroups(egroups, pgroups)
		else:
			pgroups = set(pgroups)

		if self._getMissingKeywords(pkg, pgroups, mygroups):
			return False

		# If replacing all keywords with unstable variants would mask the
#.........这里部分代码省略.........
开发者ID:gentoo,项目名称:portage,代码行数:103,代码来源:KeywordsManager.py

示例10: KeywordsManager

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
class KeywordsManager(object):
	"""Manager class to handle keywords processing and validation"""

	def __init__(self, profiles, abs_user_config, user_config=True,
				global_accept_keywords=""):
		self._pkeywords_list = []
		rawpkeywords = [grabdict_package(
			os.path.join(x.location, "package.keywords"),
			recursive=x.portage1_directories,
			verify_eapi=True) \
			for x in profiles]
		for pkeyworddict in rawpkeywords:
			if not pkeyworddict:
				# Omit non-existent files from the stack.
				continue
			cpdict = {}
			for k, v in pkeyworddict.items():
				cpdict.setdefault(k.cp, {})[k] = v
			self._pkeywords_list.append(cpdict)
		self._pkeywords_list = tuple(self._pkeywords_list)

		self._p_accept_keywords = []
		raw_p_accept_keywords = [grabdict_package(
			os.path.join(x.location, "package.accept_keywords"),
			recursive=x.portage1_directories,
			verify_eapi=True) \
			for x in profiles]
		for d in raw_p_accept_keywords:
			if not d:
				# Omit non-existent files from the stack.
				continue
			cpdict = {}
			for k, v in d.items():
				cpdict.setdefault(k.cp, {})[k] = tuple(v)
			self._p_accept_keywords.append(cpdict)
		self._p_accept_keywords = tuple(self._p_accept_keywords)

		self.pkeywordsdict = ExtendedAtomDict(dict)

		if user_config:
			pkgdict = grabdict_package(
				os.path.join(abs_user_config, "package.keywords"),
				recursive=1, allow_wildcard=True, allow_repo=True,
				verify_eapi=False)

			for k, v in grabdict_package(
				os.path.join(abs_user_config, "package.accept_keywords"),
				recursive=1, allow_wildcard=True, allow_repo=True,
				verify_eapi=False).items():
				pkgdict.setdefault(k, []).extend(v)

			accept_keywords_defaults = global_accept_keywords.split()
			accept_keywords_defaults = tuple('~' + keyword for keyword in \
				accept_keywords_defaults if keyword[:1] not in "~-")
			for k, v in pkgdict.items():
				# default to ~arch if no specific keyword is given
				if not v:
					v = accept_keywords_defaults
				else:
					v = tuple(v)
				self.pkeywordsdict.setdefault(k.cp, {})[k] = v


	def getKeywords(self, cpv, slot, keywords, repo):
		cp = cpv_getkey(cpv)
		pkg = "".join((cpv, _slot_separator, slot))
		if repo and repo != Package.UNKNOWN_REPO:
			pkg = "".join((pkg, _repo_separator, repo))
		keywords = [[x for x in keywords.split() if x != "-*"]]
		for pkeywords_dict in self._pkeywords_list:
			cpdict = pkeywords_dict.get(cp)
			if cpdict:
				pkg_keywords = ordered_by_atom_specificity(cpdict, pkg)
				if pkg_keywords:
					keywords.extend(pkg_keywords)
		return stack_lists(keywords, incremental=True)


	def getMissingKeywords(self,
							cpv,
							slot,
							keywords,
							repo,
							global_accept_keywords,
							backuped_accept_keywords):
		"""
		Take a package and return a list of any KEYWORDS that the user may
		need to accept for the given package. If the KEYWORDS are empty
		and the the ** keyword has not been accepted, the returned list will
		contain ** alone (in order to distinguish from the case of "none
		missing").

		@param cpv: The package name (for package.keywords support)
		@type cpv: String
		@param slot: The 'SLOT' key from the raw package metadata
		@type slot: String
		@param keywords: The 'KEYWORDS' key from the raw package metadata
		@type keywords: String
		@param global_accept_keywords: The current value of ACCEPT_KEYWORDS
		@type global_accept_keywords: String
#.........这里部分代码省略.........
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:103,代码来源:KeywordsManager.py

示例11: _parse_file_to_dict

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import setdefault [as 别名]
	def _parse_file_to_dict(self, file_name, juststrings=False, recursive=True,
		eapi_filter=None, user_config=False, eapi=None, eapi_default="0"):
		"""
		@param file_name: input file name
		@type file_name: str
		@param juststrings: store dict values as space-delimited strings
			instead of tuples
		@type juststrings: bool
		@param recursive: triggers recursion if the input file is a
			directory
		@type recursive: bool
		@param eapi_filter: a function that accepts a single eapi
			argument, and returns true if the the current file type
			is supported by the given EAPI
		@type eapi_filter: callable
		@param user_config: current file is part of the local
			configuration (not repository content)
		@type user_config: bool
		@param eapi: the EAPI of the current profile node, which allows
			a call to read_corresponding_eapi_file to be skipped
		@type eapi: str
		@param eapi_default: the default EAPI which applies if the
			current profile node does not define a local EAPI
		@type eapi_default: str
		@rtype: tuple
		@return: collection of USE flags
		"""
		ret = {}
		location_dict = {}
		if eapi is None:
			eapi = read_corresponding_eapi_file(file_name,
				default=eapi_default)
		extended_syntax = eapi is None and user_config
		if extended_syntax:
			ret = ExtendedAtomDict(dict)
		else:
			ret = {}
		file_dict = grabdict_package(file_name, recursive=recursive,
			allow_wildcard=extended_syntax, allow_repo=extended_syntax,
			verify_eapi=(not extended_syntax), eapi=eapi,
			eapi_default=eapi_default)
		if eapi is not None and eapi_filter is not None and not eapi_filter(eapi):
			if file_dict:
				writemsg(_("--- EAPI '%s' does not support '%s': '%s'\n") %
					(eapi, os.path.basename(file_name), file_name),
					noiselevel=-1)
			return ret
		useflag_re = _get_useflag_re(eapi)
		for k, v in file_dict.items():
			useflags = []
			for prefixed_useflag in v:
				if prefixed_useflag[:1] == "-":
					useflag = prefixed_useflag[1:]
				else:
					useflag = prefixed_useflag
				if useflag_re.match(useflag) is None:
					writemsg(_("--- Invalid USE flag for '%s' in '%s': '%s'\n") %
						(k, file_name, prefixed_useflag), noiselevel=-1)
				else:
					useflags.append(prefixed_useflag)
			location_dict.setdefault(k, []).extend(useflags)
		for k, v in location_dict.items():
			if juststrings:
				v = " ".join(v)
			else:
				v = tuple(v)
			ret.setdefault(k.cp, {})[k] = v
		return ret
开发者ID:ptisserand,项目名称:portage,代码行数:70,代码来源:UseManager.py


注:本文中的portage.dep.ExtendedAtomDict.setdefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。