当前位置: 首页>>代码示例>>Python>>正文


Python match_spec.MatchSpec类代码示例

本文整理汇总了Python中conda.models.match_spec.MatchSpec的典型用法代码示例。如果您正苦于以下问题:Python MatchSpec类的具体用法?Python MatchSpec怎么用?Python MatchSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MatchSpec类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_merge_single_name

    def test_merge_single_name(self):
        specs = (MatchSpec('exact'), MatchSpec('exact 1.2.3 1'), MatchSpec('exact >1.0,<2'))
        merged_specs = MatchSpec.merge(specs)
        print(merged_specs)
        assert len(merged_specs) == 1
        merged_spec = merged_specs[0]
        print(merged_spec)
        assert str(merged_spec) == "exact[version='1.2.3,>1.0,<2',build=1]"
        assert merged_spec.match({
            'name': 'exact',
            'version': '1.2.3',
            'build': '1',
            'build_number': 1,
        })
        assert not merged_spec.match({
            'name': 'exact',
            'version': '1.2.2',
            'build': '1',
            'build_number': 1,
        })

        specs = (MatchSpec('exact 1.2.3 1'), MatchSpec('exact 1.2.3 2'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)

        merged_specs = MatchSpec.merge((MatchSpec('exact 1.2.3 1'),))
        assert len(merged_specs) == 1
        assert str(merged_specs[0]) == "exact==1.2.3=1"
开发者ID:njalerikson,项目名称:conda,代码行数:28,代码来源:test_match_spec.py

示例2: test_index_record

 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)
开发者ID:njalerikson,项目名称:conda,代码行数:8,代码来源:test_match_spec.py

示例3: test_md5_merge_with_name

    def test_md5_merge_with_name(self):
        specs = (MatchSpec('python[md5=deadbeef]'), MatchSpec('python=1.2.3'), MatchSpec('conda-forge::python[md5=deadbeef]'))
        merged = MatchSpec.merge(specs)
        assert len(merged) == 1
        assert str(merged[0]) == "conda-forge::python=1.2.3[md5=deadbeef]"

        specs = (MatchSpec('python[md5=FFBADD11]'), MatchSpec('python=1.2.3'), MatchSpec('python[md5=ffbadd11]'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)
开发者ID:njalerikson,项目名称:conda,代码行数:9,代码来源:test_match_spec.py

示例4: test_build_number_merge

    def test_build_number_merge(self):
        specs = (MatchSpec('python[build_number=1]'), MatchSpec('python=1.2.3=py27_7'), MatchSpec('conda-forge::python<=8[build_number=1]'))
        merged = MatchSpec.merge(specs)
        assert len(merged) == 1
        assert str(merged[0]) == "conda-forge::python[version='1.2.3,<=8',build=py27_7,build_number=1]"

        specs = (MatchSpec('python[build_number=2]'), MatchSpec('python=1.2.3=py27_7'), MatchSpec('python<=8[build_number=1]'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)
开发者ID:njalerikson,项目名称:conda,代码行数:9,代码来源:test_match_spec.py

示例5: test_subdir_merge

    def test_subdir_merge(self):
        specs = (MatchSpec('pkgs/main/linux-64::python'), MatchSpec('pkgs/main/linux-32::python'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)

        specs = (MatchSpec('defaults/win-32::python'), MatchSpec('defaults/win-64::python'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)

        specs = (MatchSpec('pkgs/free/linux-64::python'), MatchSpec('pkgs/free::python 1.2.3'))
        merged = MatchSpec.merge(specs)
        assert len(merged) == 1
        assert str(merged[0]) == "pkgs/free/linux-64::python==1.2.3"
        assert merged[0] == MatchSpec(channel='pkgs/free', subdir='linux-64', name='python', version='1.2.3')
开发者ID:njalerikson,项目名称:conda,代码行数:14,代码来源:test_match_spec.py

示例6: test_match_1

    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))
开发者ID:njalerikson,项目名称:conda,代码行数:49,代码来源:test_match_spec.py

示例7: test_merge_multiple_name

    def test_merge_multiple_name(self):
        specs = tuple(MatchSpec(s) for s in (
            'exact', 'exact 1.2.3 1',
            'bounded >=1.0,<2.0', 'bounded >=1.5', 'bounded <=1.8',
            'exact >1.0,<2',
        ))
        merged_specs = MatchSpec.merge(specs)
        print(merged_specs)
        assert len(merged_specs) == 2

        exact_spec = next(s for s in merged_specs if s.name == 'exact')
        bounded_spec = next(s for s in merged_specs if s.name == 'bounded')

        assert str(exact_spec) == "exact[version='1.2.3,>1.0,<2',build=1]"
        assert str(bounded_spec) == "bounded[version='>=1.0,<2.0,>=1.5,<=1.8']"

        assert not bounded_spec.match({
            'name': 'bounded',
            'version': '1',
            'build': '6',
            'build_number': 6,
        })
        assert bounded_spec.match({
            'name': 'bounded',
            'version': '1.5',
            'build': '7',
            'build_number': 7,
        })
        assert not bounded_spec.match({
            'name': 'bounded',
            'version': '2',
            'build': '8',
            'build_number': 8,
        })
开发者ID:njalerikson,项目名称:conda,代码行数:34,代码来源:test_match_spec.py

示例8: test_md5_merge_wo_name

 def test_md5_merge_wo_name(self):
     specs = (MatchSpec('*[md5=deadbeef]'), MatchSpec('*[md5=FFBADD11]'))
     merged = MatchSpec.merge(specs)
     assert len(merged) == 2
     str_specs = ('*[md5=deadbeef]', '*[md5=FFBADD11]')
     assert str(merged[0]) in str_specs
     assert str(merged[1]) in str_specs
     assert str(merged[0]) != str(merged[1])
开发者ID:njalerikson,项目名称:conda,代码行数:8,代码来源:test_match_spec.py

示例9: test_to_filename

    def test_to_filename(self):
        m1 = MatchSpec(fn='foo-1.7-52.tar.bz2')
        m2 = MatchSpec(name='foo', version='1.7', build='52')
        m3 = MatchSpec(Dist('defaults::foo-1.7-52'))
        assert m1._to_filename_do_not_use() == 'foo-1.7-52.tar.bz2'
        assert m2._to_filename_do_not_use() == 'foo-1.7-52.tar.bz2'
        assert m3._to_filename_do_not_use() == 'foo-1.7-52.tar.bz2'

        for spec in 'bitarray', 'pycosat 0.6.0', 'numpy 1.6*':
            ms = MatchSpec(spec)
            assert ms._to_filename_do_not_use() is None
开发者ID:njalerikson,项目名称:conda,代码行数:11,代码来源:test_match_spec.py

示例10: test_dist

    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'))
开发者ID:conda,项目名称:conda,代码行数:41,代码来源:test_match_spec.py

示例11: test_channel_merge

    def test_channel_merge(self):
        specs = (MatchSpec('pkgs/main::python'), MatchSpec('defaults::python'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)

        specs = (MatchSpec('defaults::python'), MatchSpec('pkgs/main::python'))
        with pytest.raises(ValueError):
            MatchSpec.merge(specs)

        specs = (MatchSpec('defaults::python'), MatchSpec('defaults::python 1.2.3'))
        merged = MatchSpec.merge(specs)
        assert len(merged) == 1
        assert str(merged[0]) == "defaults::python==1.2.3"

        specs = (MatchSpec('pkgs/free::python'), MatchSpec('pkgs/free::python 1.2.3'))
        merged = MatchSpec.merge(specs)
        assert len(merged) == 1
        assert str(merged[0]) == "pkgs/free::python==1.2.3"
开发者ID:njalerikson,项目名称:conda,代码行数:18,代码来源:test_match_spec.py

示例12: test_track_features_match

    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',))
开发者ID:njalerikson,项目名称:conda,代码行数:37,代码来源:test_match_spec.py

示例13: test_build_number_and_filename

 def test_build_number_and_filename(self):
     ms = MatchSpec('zlib 1.2.7 0')
     assert ms.get_exact_value('name') == 'zlib'
     assert ms.get_exact_value('version') == '1.2.7'
     assert ms.get_exact_value('build') == '0'
     assert ms._to_filename_do_not_use() == 'zlib-1.2.7-0.tar.bz2'
开发者ID:njalerikson,项目名称:conda,代码行数:6,代码来源:test_match_spec.py


注:本文中的conda.models.match_spec.MatchSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。