本文整理汇总了Python中portage.versions._pkg_str函数的典型用法代码示例。如果您正苦于以下问题:Python _pkg_str函数的具体用法?Python _pkg_str怎么用?Python _pkg_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_pkg_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: __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)
try:
db = self.cpv._db
except AttributeError:
if self.built:
# For independence from the source ebuild repository and
# profile implicit IUSE state, require the _db attribute
# for built packages.
raise
db = self.root_config.trees['porttree'].dbapi
self.cpv = _pkg_str(self.cpv, metadata=self._metadata,
settings=self.root_config.settings, db=db)
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 self.root_config.settings.local_config:
implicit_match = db._iuse_implicit_cnstr(self.cpv, self._metadata)
else:
implicit_match = db._repoman_iuse_implicit_cnstr(self.cpv, self._metadata)
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:gentoo,项目名称:portage,代码行数:65,代码来源:Package.py
示例17: pkg_desc_index_line_format
def pkg_desc_index_line_format(cp, pkgs, desc):
return "%s %s: %s\n" % (cp,
" ".join(_pkg_str(cpv).version
for cpv in pkgs), desc)
开发者ID:jonasstein,项目名称:portage,代码行数:4,代码来源:pkg_desc_index.py
示例18: _unmerge_display
#.........这里部分代码省略.........
print(colorize("WARN", "but still listed in the following package sets:"))
print(" %s\n" % ", ".join(parents))
del installed_sets
numselected = len(all_selected)
if not numselected:
writemsg_level(
"\n>>> No packages selected for removal by " + \
unmerge_action + "\n")
return 1, {}
# Unmerge order only matters in some cases
if not ordered:
unordered = {}
for d in pkgmap:
selected = d["selected"]
if not selected:
continue
cp = portage.cpv_getkey(next(iter(selected)))
cp_dict = unordered.get(cp)
if cp_dict is None:
cp_dict = {}
unordered[cp] = cp_dict
for k in d:
cp_dict[k] = set()
for k, v in d.items():
cp_dict[k].update(v)
pkgmap = [unordered[cp] for cp in sorted(unordered)]
for x in range(len(pkgmap)):
selected = pkgmap[x]["selected"]
if not selected:
continue
for mytype, mylist in pkgmap[x].items():
if mytype == "selected":
continue
mylist.difference_update(all_selected)
cp = portage.cpv_getkey(next(iter(selected)))
for y in localtree.dep_match(cp):
if y not in pkgmap[x]["omitted"] and \
y not in pkgmap[x]["selected"] and \
y not in pkgmap[x]["protected"] and \
y not in all_selected:
pkgmap[x]["omitted"].add(y)
if global_unmerge and not pkgmap[x]["selected"]:
#avoid cluttering the preview printout with stuff that isn't getting unmerged
continue
if not (pkgmap[x]["protected"] or pkgmap[x]["omitted"]) and cp in syslist:
virt_cp = sys_virt_map.get(cp)
if virt_cp is None:
cp_info = "'%s'" % (cp,)
else:
cp_info = "'%s' (%s)" % (cp, virt_cp)
writemsg_level(colorize("BAD","\n\n!!! " + \
"%s is part of your system profile.\n" % (cp_info,)),
level=logging.WARNING, noiselevel=-1)
writemsg_level(colorize("WARN","!!! Unmerging it may " + \
"be damaging to your system.\n\n"),
level=logging.WARNING, noiselevel=-1)
if not quiet:
writemsg_level("\n %s\n" % (bold(cp),), noiselevel=-1)
else:
writemsg_level(bold(cp) + ": ", noiselevel=-1)
for mytype in ["selected","protected","omitted"]:
if not quiet:
writemsg_level((mytype + ": ").rjust(14), noiselevel=-1)
if pkgmap[x][mytype]:
sorted_pkgs = []
for mypkg in pkgmap[x][mytype]:
try:
sorted_pkgs.append(mypkg.cpv)
except AttributeError:
sorted_pkgs.append(_pkg_str(mypkg))
sorted_pkgs.sort(key=cpv_sort_key())
for mypkg in sorted_pkgs:
if mytype == "selected":
writemsg_level(
colorize("UNMERGE_WARN", mypkg.version + " "),
noiselevel=-1)
else:
writemsg_level(
colorize("GOOD", mypkg.version + " "),
noiselevel=-1)
else:
writemsg_level("none ", noiselevel=-1)
if not quiet:
writemsg_level("\n", noiselevel=-1)
if quiet:
writemsg_level("\n", noiselevel=-1)
writemsg_level("\nAll selected packages: %s\n" % " ".join(all_selected), noiselevel=-1)
writemsg_level("\n>>> " + colorize("UNMERGE_WARN", "'Selected'") + \
" packages are slated for removal.\n")
writemsg_level(">>> " + colorize("GOOD", "'Protected'") + \
" and " + colorize("GOOD", "'omitted'") + \
" packages will not be removed.\n\n")
return os.EX_OK, pkgmap
开发者ID:Spencerx,项目名称:portage,代码行数:101,代码来源:unmerge.py
示例19: getUseForce
def getUseForce(self, pkg=None):
if pkg is None:
return frozenset(stack_lists(
self._useforce_list, incremental=True))
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
try:
stable = pkg.stable
except AttributeError:
# KEYWORDS is unavailable (prior to "depend" phase)
stable = False
useforce = []
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:
useforce.append(self._repo_useforce_dict.get(repo, {}))
if stable:
useforce.append(self._repo_usestableforce_dict.get(repo, {}))
cpdict = self._repo_puseforce_dict.get(repo, {}).get(cp)
if cpdict:
pkg_useforce = ordered_by_atom_specificity(cpdict, pkg)
if pkg_useforce:
useforce.extend(pkg_useforce)
if stable:
cpdict = self._repo_pusestableforce_dict.get(repo, {}).get(cp)
if cpdict:
pkg_useforce = ordered_by_atom_specificity(cpdict, pkg)
if pkg_useforce:
useforce.extend(pkg_useforce)
for i, puseforce_dict in enumerate(self._puseforce_list):
if self._useforce_list[i]:
useforce.append(self._useforce_list[i])
if stable and self._usestableforce_list[i]:
useforce.append(self._usestableforce_list[i])
cpdict = puseforce_dict.get(cp)
if cpdict:
pkg_useforce = ordered_by_atom_specificity(cpdict, pkg)
if pkg_useforce:
useforce.extend(pkg_useforce)
if stable:
cpdict = self._pusestableforce_list[i].get(cp)
if cpdict:
pkg_useforce = ordered_by_atom_specificity(cpdict, pkg)
if pkg_useforce:
useforce.extend(pkg_useforce)
return frozenset(stack_lists(useforce, incremental=True))
开发者ID:devurandom,项目名称:portage,代码行数:62,代码来源:UseManager.py
示例20: getmaskingreason
def getmaskingreason(mycpv, metadata=None, settings=None,
portdb=None, return_location=False, myrepo=None):
"""
If specified, the myrepo argument is assumed to be valid. This
should be a safe assumption since portdbapi methods always
return valid repo names and valid "repository" metadata from
aux_get.
"""
if settings is None:
settings = portage.settings
if portdb is None:
portdb = portage.portdb
mysplit = catpkgsplit(mycpv)
if not mysplit:
raise ValueError(_("invalid CPV: %s") % mycpv)
if metadata is None:
db_keys = list(portdb._aux_cache_keys)
try:
metadata = dict(zip(db_keys,
portdb.aux_get(mycpv, db_keys, myrepo=myrepo)))
except KeyError:
if not portdb.cpv_exists(mycpv):
raise
else:
if myrepo is None:
myrepo = _gen_valid_repo(metadata["repository"])
elif myrepo is None:
myrepo = metadata.get("repository")
if myrepo is not None:
myrepo = _gen_valid_repo(metadata["repository"])
if metadata is not None and \
not portage.eapi_is_supported(metadata["EAPI"]):
# Return early since otherwise we might produce invalid
# results given that the EAPI is not supported. Also,
# metadata is mostly useless in this case since it doesn't
# contain essential things like SLOT.
if return_location:
return (None, None)
else:
return None
# Sometimes we can't access SLOT or repository due to corruption.
pkg = mycpv
try:
pkg.slot
except AttributeError:
pkg = _pkg_str(mycpv, metadata=metadata, repo=myrepo)
cpv_slot_list = [pkg]
mycp = pkg.cp
locations = []
if pkg.repo in settings.repositories:
for repo in settings.repositories[pkg.repo].masters + (settings.repositories[pkg.repo],):
locations.append(os.path.join(repo.location, "profiles"))
locations.extend(settings.profiles)
locations.append(os.path.join(settings["PORTAGE_CONFIGROOT"],
USER_CONFIG_PATH))
locations.reverse()
pmasklists = []
for profile in locations:
pmask_filename = os.path.join(profile, "package.mask")
node = None
for l, recursive_filename in grablines(pmask_filename,
recursive=1, remember_source_file=True):
if node is None or node[0] != recursive_filename:
node = (recursive_filename, [])
pmasklists.append(node)
node[1].append(l)
pmaskdict = settings._mask_manager._pmaskdict
if mycp in pmaskdict:
for x in pmaskdict[mycp]:
if match_from_list(x, cpv_slot_list):
x = x.without_repo
for pmask in pmasklists:
comment = ""
comment_valid = -1
pmask_filename = pmask[0]
for i in range(len(pmask[1])):
l = pmask[1][i].strip()
try:
l_atom = Atom(l, allow_repo=True,
allow_wildcard=True).without_repo
except InvalidAtom:
l_atom = None
if l == "":
comment = ""
comment_valid = -1
elif l[0] == "#":
comment += (l+"\n")
comment_valid = i + 1
elif l_atom == x:
if comment_valid != i:
comment = ""
if return_location:
#.........这里部分代码省略.........
开发者ID:entoo,项目名称:portage-src,代码行数:101,代码来源:getmaskingreason.py
注:本文中的portage.versions._pkg_str函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论