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


Python versions._pkg_str函数代码示例

本文整理汇总了Python中portage.versions._pkg_str函数的典型用法代码示例。如果您正苦于以下问题:Python _pkg_str函数的具体用法?Python _pkg_str怎么用?Python _pkg_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: cpv_inject

	def cpv_inject(self, mycpv, metadata=None):
		"""Adds a cpv to the list of available packages. See the
		exclusive_slots constructor parameter for behavior with
		respect to SLOT metadata.
		@param mycpv: cpv for the package to inject
		@type mycpv: str
		@param metadata: dictionary of raw metadata for aux_get() calls
		@param metadata: dict
		"""
		self._clear_cache()

		try:
			mycp = mycpv.cp
		except AttributeError:
			mycp = None
		try:
			myslot = mycpv.slot
		except AttributeError:
			myslot = None

		if mycp is None or \
			(myslot is None and metadata is not None and metadata.get('SLOT')):
			if metadata is None:
				mycpv = _pkg_str(mycpv)
			else:
				mycpv = _pkg_str(mycpv, metadata=metadata,
					settings=self.settings)

			mycp = mycpv.cp
			try:
				myslot = mycpv.slot
			except AttributeError:
				pass

		self.cpvdict[mycpv] = metadata
		if not self._exclusive_slots:
			myslot = None
		if myslot and mycp in self.cpdict:
			# If necessary, remove another package in the same SLOT.
			for cpv in self.cpdict[mycp]:
				if mycpv != cpv:
					try:
						other_slot = cpv.slot
					except AttributeError:
						pass
					else:
						if myslot == other_slot:
							self.cpv_remove(cpv)
							break

		cp_list = self.cpdict.get(mycp)
		if cp_list is None:
			cp_list = []
			self.cpdict[mycp] = cp_list
		try:
			cp_list.remove(mycpv)
		except ValueError:
			pass
		cp_list.append(mycpv)
开发者ID:Spencerx,项目名称:portage,代码行数:59,代码来源:virtual.py

示例2: cp_all

	def cp_all(self):
		"""
		Returns an ordered iterator instead of a list, so that search
		results can be displayed incrementally.
		"""
		if self._cp_map is not None:
			return iter(sorted(self._cp_map))

		delta_data = self._vardb._cache_delta.loadRace()
		if delta_data is None:
			return self._iter_cp_all()

		self._vardb._cache_delta.applyDelta(delta_data)

		self._cp_map = cp_map = {}
		for cpv in self._vardb._aux_cache["packages"]:
			try:
				cpv = _pkg_str(cpv)
			except InvalidData:
				continue

			cp_list = cp_map.get(cpv.cp)
			if cp_list is None:
				cp_list = []
				cp_map[cpv.cp] = cp_list
			cp_list.append(cpv)

		return iter(sorted(self._cp_map))
开发者ID:Whissi,项目名称:portage,代码行数:28,代码来源:IndexedVardb.py

示例3: getMaskAtom

	def getMaskAtom(self, cpv, slot, repo):
		"""
		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
		@rtype: String
		@return: A matching atom string or None if one is not found.
		"""

		try:
			cpv.slot
		except AttributeError:
			pkg = _pkg_str(cpv, slot=slot, repo=repo)
		else:
			pkg = cpv

		return self._getMaskAtom(pkg, slot, repo,
			self._punmaskdict.get(pkg.cp))
开发者ID:aeroniero33,项目名称:portage,代码行数:25,代码来源:MaskManager.py

示例4: getUseMask

	def getUseMask(self, pkg=None, stable=None):
		if pkg is None:
			return frozenset(stack_lists(
				self._usemask_list, incremental=True))

		slot = None
		cp = getattr(pkg, "cp", None)
		if cp is None:
			slot = dep_getslot(pkg)
			repo = dep_getrepo(pkg)
			pkg = _pkg_str(remove_slot(pkg), slot=slot, repo=repo)
			cp = pkg.cp

		if stable is None:
			stable = self._isStable(pkg)

		usemask = []

		if hasattr(pkg, "repo") and pkg.repo != Package.UNKNOWN_REPO:
			repos = []
			try:
				repos.extend(repo.name for repo in
					self.repositories[pkg.repo].masters)
			except KeyError:
				pass
			repos.append(pkg.repo)
			for repo in repos:
				usemask.append(self._repo_usemask_dict.get(repo, {}))
				if stable:
					usemask.append(self._repo_usestablemask_dict.get(repo, {}))
				cpdict = self._repo_pusemask_dict.get(repo, {}).get(cp)
				if cpdict:
					pkg_usemask = ordered_by_atom_specificity(cpdict, pkg)
					if pkg_usemask:
						usemask.extend(pkg_usemask)
				if stable:
					cpdict = self._repo_pusestablemask_dict.get(repo, {}).get(cp)
					if cpdict:
						pkg_usemask = ordered_by_atom_specificity(cpdict, pkg)
						if pkg_usemask:
							usemask.extend(pkg_usemask)

		for i, pusemask_dict in enumerate(self._pusemask_list):
			if self._usemask_list[i]:
				usemask.append(self._usemask_list[i])
			if stable and self._usestablemask_list[i]:
				usemask.append(self._usestablemask_list[i])
			cpdict = pusemask_dict.get(cp)
			if cpdict:
				pkg_usemask = ordered_by_atom_specificity(cpdict, pkg)
				if pkg_usemask:
					usemask.extend(pkg_usemask)
			if stable:
				cpdict = self._pusestablemask_list[i].get(cp)
				if cpdict:
					pkg_usemask = ordered_by_atom_specificity(cpdict, pkg)
					if pkg_usemask:
						usemask.extend(pkg_usemask)

		return frozenset(stack_lists(usemask, incremental=True))
开发者ID:Spencerx,项目名称:portage,代码行数:60,代码来源:UseManager.py

示例5: __iter__

	def __iter__(self):
		"""generator for walking the dir struct"""
		dirs = [(0, self.location)]
		len_base = len(self.location)
		while dirs:
			depth, dir_path = dirs.pop()
			try:
				dir_list = os.listdir(dir_path)
			except OSError as e:
				if e.errno != errno.ENOENT:
					raise
				del e
				continue
			for l in dir_list:
				p = os.path.join(dir_path, l)
				try:
					st = os.lstat(p)
				except OSError:
					# Cache entry disappeared.
					continue
				if stat.S_ISDIR(st.st_mode):
					# Only recurse 1 deep, in order to avoid iteration over
					# entries from another nested cache instance. This can
					# happen if the user nests an overlay inside
					# /usr/portage/local as in bug #302764.
					if depth < 1:
						dirs.append((depth+1, p))
					continue

				try:
					yield _pkg_str(p[len_base+1:])
				except InvalidData:
					continue
开发者ID:amadio,项目名称:portage,代码行数:33,代码来源:flat_hash.py

示例6: __init__

	def __init__(self, **kwargs):
		metadata = _PackageMetadataWrapperBase(kwargs.pop('metadata'))
		Task.__init__(self, **kwargs)
		# the SlotObject constructor assigns self.root_config from keyword args
		# and is an instance of a '_emerge.RootConfig.RootConfig class
		self.root = self.root_config.root
		self._raw_metadata = metadata
		self._metadata = _PackageMetadataWrapper(self, metadata)
		if not self.built:
			self._metadata['CHOST'] = self.root_config.settings.get('CHOST', '')
		eapi_attrs = _get_eapi_attrs(self.eapi)
		self.cpv = _pkg_str(self.cpv, metadata=self._metadata,
			settings=self.root_config.settings)
		if hasattr(self.cpv, 'slot_invalid'):
			self._invalid_metadata('SLOT.invalid',
				"SLOT: invalid value: '%s'" % self._metadata["SLOT"])
		self.cpv_split = self.cpv.cpv_split
		self.category, self.pf = portage.catsplit(self.cpv)
		self.cp = self.cpv.cp
		self.version = self.cpv.version
		self.slot = self.cpv.slot
		self.sub_slot = self.cpv.sub_slot
		self.slot_atom = Atom("%s%s%s" % (self.cp, _slot_separator, self.slot))
		# sync metadata with validated repo (may be UNKNOWN_REPO)
		self._metadata['repository'] = self.cpv.repo

		if eapi_attrs.iuse_effective:
			implicit_match = self.root_config.settings._iuse_effective_match
			if self.built:
				implicit_match = functools.partial(
					self._built_iuse_effective_match,
					implicit_match, frozenset(self._metadata['USE'].split()))
		else:
			implicit_match = self.root_config.settings._iuse_implicit_match
		usealiases = self.root_config.settings._use_manager.getUseAliases(self)
		self.iuse = self._iuse(self, self._metadata["IUSE"].split(), implicit_match,
			usealiases, self.eapi)

		if (self.iuse.enabled or self.iuse.disabled) and \
			not eapi_attrs.iuse_defaults:
			if not self.installed:
				self._invalid_metadata('EAPI.incompatible',
					"IUSE contains defaults, but EAPI doesn't allow them")
		if self.inherited is None:
			self.inherited = frozenset()

		if self.operation is None:
			if self.onlydeps or self.installed:
				self.operation = "nomerge"
			else:
				self.operation = "merge"

		self._hash_key = Package._gen_hash_key(cpv=self.cpv,
			installed=self.installed, onlydeps=self.onlydeps,
			operation=self.operation, repo_name=self.cpv.repo,
			root_config=self.root_config,
			type_name=self.type_name)
		self._hash_value = hash(self._hash_key)
开发者ID:monsieurp,项目名称:portage,代码行数:58,代码来源:Package.py

示例7: getUseAliases

    def getUseAliases(self, pkg):
        if hasattr(pkg, "eapi") and not eapi_has_use_aliases(pkg.eapi):
            return {}

        cp = getattr(pkg, "cp", None)
        if cp is None:
            slot = dep_getslot(pkg)
            repo = dep_getrepo(pkg)
            pkg = _pkg_str(remove_slot(pkg), slot=slot, repo=repo)
            cp = pkg.cp

        usealiases = {}

        if hasattr(pkg, "repo") and pkg.repo != Package.UNKNOWN_REPO:
            repos = []
            try:
                if self.repositories[pkg.repo].use_aliases_masters is not None:
                    masters = self.repositories[pkg.repo].use_aliases_masters
                else:
                    masters = self.repositories[pkg.repo].masters
                repos.extend(repo.name for repo in masters)
            except KeyError:
                pass
            repos.append(pkg.repo)
            for repo in repos:
                usealiases_dict = self._repo_usealiases_dict.get(repo, {})
                for real_flag, aliases in usealiases_dict.items():
                    for alias in aliases:
                        if any(alias in v for k, v in usealiases.items() if k != real_flag):
                            writemsg(
                                _("--- Duplicated USE flag alias for '%s%s%s': '%s'\n")
                                % (pkg.cpv, _repo_separator, pkg.repo, alias),
                                noiselevel=-1,
                            )
                        else:
                            usealiases.setdefault(real_flag, []).append(alias)
                cp_usealiases_dict = self._repo_pusealiases_dict.get(repo, {}).get(cp)
                if cp_usealiases_dict:
                    usealiases_dict_list = ordered_by_atom_specificity(cp_usealiases_dict, pkg)
                    for usealiases_dict in usealiases_dict_list:
                        for real_flag, aliases in usealiases_dict.items():
                            for alias in aliases:
                                if any(alias in v for k, v in usealiases.items() if k != real_flag):
                                    writemsg(
                                        _("--- Duplicated USE flag alias for '%s%s%s': '%s'\n")
                                        % (pkg.cpv, _repo_separator, pkg.repo, alias),
                                        noiselevel=-1,
                                    )
                                else:
                                    usealiases.setdefault(real_flag, []).append(alias)

        return usealiases
开发者ID:rafaelmartins,项目名称:portage,代码行数:52,代码来源:UseManager.py

示例8: getPKeywords

	def getPKeywords(self, cpv, slot, repo, global_accept_keywords):
		"""Gets any package.keywords settings for cp for the given
		cpv, slot and repo

		@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
		@param backuped_accept_keywords: ACCEPT_KEYWORDS from the backup env
		@type backuped_accept_keywords: String
		@rtype: List
		@return: list of KEYWORDS that have been accepted
		"""

		pgroups = global_accept_keywords.split()
		try:
			cpv.slot
		except AttributeError:
			cpv = _pkg_str(cpv, slot=slot, repo=repo)
		cp = cpv.cp

		unmaskgroups = []
		if self._p_accept_keywords:
			accept_keywords_defaults = tuple('~' + keyword for keyword in \
				pgroups if keyword[:1] not in "~-")
			for d in self._p_accept_keywords:
				cpdict = d.get(cp)
				if cpdict:
					pkg_accept_keywords = \
						ordered_by_atom_specificity(cpdict, cpv)
					if pkg_accept_keywords:
						for x in pkg_accept_keywords:
							if not x:
								x = accept_keywords_defaults
							unmaskgroups.extend(x)

		pkgdict = self.pkeywordsdict.get(cp)
		if pkgdict:
			pkg_accept_keywords = \
				ordered_by_atom_specificity(pkgdict, cpv)
			if pkg_accept_keywords:
				for x in pkg_accept_keywords:
					unmaskgroups.extend(x)
		return unmaskgroups
开发者ID:gentoo,项目名称:portage,代码行数:48,代码来源:KeywordsManager.py

示例9: getKeywords

	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)
开发者ID:gentoo,项目名称:portage,代码行数:16,代码来源:KeywordsManager.py

示例10: _getPkgAcceptLicense

	def _getPkgAcceptLicense(self, cpv, slot, repo):
		"""
		Get an ACCEPT_LICENSE list, accounting for package.license.
		"""
		accept_license = self._accept_license
		cp = cpv_getkey(cpv)
		cpdict = self._plicensedict.get(cp)
		if cpdict:
			if not hasattr(cpv, "slot"):
				cpv = _pkg_str(cpv, slot=slot, repo=repo)
			plicence_list = ordered_by_atom_specificity(cpdict, cpv)
			if plicence_list:
				accept_license = list(self._accept_license)
				for x in plicence_list:
					accept_license.extend(x)
		return accept_license
开发者ID:aeroniero33,项目名称:portage,代码行数:16,代码来源:LicenseManager.py

示例11: getPUSE

	def getPUSE(self, pkg):
		cp = getattr(pkg, "cp", None)
		if cp is None:
			slot = dep_getslot(pkg)
			repo = dep_getrepo(pkg)
			pkg = _pkg_str(remove_slot(pkg), slot=slot, repo=repo)
			cp = pkg.cp
		ret = ""
		cpdict = self._pusedict.get(cp)
		if cpdict:
			puse_matches = ordered_by_atom_specificity(cpdict, pkg)
			if puse_matches:
				puse_list = []
				for x in puse_matches:
					puse_list.extend(x)
				ret = " ".join(puse_list)
		return ret
开发者ID:devurandom,项目名称:portage,代码行数:17,代码来源:UseManager.py

示例12: testUpdateDbentryBlockerTestCase

	def testUpdateDbentryBlockerTestCase(self):
		"""
		Avoid creating self-blockers for bug #367215.
		"""
		cases = (

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/B-1", eapi="1", slot="0"),
				"  !dev-libs/A  ", "  !dev-libs/A  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/C-1", eapi="1", slot="0"),
				"  !dev-libs/A  ", "  !dev-libs/B  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/B-1", eapi="1", slot="0"),
				"  !dev-libs/A:0  ", "  !dev-libs/A:0  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/C-1", eapi="1", slot="0"),
				"  !dev-libs/A:0  ", "  !dev-libs/B:0  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/C-1", eapi="1", slot="0"),
				"  !>=dev-libs/A-1:0  ", "  !>=dev-libs/B-1:0  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/B-1", eapi="1", slot="0"),
				"  !>=dev-libs/A-1:0  ", "  !>=dev-libs/A-1:0  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/C-1", eapi="1", slot="0"),
				"  !>=dev-libs/A-1  ", "  !>=dev-libs/B-1  "),

			(("move", Atom("dev-libs/A"), Atom("dev-libs/B")),
				_pkg_str("dev-libs/B-1", eapi="1", slot="0"),
				"  !>=dev-libs/A-1  ", "  !>=dev-libs/A-1  "),

		)
		for update_cmd, parent, input_str, output_str in cases:
			result = update_dbentry(update_cmd, input_str, parent=parent)
			self.assertEqual(result, output_str)
开发者ID:mgorny,项目名称:portage,代码行数:42,代码来源:test_update_dbentry.py

示例13: __init__

	def __init__(self, atom):
		atom = Atom(atom, allow_repo=True)
		self.cp = atom.cp
		slot = atom.slot
		if atom.sub_slot:
			slot = "%s/%s" % (slot, atom.sub_slot)
		if not slot:
			slot = '0'
		self.cpv = _pkg_str(atom.cpv, slot=slot, repo=atom.repo)
		self.cpv_split = catpkgsplit(self.cpv)
		self.slot = self.cpv.slot
		self.sub_slot = self.cpv.sub_slot
		self.repo = atom.repo
		if atom.use:
			self.use = self._use_class(atom.use.enabled)
			self.iuse = self._iuse_class(atom.use.required)
		else:
			self.use = self._use_class([])
			self.iuse = self._iuse_class([])
开发者ID:aeroniero33,项目名称:portage,代码行数:19,代码来源:test_match_from_list.py

示例14: perform_global_updates

def perform_global_updates(mycpv, aux_dict, mydb, myupdates):
	try:
		pkg = _pkg_str(mycpv, metadata=aux_dict, settings=mydb.settings)
	except InvalidData:
		return
	aux_dict = dict((k, aux_dict[k]) for k in Package._dep_keys)
	try:
		mycommands = myupdates[pkg.repo]
	except KeyError:
		try:
			mycommands = myupdates['DEFAULT']
		except KeyError:
			return

	if not mycommands:
		return

	updates = update_dbentries(mycommands, aux_dict, parent=pkg)
	if updates:
		mydb.aux_update(mycpv, updates)
开发者ID:jonasstein,项目名称:portage,代码行数:20,代码来源:FakeVartree.py

示例15: _getMaskAtom

	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:
			pkg = _pkg_str(cpv, slot=slot, repo=repo)
		else:
			pkg = cpv

		mask_atoms = self._pmaskdict.get(pkg.cp)
		if mask_atoms:
			pkg_list = [pkg]
			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:aeroniero33,项目名称:portage,代码行数:37,代码来源:MaskManager.py


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