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


Python Dist.to_url方法代码示例

本文整理汇总了Python中conda.models.dist.Dist.to_url方法的典型用法代码示例。如果您正苦于以下问题:Python Dist.to_url方法的具体用法?Python Dist.to_url怎么用?Python Dist.to_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在conda.models.dist.Dist的用法示例。


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

示例1: test_dist_with_non_channel_url

# 需要导入模块: from conda.models.dist import Dist [as 别名]
# 或者: from conda.models.dist.Dist import to_url [as 别名]
    def test_dist_with_non_channel_url(self):
        # contrived url
        url = "https://repo.anaconda.com/pkgs/anaconda/cffi-1.9.1-py34_0.tar.bz2"
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False

        # file url that is not a channel
        url = path_to_url(join_url(context.croot, 'cffi-1.9.1-py34_0.tar.bz2'))
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False

        # file url that is a package cache
        # TODO: maybe this should look up the channel in urls.txt?  or maybe that's too coupled?
        url = join_url(path_to_url(context.pkgs_dirs[0]), 'cffi-1.9.1-py34_0.tar.bz2')
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False
开发者ID:scopatz,项目名称:conda,代码行数:36,代码来源:test_dist.py

示例2: test_dist_with_channel_url

# 需要导入模块: from conda.models.dist import Dist [as 别名]
# 或者: from conda.models.dist.Dist import to_url [as 别名]
    def test_dist_with_channel_url(self):
        # standard named channel
        url = "https://repo.anaconda.com/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'defaults'
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # standard url channel
        url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'defaults'  # because pkgs/anaconda is in defaults
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # another standard url channel
        url = "https://not.real.continuum.io/not/anaconda/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'https://not.real.continuum.io/not/anaconda'
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # local file url that is a named channel
        conda_bld_path = join(gettempdir(), 'conda-bld')
        try:
            mkdir_p(conda_bld_path)
            with env_var('CONDA_BLD_PATH', conda_bld_path, stack_callback=conda_tests_ctxt_mgmt_def_pol):
                url = path_to_url(join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2'))
                d = Dist(url)
                assert d.channel == 'local'
                assert d.name == 'bcrypt'
                assert d.version == '3.1.1'
                assert d.build_string == 'py35_2'

                assert d.to_url() == url
                assert d.is_channel is True
        finally:
            rm_rf(conda_bld_path)

        # local file url that is not a named channel
        url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')
        d = Dist(url)
        assert d.channel == 'file:///some/location/on/disk'
        assert d.name == 'bcrypt'
        assert d.version == '3.1.1'
        assert d.build_string == 'py35_2'

        assert d.to_url() == url
        assert d.is_channel is True
开发者ID:scopatz,项目名称:conda,代码行数:63,代码来源:test_dist.py


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