本文整理汇总了Python中Pkg.rangeCompare方法的典型用法代码示例。如果您正苦于以下问题:Python Pkg.rangeCompare方法的具体用法?Python Pkg.rangeCompare怎么用?Python Pkg.rangeCompare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pkg
的用法示例。
在下文中一共展示了Pkg.rangeCompare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: import Pkg [as 别名]
# 或者: from Pkg import rangeCompare [as 别名]
#.........这里部分代码省略.........
# if name == provide_name:
# printWarning(pkg, 'package-provides-itself')
# break
def split_license(license):
return (x.strip() for x in
(l for l in license_regex.split(license) if l))
rpm_license = pkg[rpm.RPMTAG_LICENSE]
if not rpm_license:
printError(pkg, 'no-license')
else:
valid_license = True
if rpm_license not in VALID_LICENSES:
for l1 in split_license(rpm_license):
if l1 in VALID_LICENSES:
continue
for l2 in split_license(l1):
if l2 not in VALID_LICENSES:
printWarning(pkg, 'invalid-license', l2)
valid_license = False
if not valid_license:
self._unexpanded_macros(pkg, 'License', rpm_license)
for tag in ('URL', 'DistURL', 'BugURL'):
if hasattr(rpm, 'RPMTAG_%s' % tag.upper()):
url = Pkg.b2s(pkg[getattr(rpm, 'RPMTAG_%s' % tag.upper())])
self._unexpanded_macros(pkg, tag, url, is_url=True)
if url:
(scheme, netloc) = urlparse(url)[0:2]
if not scheme or not netloc or "." not in netloc or \
scheme not in ('http', 'https', 'ftp') or \
(Config.getOption('InvalidURL') and
invalid_url_regex.search(url)):
printWarning(pkg, 'invalid-url', tag, url)
else:
self.check_url(pkg, tag, url)
elif tag == 'URL':
printWarning(pkg, 'no-url-tag')
obs_names = [x[0] for x in pkg.obsoletes()]
prov_names = [x[0] for x in pkg.provides()]
for o in (x for x in obs_names if x not in prov_names):
printWarning(pkg, 'obsolete-not-provided', o)
for o in pkg.obsoletes():
value = Pkg.formatRequire(*o)
self._unexpanded_macros(pkg, 'Obsoletes %s' % (value,), value)
# TODO: should take versions, <, <=, =, >=, > into account here
# https://bugzilla.redhat.com/460872
useless_provides = []
for p in prov_names:
if prov_names.count(p) != 1 and p not in useless_provides:
useless_provides.append(p)
for p in useless_provides:
printError(pkg, 'useless-provides', p)
for p in pkg.provides():
value = Pkg.formatRequire(*p)
self._unexpanded_macros(pkg, 'Provides %s' % (value,), value)
for c in pkg.conflicts():
value = Pkg.formatRequire(*c)
self._unexpanded_macros(pkg, 'Conflicts %s' % (value,), value)
obss = pkg.obsoletes()
if obss:
provs = pkg.provides()
for prov in provs:
for obs in obss:
if Pkg.rangeCompare(obs, prov):
printWarning(pkg, 'self-obsoletion',
'%s obsoletes %s' %
(Pkg.formatRequire(*obs),
Pkg.formatRequire(*prov)))
expfmt = rpm.expandMacro("%{_build_name_fmt}")
if pkg.isSource():
# _build_name_fmt often (always?) ends up not outputting src/nosrc
# as arch for source packages, do it ourselves
expfmt = re.sub(r'(?i)%\{?ARCH\b\}?', pkg.arch, expfmt)
expected = pkg.header.sprintf(expfmt).split("/")[-1]
basename = os.path.basename(pkg.filename)
if basename != expected:
printWarning(pkg, 'non-coherent-filename', basename, expected)
for tag in ('Distribution', 'DistTag', 'ExcludeArch', 'ExcludeOS',
'Vendor'):
if hasattr(rpm, 'RPMTAG_%s' % tag.upper()):
self._unexpanded_macros(pkg, tag,
Pkg.b2s(pkg[getattr(rpm, 'RPMTAG_%s' % tag.upper())]))
for path in private_so_paths:
for fname, pkgfile in pkg.files().items():
if fname.startswith(path):
for prov in pkgfile.provides:
if so_dep_regex.search(prov[0]):
printWarning(pkg, "private-shared-object-provides",
fname, Pkg.formatRequire(*prov))
示例2: test_rangeCompare
# 需要导入模块: import Pkg [as 别名]
# 或者: from Pkg import rangeCompare [as 别名]
def test_rangeCompare(self):
for (req, prov) in (
(("foo", rpm.RPMSENSE_LESS, (None, "1.0", None)),
("foo", rpm.RPMSENSE_EQUAL, ("1", "0.5", None))),
):
self.assertFalse(Pkg.rangeCompare(req, prov))