本文整理汇总了Python中conda.models.match_spec.MatchSpec.match方法的典型用法代码示例。如果您正苦于以下问题:Python MatchSpec.match方法的具体用法?Python MatchSpec.match怎么用?Python MatchSpec.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类conda.models.match_spec.MatchSpec
的用法示例。
在下文中一共展示了MatchSpec.match方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index_record
# 需要导入模块: from conda.models.match_spec import MatchSpec [as 别名]
# 或者: from conda.models.match_spec.MatchSpec import match [as 别名]
def test_index_record(self):
dst = Dist('defaults::foo-1.2.3-4.tar.bz2')
rec = DPkg(dst)
a = MatchSpec(dst)
b = MatchSpec(rec)
assert b.match(rec.dump())
assert b.match(rec)
assert a.match(rec)
示例2: test_dist
# 需要导入模块: from conda.models.match_spec import MatchSpec [as 别名]
# 或者: from conda.models.match_spec.MatchSpec import match [as 别名]
def test_dist(self):
with env_unmodified(conda_tests_ctxt_mgmt_def_pol):
dst = Dist('defaults::foo-1.2.3-4.tar.bz2')
a = MatchSpec(dst)
b = MatchSpec(a)
c = MatchSpec(dst, optional=True, target='burg')
d = MatchSpec(a, build='5')
assert a == b
assert hash(a) == hash(b)
assert a is b
assert a != c
assert hash(a) != hash(c)
assert a != d
assert hash(a) != hash(d)
p = MatchSpec(channel='defaults',name='python',version=VersionSpec('3.5*'))
assert p.match(Dist(channel='defaults', dist_name='python-3.5.3-1', name='python',
version='3.5.3', build_string='1', build_number=1, base_url=None,
platform=None))
assert not p.match(Dist(channel='defaults', dist_name='python-3.6.0-0', name='python',
version='3.6.0', build_string='0', build_number=0, base_url=None,
platform=None))
assert p.match(Dist(channel='defaults', dist_name='python-3.5.1-0', name='python',
version='3.5.1', build_string='0', build_number=0, base_url=None,
platform=None))
assert p.match(PackageRecord(name='python', version='3.5.1', build='0', build_number=0,
depends=('openssl 1.0.2*', 'readline 6.2*', 'sqlite',
'tk 8.5*', 'xz 5.0.5', 'zlib 1.2*', 'pip'),
channel=Channel(scheme='https', auth=None,
location='repo.anaconda.com', token=None,
name='pkgs/main', platform='osx-64',
package_filename=None),
subdir='osx-64', fn='python-3.5.1-0.tar.bz2',
md5='a813bc0a32691ab3331ac9f37125164c', size=14678857,
priority=0,
url='https://repo.anaconda.com/pkgs/main/osx-64/python-3.5.1-0.tar.bz2'))
示例3: test_match_1
# 需要导入模块: from conda.models.match_spec import MatchSpec [as 别名]
# 或者: from conda.models.match_spec.MatchSpec import match [as 别名]
def test_match_1(self):
for spec, result in [
('numpy 1.7*', True), ('numpy 1.7.1', True),
('numpy 1.7', False), ('numpy 1.5*', False),
('numpy >=1.5', True), ('numpy >=1.5,<2', True),
('numpy >=1.8,<1.9', False), ('numpy >1.5,<2,!=1.7.1', False),
('numpy >1.8,<2|==1.7', False),('numpy >1.8,<2|>=1.7.1', True),
('numpy >=1.8|1.7*', True), ('numpy ==1.7', False),
('numpy >=1.5,>1.6', True), ('numpy ==1.7.1', True),
('numpy ==1.7.1.0', True), ('numpy==1.7.1.0.0', True),
('numpy >=1,*.7.*', True), ('numpy *.7.*,>=1', True),
('numpy >=1,*.8.*', False), ('numpy >=2,*.7.*', False),
('numpy 1.6*|1.7*', True), ('numpy 1.6*|1.8*', False),
('numpy 1.6.2|1.7*', True), ('numpy 1.6.2|1.7.1', True),
('numpy 1.6.2|1.7.0', False), ('numpy 1.7.1 py27_0', True),
('numpy 1.7.1 py26_0', False), ('numpy >1.7.1a', True),
('python', False),
]:
m = MatchSpec(spec)
assert m.match(DPkg('numpy-1.7.1-py27_0.tar.bz2')) == result
assert 'name' in m
assert m.name == 'python' or 'version' in m
# both version numbers conforming to PEP 440
assert not MatchSpec('numpy >=1.0.1').match(DPkg('numpy-1.0.1a-0.tar.bz2'))
# both version numbers non-conforming to PEP 440
assert not MatchSpec('numpy >=1.0.1.vc11').match(DPkg('numpy-1.0.1a.vc11-0.tar.bz2'))
assert MatchSpec('numpy >=1.0.1*.vc11').match(DPkg('numpy-1.0.1a.vc11-0.tar.bz2'))
# one conforming, other non-conforming to PEP 440
assert MatchSpec('numpy <1.0.1').match(DPkg('numpy-1.0.1.vc11-0.tar.bz2'))
assert MatchSpec('numpy <1.0.1').match(DPkg('numpy-1.0.1a.vc11-0.tar.bz2'))
assert not MatchSpec('numpy >=1.0.1.vc11').match(DPkg('numpy-1.0.1a-0.tar.bz2'))
assert MatchSpec('numpy >=1.0.1a').match(DPkg('numpy-1.0.1z-0.tar.bz2'))
assert MatchSpec('numpy >=1.0.1a py27*').match(DPkg('numpy-1.0.1z-py27_1.tar.bz2'))
assert MatchSpec('blas * openblas_0').match(DPkg('blas-1.0-openblas_0.tar.bz2'))
assert MatchSpec('blas')._is_simple()
assert not MatchSpec('blas 1.0')._is_simple()
assert not MatchSpec('blas 1.0 1')._is_simple()
m = MatchSpec('blas 1.0', optional=True)
m2 = MatchSpec(m, optional=False)
m3 = MatchSpec(m2, target='blas-1.0-0.tar.bz2')
m4 = MatchSpec(m3, target=None, optional=True)
assert m.spec == m2.spec and m.optional != m2.optional
assert m2.spec == m3.spec and m2.optional == m3.optional and m2.target != m3.target
assert m == m4
self.assertRaises(ValueError, MatchSpec, (1, 2, 3))
示例4: test_track_features_match
# 需要导入模块: from conda.models.match_spec import MatchSpec [as 别名]
# 或者: from conda.models.match_spec.MatchSpec import match [as 别名]
def test_track_features_match(self):
dst = Dist('defaults::foo-1.2.3-4.tar.bz2')
a = MatchSpec(features='test')
assert text_type(a) == "*[features=test]"
assert not a.match(DPkg(dst))
assert not a.match(DPkg(dst, track_features=''))
a = MatchSpec(track_features='test')
assert a.match(DPkg(dst, track_features='test'))
assert not a.match(DPkg(dst, track_features='test2'))
assert not a.match(DPkg(dst, track_features='test me'))
assert not a.match(DPkg(dst, track_features='you test'))
assert not a.match(DPkg(dst, track_features='you test me'))
assert a.get_exact_value('track_features') == frozenset(('test',))
b = MatchSpec(track_features='mkl')
assert not b.match(DPkg(dst))
assert b.match(DPkg(dst, track_features='mkl'))
assert b.match(DPkg(dst, track_features='mkl'))
assert not b.match(DPkg(dst, track_features='mkl debug'))
assert not b.match(DPkg(dst, track_features='debug'))
c = MatchSpec(track_features='nomkl')
assert not c.match(DPkg(dst))
assert not c.match(DPkg(dst, track_features='mkl'))
assert c.match(DPkg(dst, track_features='nomkl'))
assert not c.match(DPkg(dst, track_features='nomkl debug'))
# regression test for #6860
d = MatchSpec(track_features='')
assert d.get_exact_value('track_features') == frozenset()
d = MatchSpec(track_features=' ')
assert d.get_exact_value('track_features') == frozenset()
d = MatchSpec(track_features=('', ''))
assert d.get_exact_value('track_features') == frozenset()
d = MatchSpec(track_features=('', '', 'test'))
assert d.get_exact_value('track_features') == frozenset(('test',))