本文整理汇总了Python中portage.versions.catpkgsplit函数的典型用法代码示例。如果您正苦于以下问题:Python catpkgsplit函数的具体用法?Python catpkgsplit怎么用?Python catpkgsplit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了catpkgsplit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cpvequal
def cpvequal(cpv1, cpv2):
"""
@param cpv1: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
@type cpv1: String
@param cpv2: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
@type cpv2: String
@rtype: Boolean
@returns:
1. True if cpv1 = cpv2
2. False Otherwise
3. Throws PortageException if cpv1 or cpv2 is not a CPV
Example Usage:
>>> from portage.dep import cpvequal
>>> cpvequal("sys-apps/portage-2.1","sys-apps/portage-2.1")
>>> True
"""
split1 = catpkgsplit(cpv1)
split2 = catpkgsplit(cpv2)
if not split1 or not split2:
raise portage.exception.PortageException(_("Invalid data '%s, %s', parameter was not a CPV") % (cpv1, cpv2))
if split1[0] != split2[0]:
return False
return (pkgcmp(split1[1:], split2[1:]) == 0)
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:30,代码来源:__init__.py
示例2: mapPathsToAtoms
def mapPathsToAtoms(self, paths, exclude_paths=None):
"""
All paths must have $EROOT stripped from the left side.
"""
rValue = set()
vardb = self._db
aux_get = vardb.aux_get
aux_keys = ["SLOT"]
if exclude_paths is None:
for link, p in vardb._owners.iter_owners(paths):
cat, pn = catpkgsplit(link.mycpv)[:2]
slot, = aux_get(link.mycpv, aux_keys)
rValue.add("%s/%s:%s" % (cat, pn, slot))
else:
all_paths = set()
all_paths.update(paths)
all_paths.update(exclude_paths)
exclude_atoms = set()
for link, p in vardb._owners.iter_owners(all_paths):
cat, pn = catpkgsplit(link.mycpv)[:2]
slot, = aux_get(link.mycpv, aux_keys)
atom = "%s/%s:%s" % (cat, pn, slot)
rValue.add(atom)
if p in exclude_paths:
exclude_atoms.add(atom)
rValue.difference_update(exclude_atoms)
return rValue
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:28,代码来源:dbapi.py
示例3: getMinUpgrade
def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=True):
"""
Checks if the systemstate is matching an atom in
I{vulnerableList} and returns string describing
the lowest version for the package that matches an atom in
I{unaffectedList} and is greater than the currently installed
version or None if the system is not affected. Both
I{vulnerableList} and I{unaffectedList} should have the
same base package.
@type vulnerableList: List of Strings
@param vulnerableList: atoms matching vulnerable package versions
@type unaffectedList: List of Strings
@param unaffectedList: atoms matching unaffected package versions
@type portdbapi: portage.dbapi.porttree.portdbapi
@param portdbapi: Ebuild repository
@type vardbapi: portage.dbapi.vartree.vardbapi
@param vardbapi: Installed package repository
@type minimize: Boolean
@param minimize: True for a least-change upgrade, False for emerge-like algorithm
@rtype: String | None
@return: the lowest unaffected version that is greater than
the installed version.
"""
rValue = None
v_installed = []
u_installed = []
for v in vulnerableList:
v_installed += match(v, vardbapi)
for u in unaffectedList:
u_installed += match(u, vardbapi)
install_unaffected = True
for i in v_installed:
if i not in u_installed:
install_unaffected = False
if install_unaffected:
return rValue
for u in unaffectedList:
mylist = match(u, portdbapi, match_type="match-all")
for c in mylist:
c_pv = catpkgsplit(c)
i_pv = catpkgsplit(best(v_installed))
if pkgcmp(c_pv[1:], i_pv[1:]) > 0 \
and (rValue == None \
or not match("="+rValue, portdbapi) \
or (minimize ^ (pkgcmp(c_pv[1:], catpkgsplit(rValue)[1:]) > 0)) \
and match("="+c, portdbapi)) \
and portdbapi.aux_get(c, ["SLOT"]) == vardbapi.aux_get(best(v_installed), ["SLOT"]):
rValue = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2]
if c_pv[3] != "r0": # we don't like -r0 for display
rValue += "-"+c_pv[3]
return rValue
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:57,代码来源:glsa.py
示例4: catpkgsplit
def catpkgsplit(cpv):
split = catpkgsplit(cpv)
if not split:
split = catpkgsplit('%s-0' % (cpv, ))
if not split:
return split
c, p, v, r = split
if r != 'r0' or cpv[-3:] == 'r0':
v = '%s-%s' % (v, r)
return c, p, v
开发者ID:frogbywyplay,项目名称:genbox_xintegtools,代码行数:10,代码来源:package.py
示例5: _calc_changelog
def _calc_changelog(ebuildpath, current, next):
if ebuildpath == None or not os.path.exists(ebuildpath):
return []
current = "-".join(catpkgsplit(current)[1:])
if current.endswith("-r0"):
current = current[:-3]
next = "-".join(catpkgsplit(next)[1:])
if next.endswith("-r0"):
next = next[:-3]
changelogdir = os.path.dirname(ebuildpath)
changelogs = ["ChangeLog"]
# ChangeLog-YYYY (see bug #389611)
changelogs.extend(sorted((fn for fn in os.listdir(changelogdir) if fn.startswith("ChangeLog-")), reverse=True))
divisions = []
found_current = False
for fn in changelogs:
changelogpath = os.path.join(changelogdir, fn)
try:
with io.open(
_unicode_encode(changelogpath, encoding=_encodings["fs"], errors="strict"),
mode="r",
encoding=_encodings["repo.content"],
errors="replace",
) as f:
changelog = f.read()
except EnvironmentError:
return []
for node in _find_changelog_tags(changelog):
if node[0] == current:
found_current = True
break
else:
divisions.append(node)
if found_current:
break
if not found_current:
return []
# print 'XX from',current,'to',next
# for div,text in divisions: print 'XX',div
# skip entries for all revisions above the one we are about to emerge
for i in range(len(divisions)):
if divisions[i][0] == next:
divisions = divisions[i:]
break
return divisions
开发者ID:zy-sunshine,项目名称:easymgc,代码行数:50,代码来源:output_helpers.py
示例6: _reduce
def _reduce(self, atomlist):
mydict = {}
for atom in atomlist[:]:
cpv = self._portdbapi.xmatch("match-all", atom)[0]
slot = self._portdbapi.aux_get(cpv, ["SLOT"])[0]
cps = "/".join(catpkgsplit(cpv)[0:2]) + ":" + slot
if not cps in mydict:
mydict[cps] = (atom, cpv)
else:
other_cpv = mydict[cps][1]
if pkgcmp(catpkgsplit(cpv)[1:], catpkgsplit(other_cpv)[1:]) > 0:
atomlist.remove(mydict[cps][0])
mydict[cps] = (atom, cpv)
return atomlist
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:14,代码来源:security.py
示例7: mapPathsToAtoms
def mapPathsToAtoms(self, paths):
rValue = set()
for link, p in self.dbapi._owners.iter_owners(paths):
cat, pn = catpkgsplit(link.mycpv)[:2]
slot = self.dbapi.aux_get(link.mycpv, ["SLOT"])[0]
rValue.add("%s/%s:%s" % (cat, pn, slot))
return rValue
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:7,代码来源:libs.py
示例8: get_slotted_cps
def get_slotted_cps(cpvs, logger):
"""Uses portage to reduce the cpv list into a cp:slot list and returns it
"""
from portage.versions import catpkgsplit
from portage import portdb
cps = []
for cpv in cpvs:
parts = catpkgsplit(cpv)
if not parts:
logger.warning(('\t' + red("Failed to split the following pkg: "
"%s, not a valid cat/pkg-ver" %cpv)))
continue
cp = parts[0] + '/' + parts[1]
try:
slot = portdb.aux_get(cpv, ["SLOT"])
except KeyError:
match, slot = get_best_match(cpv, cp, logger)
if not match:
logger.warning('\t' + red("Installed package: "
"%s is no longer available" %cp))
continue
if slot[0]:
cps.append(cp + ":" + slot[0])
else:
cps.append(cp)
return cps
开发者ID:zmedico,项目名称:gentoolkit,代码行数:30,代码来源:assign.py
示例9: validateLogfile
def validateLogfile(package, config_, target): # pylint: disable=too-many-locals
try:
my_root = os.path.join('/usr/targets', os.getenv('CURRENT_TARGET', target), 'root/')
my_trees = create_trees(config_root=my_root, target_root=my_root)
portage_db = my_trees[my_root]['vartree'].dbapi
[cpv] = portage_db.match(package)
except (InvalidAtom, ValueError):
return None
if not cpv:
return None
[license_] = portage_db.aux_get(cpv, ['LICENSE'])
if license_.lower() != 'wyplay':
return None
category, name, version, revision = catpkgsplit(cpv)
logfile = '%s:%s-%s%s:' % (category, name, version, str() if revision == 'r0' else '-%s' % revision)
try:
file_ = next(fname for fname in os.listdir(config_['PORT_LOGDIR']) if fname.startswith(logfile))
except StopIteration:
return None
filepath = os.path.abspath(os.path.join(config_['PORT_LOGDIR'], file_))
with open(filepath, 'r') as fd:
compiler_pattern = r'^\s?%s-g' % config_['CHOST']
try:
line = next(l for l in fd if re.match(compiler_pattern, l))
except StopIteration:
return None
return list(v for k, v in [(' -Wall ', 'NO_WALL'), (' -Wextra ', 'NO_WEXTRA')] if k not in line)
开发者ID:frogbywyplay,项目名称:genbox_xbuilder,代码行数:32,代码来源:analyzer.py
示例10: convert_myoldbest
def convert_myoldbest(myoldbest):
"""converts and colorizes a version list to a string
@param myoldbest: list
@rtype string.
"""
# Convert myoldbest from a list to a string.
myoldbest_str = ""
if myoldbest:
versions = []
for pos, pkg in enumerate(myoldbest):
key = catpkgsplit(pkg.cpv)[2] + \
"-" + catpkgsplit(pkg.cpv)[3]
if key[-3:] == "-r0":
key = key[:-3]
versions.append(key)
myoldbest_str = blue("["+", ".join(versions)+"]")
return myoldbest_str
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:18,代码来源:output.py
示例11: mapPathsToAtoms
def mapPathsToAtoms(self, paths):
rValue = set()
vardb = self._db
aux_get = vardb.aux_get
aux_keys = ["SLOT"]
for link, p in vardb._owners.iter_owners(paths):
cat, pn = catpkgsplit(link.mycpv)[:2]
slot, = aux_get(link.mycpv, aux_keys)
rValue.add("%s/%s:%s" % (cat, pn, slot))
return rValue
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:10,代码来源:dbapi.py
示例12: load
def load(self):
atoms = []
xmatch = self._portdb.xmatch
xmatch_level = "bestmatch-visible"
cp_list = self._vardb.cp_list
aux_get = self._vardb.aux_get
aux_keys = ["SLOT"]
for cp in self._vardb.cp_all():
for cpv in cp_list(cp):
slot, = aux_get(cpv, aux_keys)
slot_atom = "%s:%s" % (cp, slot)
ebuild = xmatch(xmatch_level, slot_atom)
if not ebuild:
continue
ebuild_split = catpkgsplit(ebuild)[1:]
installed_split = catpkgsplit(cpv)[1:]
if pkgcmp(installed_split, ebuild_split) > 0:
atoms.append(slot_atom)
self._setAtoms(atoms)
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:20,代码来源:dbapi.py
示例13: get_ver_str
def get_ver_str(pkg):
"""Obtains the version string
@param pkg: _emerge.Package.Package instance
@rtype string
"""
ver_str = list(catpkgsplit(pkg.cpv)[2:])
if ver_str[1] == "r0":
ver_str[1] = ""
else:
ver_str[1] = "-" + ver_str[1]
return ver_str[0]+ver_str[1]
开发者ID:zy-sunshine,项目名称:easymgc,代码行数:11,代码来源:output.py
示例14: __init__
def __init__(self, atom):
atom = Atom(atom)
self.cp = atom.cp
self.cpv = atom.cpv
self.cpv_split = catpkgsplit(self.cpv)
self.slot = atom.slot
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:Neuvoo,项目名称:legacy-portage,代码行数:12,代码来源:test_match_from_list.py
示例15: convert_myoldbest
def convert_myoldbest(self, pkg, myoldbest):
"""converts and colorizes a version list to a string
@param pkg: _emerge.Package.Package instance
@param myoldbest: list
@rtype string.
"""
# Convert myoldbest from a list to a string.
myoldbest_str = ""
if myoldbest:
versions = []
for pos, old_pkg in enumerate(myoldbest):
key = catpkgsplit(old_pkg.cpv)[2] + "-" + catpkgsplit(old_pkg.cpv)[3]
if key[-3:] == "-r0":
key = key[:-3]
if self.conf.verbosity == 3 and not self.quiet_repo_display and (self.verbose_main_repo_display or
any(x.repo != self.portdb.repositories.mainRepo().name for x in myoldbest + [pkg])):
key += _repo_separator + old_pkg.repo
versions.append(key)
myoldbest_str = blue("["+", ".join(versions)+"]")
return myoldbest_str
开发者ID:zy-sunshine,项目名称:easymgc,代码行数:21,代码来源:output.py
示例16: package_version_ebuild
def package_version_ebuild(request, overlay, cpv):
category, package, version, revision = catpkgsplit(cpv)
pkg = get_object_or_404(Package, category=category, name=package)
obj = get_object_or_404(Version, package=pkg, version=version,
revision=revision, overlay=overlay)
if obj.ebuild_path:
try:
with open(obj.ebuild_path) as ebuild_file:
content = ebuild_file.read()
except IOError:
return HttpResponseNotFound()
else:
return HttpResponseNotFound()
return HttpResponse(content, content_type="text/plain")
开发者ID:EvaSDK,项目名称:euscan,代码行数:15,代码来源:views.py
示例17: pkgsplit
def pkgsplit(pkgname):
"""
Custom pkgsplit
"""
cpv={'cat':'','pkg':'','ver':''}
cpvr = catpkgsplit(pkgname)
if cpvr is None:
pkgsplit = pkgname.split('/')
cpv['cat'] = pkgsplit[0]
cpv['pkg'] = pkgsplit[1]
else:
cpv['cat'] = cpvr[0]
cpv['pkg'] = cpvr[1]
cpv['ver'] = cpvr[2]
if cpvr[3] != 'r0':
cpv['ver'] = cpv['ver'] + '-' + cpvr[3]
return cpv
开发者ID:gktrk,项目名称:gentoostats,代码行数:17,代码来源:helpers.py
示例18: _getCP
def _getCP(self, pkg):
# drop ><= from the beginning
if pkg[0] in (">", "<", "="):
pkg = pkg[1:]
if pkg[0] == "=":
pkg = pkg[1:]
dotPos = pkg.find(":")
bracketPos = pkg.find("[")
if dotPos > 0:
pkg = pkg[0:dotPos]
elif bracketPos > 0:
pkg = pkg[0:bracketPos]
res = catpkgsplit(pkg)
if res:
return res[0] + "/" + res[1]
return pkg
开发者ID:gentoo-mirror,项目名称:maekke,代码行数:17,代码来源:check-subslot-deps.py
示例19: __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
示例20: dep_getkey
def dep_getkey(mydep):
"""
Return the category/package-name of a depstring.
Example usage:
>>> dep_getkey('=media-libs/test-3.0')
'media-libs/test'
@param mydep: The depstring to retrieve the category/package-name of
@type mydep: String
@rtype: String
@return: The package category/package-name
"""
if isinstance(mydep, Atom):
return mydep.cp
try:
return Atom(mydep).cp
except InvalidAtom:
try:
atom = Atom('=' + mydep)
except InvalidAtom:
pass
else:
warnings.warn(_("invalid input to %s: '%s', use %s instead") % \
('portage.dep.dep_getkey()', mydep, 'portage.cpv_getkey()'),
DeprecationWarning, stacklevel=2)
return atom.cp
# Fall back to legacy code for backward compatibility.
warnings.warn(_("%s is deprecated, use %s instead") % \
('portage.dep.dep_getkey()', 'portage.dep.Atom.cp'),
DeprecationWarning, stacklevel=2)
mydep = dep_getcpv(mydep)
if mydep and isspecific(mydep):
mysplit = catpkgsplit(mydep)
if not mysplit:
return mydep
return mysplit[0] + "/" + mysplit[1]
else:
return mydep
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:40,代码来源:__init__.py
注:本文中的portage.versions.catpkgsplit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论