本文整理汇总了Python中portage.dep.use_reduce函数的典型用法代码示例。如果您正苦于以下问题:Python use_reduce函数的具体用法?Python use_reduce怎么用?Python use_reduce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use_reduce函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: __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(paren_normalize(use_reduce(
paren_reduce(v), uselist=self._pkg.use.enabled)))
except portage.exception.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.
pkgsettings = self._pkg.root_config.trees[
'porttree'].dbapi.doebuild_settings
pkgsettings.setcpv(self._pkg)
v = pkgsettings["PORTAGE_USE"]
self['USE'] = v
return v
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:24,代码来源:Package.py
示例17: _validate_deps
def _validate_deps(self):
"""
Validate deps. This does not trigger USE calculation since that
is expensive for ebuilds and therefore we want to avoid doing
it unnecessarily (like for masked packages).
"""
eapi = self.eapi
dep_eapi = eapi
dep_valid_flag = self.iuse.is_valid_flag
if self.installed:
# Ignore EAPI.incompatible and conditionals missing
# from IUSE for installed packages since these issues
# aren't relevant now (re-evaluate when new EAPIs are
# deployed).
dep_eapi = None
dep_valid_flag = None
validated_atoms = []
for k in self._dep_keys:
v = self._metadata.get(k)
if not v:
continue
try:
atoms = use_reduce(v, eapi=dep_eapi,
matchall=True, is_valid_flag=dep_valid_flag,
token_class=Atom, flat=True)
except InvalidDependString as e:
self._metadata_exception(k, e)
else:
validated_atoms.extend(atoms)
if not self.built:
for atom in atoms:
if not isinstance(atom, Atom):
continue
if atom.slot_operator_built:
e = InvalidDependString(
_("Improper context for slot-operator "
"\"built\" atom syntax: %s") %
(atom.unevaluated_atom,))
self._metadata_exception(k, e)
self._validated_atoms = tuple(set(atom for atom in
validated_atoms if isinstance(atom, Atom)))
k = 'PROVIDE'
v = self._metadata.get(k)
if v:
try:
use_reduce(v, eapi=dep_eapi, matchall=True,
is_valid_flag=dep_valid_flag, token_class=Atom)
except InvalidDependString as e:
self._invalid_metadata("PROVIDE.syntax", "%s: %s" % (k, e))
for k in self._use_conditional_misc_keys:
v = self._metadata.get(k)
if not v:
continue
try:
use_reduce(v, eapi=dep_eapi, matchall=True,
is_valid_flag=dep_valid_flag)
except InvalidDependString as e:
self._metadata_exception(k, e)
k = 'REQUIRED_USE'
v = self._metadata.get(k)
if v and not self.built:
if not _get_eapi_attrs(eapi).required_use:
self._invalid_metadata('EAPI.incompatible',
"REQUIRED_USE set, but EAPI='%s' doesn't allow it" % eapi)
else:
try:
check_required_use(v, (),
self.iuse.is_valid_flag, eapi=eapi)
except InvalidDependString as e:
self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
k = 'SRC_URI'
v = self._metadata.get(k)
if v:
try:
use_reduce(v, is_src_uri=True, eapi=eapi, matchall=True,
is_valid_flag=self.iuse.is_valid_flag)
except InvalidDependString as e:
if not self.installed:
self._metadata_exception(k, e)
if self.built:
k = 'PROVIDES'
try:
self._provides = frozenset(
parse_soname_deps(self._metadata[k]))
except InvalidData as e:
self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
k = 'REQUIRES'
try:
self._requires = frozenset(
parse_soname_deps(self._metadata[k]))
except InvalidData as e:
self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
开发者ID:monsieurp,项目名称:portage,代码行数:100,代码来源:Package.py
示例18: dep_check
def dep_check(
depstring,
mydbapi,
mysettings,
use="yes",
mode=None,
myuse=None,
use_cache=1,
use_binaries=0,
myroot=None,
trees=None,
):
"""
Takes a depend string, parses it, and selects atoms.
The myroot parameter is unused (use mysettings['EROOT'] instead).
"""
myroot = mysettings["EROOT"]
edebug = mysettings.get("PORTAGE_DEBUG", None) == "1"
# check_config_instance(mysettings)
if trees is None:
trees = globals()["db"]
if use == "yes":
if myuse is None:
# default behavior
myusesplit = mysettings["PORTAGE_USE"].split()
else:
myusesplit = myuse
# We've been given useflags to use.
# print "USE FLAGS PASSED IN."
# print myuse
# if "bindist" in myusesplit:
# print "BINDIST is set!"
# else:
# print "BINDIST NOT set."
else:
# we are being run by autouse(), don't consult USE vars yet.
# WE ALSO CANNOT USE SETTINGS
myusesplit = []
mymasks = set()
useforce = set()
if use == "all":
# This is only for repoman, in order to constrain the use_reduce
# matchall behavior to account for profile use.mask/force. The
# ARCH/archlist code here may be redundant, since the profile
# really should be handling ARCH masking/forcing itself.
mymasks.update(mysettings.usemask)
mymasks.update(mysettings.archlist())
mymasks.discard(mysettings["ARCH"])
useforce.add(mysettings["ARCH"])
useforce.update(mysettings.useforce)
useforce.difference_update(mymasks)
# eapi code borrowed from _expand_new_virtuals()
mytrees = trees[myroot]
parent = mytrees.get("parent")
virt_parent = mytrees.get("virt_parent")
current_parent = None
eapi = None
if parent is not None:
if virt_parent is not None:
current_parent = virt_parent
else:
current_parent = parent
if current_parent is not None:
# Don't pass the eapi argument to use_reduce() for installed packages
# since previous validation will have already marked them as invalid
# when necessary and now we're more interested in evaluating
# dependencies so that things like --depclean work as well as possible
# in spite of partial invalidity.
if not current_parent.installed:
eapi = current_parent.eapi
if isinstance(depstring, list):
mysplit = depstring
else:
try:
mysplit = use_reduce(
depstring,
uselist=myusesplit,
masklist=mymasks,
matchall=(use == "all"),
excludeall=useforce,
opconvert=True,
token_class=Atom,
eapi=eapi,
)
except InvalidDependString as e:
return [0, "%s" % (e,)]
if mysplit == []:
# dependencies were reduced to nothing
return [1, []]
# Recursively expand new-style virtuals so as to
# collapse one or more levels of indirection.
try:
mysplit = _expand_new_virtuals(
mysplit,
#.........这里部分代码省略.........
开发者ID:nullishzero,项目名称:portage-1,代码行数:101,代码来源:dep_check.py
示例19: dep_check
def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
use_cache=1, use_binaries=0, myroot="/", trees=None):
"""Takes a depend string and parses the condition."""
edebug = mysettings.get("PORTAGE_DEBUG", None) == "1"
#check_config_instance(mysettings)
if trees is None:
trees = globals()["db"]
if use=="yes":
if myuse is None:
#default behavior
myusesplit = mysettings["PORTAGE_USE"].split()
else:
myusesplit = myuse
# We've been given useflags to use.
#print "USE FLAGS PASSED IN."
#print myuse
#if "bindist" in myusesplit:
# print "BINDIST is set!"
#else:
# print "BINDIST NOT set."
else:
#we are being run by autouse(), don't consult USE vars yet.
# WE ALSO CANNOT USE SETTINGS
myusesplit=[]
#convert parenthesis to sublists
try:
mysplit = paren_reduce(depstring)
except InvalidDependString as e:
return [0, str(e)]
mymasks = set()
useforce = set()
useforce.add(mysettings["ARCH"])
if use == "all":
# This masking/forcing is only for repoman. In other cases, relevant
# masking/forcing should have already been applied via
# config.regenerate(). Also, binary or installed packages may have
# been built with flags that are now masked, and it would be
# inconsistent to mask them now. Additionally, myuse may consist of
# flags from a parent package that is being merged to a $ROOT that is
# different from the one that mysettings represents.
mymasks.update(mysettings.usemask)
mymasks.update(mysettings.archlist())
mymasks.discard(mysettings["ARCH"])
useforce.update(mysettings.useforce)
useforce.difference_update(mymasks)
try:
mysplit = use_reduce(mysplit, uselist=myusesplit,
masklist=mymasks, matchall=(use=="all"), excludeall=useforce)
except InvalidDependString as e:
return [0, str(e)]
# Do the || conversions
mysplit = dep_opconvert(mysplit)
if mysplit == []:
#dependencies were reduced to nothing
return [1,[]]
# Recursively expand new-style virtuals so as to
# collapse one or more levels of indirection.
try:
mysplit = _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings,
use=use, mode=mode, myuse=myuse,
use_force=useforce, use_mask=mymasks, use_cache=use_cache,
use_binaries=use_binaries, myroot=myroot, trees=trees)
except ParseError as e:
return [0, str(e)]
mysplit2=mysplit[:]
mysplit2=dep_wordreduce(mysplit2,mysettings,mydbapi,mode,use_cache=use_cache)
if mysplit2 is None:
return [0, _("Invalid token")]
writemsg("\n\n\n", 1)
writemsg("mysplit: %s\n" % (mysplit), 1)
writemsg("mysplit2: %s\n" % (mysplit2), 1)
try:
selected_atoms = dep_zapdeps(mysplit, mysplit2, myroot,
use_binaries=use_binaries, trees=trees)
except InvalidAtom as e:
if portage.dep._dep_check_strict:
raise # This shouldn't happen.
# dbapi.match() failed due to an invalid atom in
# the dependencies of an installed package.
return [0, _("Invalid atom: '%s'") % (e,)]
return [1, selected_atoms]
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:90,代码来源:dep_check.py
示例20: _find_suggestions
def _find_suggestions(self):
if not self.shortest_cycle:
return None, None
suggestions = []
final_solutions = {}
for pos, pkg in enumerate(self.shortest_cycle):
parent = self.shortest_cycle[pos-1]
priorities = self.graph.nodes[parent][0][pkg]
parent_atoms = self.all_parent_atoms.get(pkg)
if priorities[-1].buildtime:
dep = parent.metadata["DEPEND"]
elif priorities[-1].runtime:
dep = parent.metadata["RDEPEND"]
for ppkg, atom in parent_atoms:
if ppkg == parent:
changed_parent = ppkg
parent_atom = atom.unevaluated_atom
break
affecting_use = extract_affecting_use(dep, parent_atom)
# Make sure we don't want to change a flag that is
# a) in use.mask or use.force
# b) changed by autounmask
usemask, useforce = self._get_use_mask_and_force(parent)
autounmask_changes = self._get_autounmask_changes(parent)
untouchable_flags = frozenset(chain(usemask, useforce, autounmask_changes))
affecting_use.difference_update(untouchable_flags)
#If any of the flags we're going to touch is in REQUIRED_USE, add all
#other flags in REQUIRED_USE to affecting_use, to not lose any solution.
required_use_flags = get_required_use_flags(parent.metadata["REQUIRED_USE"])
if affecting_use.intersection(required_use_flags):
affecting_use.update(required_use_flags)
affecting_use.difference_update(untouchable_flags)
affecting_use = tuple(affecting_use)
if not affecting_use:
continue
#We iterate over all possible settings of these use flags and gather
#a set of possible changes
#TODO: Use the information encoded in REQUIRED_USE
use_state = []
for flag in affecting_use:
use_state.append("disabled")
def _next_use_state(state, id=None):
if id is None:
id = len(state)-1
if id == 0 and state[0] == "enabled":
return False
if state[id] == "disabled":
state[id] = "enabled"
for i in range(id+1,len(state)):
state[i] = "disabled"
return True
else:
return _next_use_state(state, id-1)
solutions = set()
while(True):
current_use = set(self.depgraph._pkg_use_enabled(parent))
for flag, state in zip(affecting_use, use_state):
if state == "enabled":
current_use.add(flag)
else:
current_use.discard(flag)
reduced_dep = use_reduce(dep,
uselist=current_use, flat=True)
if parent_atom not in reduced_dep:
#We found an assignment that removes the atom from 'dep'.
#Make sure it doesn't conflict with REQUIRED_USE.
required_use = parent.metadata["REQUIRED_USE"]
if check_required_use(required_use, current_use, parent.iuse.is_valid_flag):
use = self.depgraph._pkg_use_enabled(parent)
solution = set()
for flag, state in zip(affecting_use, use_state):
if state == "enabled" and \
flag not in use:
solution.add((flag, True))
elif state == "disabled" and \
flag in use:
solution.add((flag, False))
solutions.add(frozenset(solution))
if not _next_use_state(use_state):
break
#.........这里部分代码省略.........
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:101,代码来源:circular_dependency.py
注:本文中的portage.dep.use_reduce函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论