本文整理匯總了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
示例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