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


Python dep.use_reduce函数代码示例

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


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

示例1: load_unpack_dependencies_configuration

def load_unpack_dependencies_configuration(repositories):
	repo_dict = {}
	for repo in repositories.repos_with_profiles():
		for eapi in _supported_eapis:
			if eapi_has_automatic_unpack_dependencies(eapi):
				file_name = os.path.join(repo.location, "profiles", "unpack_dependencies", eapi)
				lines = grabfile(file_name, recursive=True)
				for line in lines:
					elements = line.split()
					suffix = elements[0].lower()
					if len(elements) == 1:
						writemsg(_("--- Missing unpack dependencies for '%s' suffix in '%s'\n") % (suffix, file_name))
					depend = " ".join(elements[1:])
					try:
						use_reduce(depend, eapi=eapi)
					except InvalidDependString as e:
						writemsg(_("--- Invalid unpack dependencies for '%s' suffix in '%s': '%s'\n" % (suffix, file_name, e)))
					else:
						repo_dict.setdefault(repo.name, {}).setdefault(eapi, {})[suffix] = depend

	ret = {}
	for repo in repositories.repos_with_profiles():
		for repo_name in [x.name for x in repo.masters] + [repo.name]:
			for eapi in repo_dict.get(repo_name, {}):
				for suffix, depend in repo_dict.get(repo_name, {}).get(eapi, {}).items():
					ret.setdefault(repo.name, {}).setdefault(eapi, {})[suffix] = depend

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

示例2: load

	def load(self):
		depvars = ('RDEPEND', 'PDEPEND')

		# regexp used to match atoms using subslot operator :=
		subslot_repl_re = re.compile(r':[^[]*=')

		atoms = []
		for cpv in self._vardb.cpv_all():
			# no ebuild, no update :).
			if not self._portdb.cpv_exists(cpv):
				continue

			# USE flags used to build the ebuild and EAPI
			# (needed for Atom & use_reduce())
			use, eapi = self._vardb.aux_get(cpv, ('USE', 'EAPI'))
			usel = use.split()

			# function used to recursively process atoms in nested lists.
			def clean_subslots(depatom, usel=None):
				if isinstance(depatom, list):
					# process the nested list.
					return [clean_subslots(x, usel) for x in depatom]
				else:
					try:
						# this can be either an atom or some special operator.
						# in the latter case, we get InvalidAtom and pass it as-is.
						a = Atom(depatom)
					except InvalidAtom:
						return depatom
					else:
						# if we're processing portdb, we need to evaluate USE flag
						# dependency conditionals to make them match vdb. this
						# requires passing the list of USE flags, so we reuse it
						# as conditional for the operation as well.
						if usel is not None:
							a = a.evaluate_conditionals(usel)

						# replace slot operator := dependencies with plain :=
						# since we can't properly compare expanded slots
						# in vardb to abstract slots in portdb.
						return subslot_repl_re.sub(':=', a)

			# get all *DEPEND variables from vdb & portdb and compare them.
			# we need to do some cleaning up & expansion to make matching
			# meaningful since vdb dependencies are conditional-free.
			vdbvars = [clean_subslots(use_reduce(x, uselist=usel, eapi=eapi))
					for x in self._vardb.aux_get(cpv, depvars)]
			pdbvars = [clean_subslots(use_reduce(x, uselist=usel, eapi=eapi), usel)
					for x in self._portdb.aux_get(cpv, depvars)]

			# if dependencies don't match, trigger the rebuild.
			if vdbvars != pdbvars:
				atoms.append('=%s' % cpv)

		self._setAtoms(atoms)
开发者ID:aeroniero33,项目名称:portage,代码行数:55,代码来源:dbapi.py

示例3: _eval_use_flags

	def _eval_use_flags(self, cpv, metadata):
		use = frozenset(metadata["USE"].split())
		raw_use = use
		iuse = set(f.lstrip("-+") for f in metadata["IUSE"].split())
		use = [f for f in use if f in iuse]
		use.sort()
		metadata["USE"] = " ".join(use)
		from portage.dep import paren_reduce, use_reduce, \
			paren_normalize, paren_enclose
		for k in self._pkgindex_use_evaluated_keys:
			try:
				deps = paren_reduce(metadata[k])
				deps = use_reduce(deps, uselist=raw_use)
				deps = paren_normalize(deps)
				deps = paren_enclose(deps)
			except portage.exception.InvalidDependString as e:
				writemsg("%s: %s\n" % (k, str(e)),
					noiselevel=-1)
				raise
			if k in _vdb_use_conditional_atoms:
				v_split = []
				for x in deps.split():
					try:
						x = portage.dep.Atom(x)
					except portage.exception.InvalidAtom:
						v_split.append(x)
					else:
						v_split.append(str(x.evaluate_conditionals(raw_use)))
				deps = ' '.join(v_split)
			metadata[k] = deps
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:30,代码来源:bintree.py

示例4: evaluate_slot_operator_equal_deps

def evaluate_slot_operator_equal_deps(settings, use, trees):

	metadata = settings.configdict['pkg']
	eapi = metadata['EAPI']
	eapi_attrs = _get_eapi_attrs(eapi)
	running_vardb = trees[trees._running_eroot]["vartree"].dbapi
	target_vardb = trees[trees._target_eroot]["vartree"].dbapi
	vardbs = [target_vardb]
	deps = {}
	for k in Package._dep_keys:
		deps[k] = use_reduce(metadata[k],
			uselist=use, eapi=eapi, token_class=Atom)

	for k in Package._runtime_keys:
		_eval_deps(deps[k], vardbs)

	if eapi_attrs.bdepend:
		_eval_deps(deps["BDEPEND"], [running_vardb])
		_eval_deps(deps["DEPEND"], [target_vardb])
	else:
		if running_vardb is not target_vardb:
			vardbs.append(running_vardb)
		_eval_deps(deps["DEPEND"], vardbs)

	result = {}
	for k, v in deps.items():
		result[k] = paren_enclose(v)

	return result
开发者ID:mgorny,项目名称:portage,代码行数:29,代码来源:_slot_operator.py

示例5: get_prunned_accept_license

	def get_prunned_accept_license(self, cpv, use, lic, slot):
		"""
		Generate a pruned version of ACCEPT_LICENSE, by intersection with
		LICENSE. This is required since otherwise ACCEPT_LICENSE might be
		too big (bigger than ARG_MAX), causing execve() calls to fail with
		E2BIG errors as in bug #262647.
		"""
		try:
			licenses = set(use_reduce(lic, uselist=use, flat=True))
		except InvalidDependString:
			licenses = set()
		licenses.discard('||')

		accept_license = self._getPkgAcceptLicense(cpv, slot)

		if accept_license:
			acceptable_licenses = set()
			for x in accept_license:
				if x == '*':
					acceptable_licenses.update(licenses)
				elif x == '-*':
					acceptable_licenses.clear()
				elif x[:1] == '-':
					acceptable_licenses.discard(x[1:])
				elif x in licenses:
					acceptable_licenses.add(x)

			licenses = acceptable_licenses
		return ' '.join(sorted(licenses))
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:29,代码来源:LicenseManager.py

示例6: run

	def run(self):
		try:
			return use_reduce(self.deparray, self.uselist, self.masklist,
				self.matchall, self.excludeall, self.is_src_uri, self.eapi,
				self.opconvert, self.flat, self.is_valid_flag, self.token_class)
		except InvalidDependString as e:
			raise InvalidDependString("%s: %s" % (e, self.deparray))
开发者ID:Spencerx,项目名称:portage,代码行数:7,代码来源:test_use_reduce.py

示例7: testUseReduce

	def testUseReduce(self):

		tests = (
			('|| ( x y )',                                           True  ),
			('|| x',                                                 False ),
			('foo? ( x y )',                                         True  ),
			('foo? ( bar? x y )',                                    False ),
			('foo? x',                                               False ),
		)

		for dep_str, valid in tests:
			try:
				use_reduce(paren_reduce(dep_str), matchall=True)
			except InvalidDependString:
				self.assertEqual(valid, False)
			else:
				self.assertEqual(valid, True)
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:17,代码来源:test_use_reduce.py

示例8: homepage_urischeme

	def homepage_urischeme(self, **kwargs):
		ebuild = kwargs.get('ebuild').get()
		if kwargs.get('catdir') != "virtual":
			for homepage in use_reduce(ebuild.metadata["HOMEPAGE"],
				matchall=True,flat=True):
				if URISCHEME_RE.match(homepage) is None:
					self.qatracker.add_error(
						"HOMEPAGE.missingurischeme", ebuild.relative_path)
		return False
开发者ID:dol-sen,项目名称:portage,代码行数:9,代码来源:ebuild_metadata.py

示例9: find_built_slot_operator_atoms

def find_built_slot_operator_atoms(pkg):
	atoms = {}
	for k in Package._dep_keys:
		atom_list = list(_find_built_slot_operator(use_reduce(pkg._metadata[k],
			uselist=pkg.use.enabled, eapi=pkg.eapi,
			token_class=Atom)))
		if atom_list:
			atoms[k] = atom_list
	return atoms
开发者ID:mgorny,项目名称:portage,代码行数:9,代码来源:_slot_operator.py

示例10: getMissingLicenses

	def getMissingLicenses(self, cpv, use, lic, slot):
		"""
		Take a LICENSE string and return a list any licenses that the user may
		may need to accept for the given package.  The returned list will not
		contain any licenses that have already been accepted.  This method
		can throw an InvalidDependString exception.

		@param cpv: The package name (for package.license support)
		@type cpv: String
		@param use: "USE" from the cpv's metadata
		@type use: String
		@param lic: "LICENSE" from the cpv's metadata
		@type lic: String
		@param slot: "SLOT" from the cpv's metadata
		@type slot: String
		@rtype: List
		@return: A list of licenses that have not been accepted.
		"""

		licenses = set(use_reduce(lic, matchall=1, flat=True))
		licenses.discard('||')

		acceptable_licenses = set()
		for x in self._getPkgAcceptLicense(cpv, slot):
			if x == '*':
				acceptable_licenses.update(licenses)
			elif x == '-*':
				acceptable_licenses.clear()
			elif x[:1] == '-':
				acceptable_licenses.discard(x[1:])
			else:
				acceptable_licenses.add(x)

		license_str = lic
		if "?" in license_str:
			use = use.split()
		else:
			use = []

		license_struct = use_reduce(license_str, uselist=use, opconvert=True)
		return self._getMaskedLicenses(license_struct, acceptable_licenses)
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:41,代码来源:LicenseManager.py

示例11: __setitem__

	def __setitem__(self, k, v):
		_PackageMetadataWrapperBase.__setitem__(self, k, v)
		if k in self._wrapped_keys:
			getattr(self, "_set_" + k.lower())(k, v)
		elif k in self._use_conditional_keys:
			try:
				reduced = use_reduce(paren_reduce(v), matchall=1)
			except portage.exception.InvalidDependString as e:
				self._pkg._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
			else:
				if reduced and k == 'PROVIDE':
					for x in portage.flatten(reduced):
						if not isvalidatom(x):
							self._pkg._invalid_metadata(k + ".syntax",
								"%s: %s" % (k, x))
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:15,代码来源:Package.py

示例12: _eval_use_flags

	def _eval_use_flags(self, cpv, metadata):
		use = frozenset(metadata["USE"].split())
		for k in self._pkgindex_use_evaluated_keys:
			if k.endswith('DEPEND'):
				token_class = Atom
			else:
				token_class = None

			try:
				deps = metadata[k]
				deps = use_reduce(deps, uselist=use, token_class=token_class)
				deps = paren_enclose(deps)
			except portage.exception.InvalidDependString as e:
				writemsg("%s: %s\n" % (k, str(e)),
					noiselevel=-1)
				raise
			metadata[k] = deps
开发者ID:entoo,项目名称:portage-src,代码行数:17,代码来源:bintree.py

示例13: testOverlapDNF

	def testOverlapDNF(self):

		test_cases = (
			(
				'|| ( cat/A cat/B ) cat/E || ( cat/C cat/D )',
				[['||', 'cat/A', 'cat/B'], 'cat/E', ['||', 'cat/C', 'cat/D']],
			),
			(
				'|| ( cat/A cat/B ) cat/D || ( cat/B cat/C )',
				['cat/D', ['||', ['cat/A', 'cat/B'], ['cat/A', 'cat/C'], ['cat/B', 'cat/B'], ['cat/B', 'cat/C']]],
			),
			(
				'|| ( cat/A cat/B ) || ( cat/C cat/D )  || ( ( cat/B cat/E ) cat/F )',
				[['||', ['cat/A', 'cat/B', 'cat/E'], ['cat/A', 'cat/F'], ['cat/B', 'cat/B', 'cat/E'], ['cat/B', 'cat/F']], ['||', 'cat/C', 'cat/D']],
			),
		)

		for dep_str, result in test_cases:
			self.assertEqual(_overlap_dnf(use_reduce(dep_str, token_class=Atom, opconvert=True)), result)
开发者ID:gentoo,项目名称:portage,代码行数:19,代码来源:test_overlap_dnf.py

示例14: __getitem__

	def __getitem__(self, k):
		v = _PackageMetadataWrapperBase.__getitem__(self, k)
		if k in self._use_conditional_keys:
			if self._pkg.root_config.settings.local_config and '?' in v:
				try:
					v = paren_enclose(use_reduce(v, uselist=self._pkg.use.enabled, \
						is_valid_flag=self._pkg.iuse.is_valid_flag))
				except InvalidDependString:
					# This error should already have been registered via
					# self._pkg._invalid_metadata().
					pass
				else:
					self[k] = v

		elif k == 'USE' and not self._pkg.built:
			if not v:
				# This is lazy because it's expensive.
				v = self._pkg._init_use()

		return v
开发者ID:monsieurp,项目名称:portage,代码行数:20,代码来源:Package.py

示例15: testDNFConvert

	def testDNFConvert(self):

		test_cases = (
			(
				'|| ( A B ) || ( C D )',
				[['||', ['A', 'C'], ['A', 'D'], ['B', 'C'], ['B', 'D']]],
			),
			(
				'|| ( A B ) || ( B C )',
				[['||', ['A', 'B'], ['A', 'C'], ['B', 'B'], ['B', 'C']]],
			),
			(
				'|| ( A ( B C D ) )',
				[['||', 'A', ['B', 'C', 'D']]],
			),
			(
				'|| ( A ( B C D ) ) E',
				[['||', ['E', 'A'], ['E', 'B', 'C', 'D']]],
			),
			(
				'|| ( A ( B C ) ) || ( D E ) F',
				[['||', ['F', 'A', 'D'], ['F', 'A', 'E'], ['F', 'B', 'C', 'D'], ['F', 'B', 'C', 'E']]],
			),
			(
				'|| ( A ( B C || ( D E ) ) ( F G ) H )',
				[['||', 'A', ['B', 'C', 'D'], ['B', 'C', 'E'], ['F', 'G'], 'H']],
			),
			(
				'|| ( A ( B C || ( D E ) ) F )',
				[['||', 'A', ['B', 'C', 'D'], ['B', 'C', 'E'], 'F']],
			),
			(
				'|| ( A ( C || ( D E ) || ( F G ) ) H )',
				[['||', 'A', ['C', 'D', 'F'], ['C', 'D', 'G'], ['C', 'E', 'F'], ['C', 'E', 'G'], 'H']],
			),
		)

		for dep_str, result in test_cases:
			self.assertEqual(dnf_convert(use_reduce(dep_str, opconvert=True)), result)
开发者ID:gentoo,项目名称:portage,代码行数:39,代码来源:test_dnf_convert.py


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