Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
4a9e3066
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4a9e3066
编写于
7月 06, 2019
作者:
C
Chris Jerdonek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add get_applicable_candidates(), and test.
上级
b2389bf8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
12 deletion
+44
-12
src/pip/_internal/index.py
src/pip/_internal/index.py
+27
-12
tests/unit/test_index.py
tests/unit/test_index.py
+17
-0
未找到文件。
src/pip/_internal/index.py
浏览文件 @
4a9e3066
...
...
@@ -507,22 +507,15 @@ class CandidateEvaluator(object):
self
.
_prefer_binary
=
prefer_binary
self
.
_supported_tags
=
supported_tags
def
make_found
_candidates
(
def
get_applicable
_candidates
(
self
,
candidates
,
# type: List[InstallationCandidate]
specifier
=
None
,
# type: Optional[specifiers.BaseSpecifier]
candidates
,
# type: List[InstallationCandidate]
specifier
,
# type: specifiers.BaseSpecifier
):
# type: (...) ->
FoundCandidates
# type: (...) ->
List[InstallationCandidate]
"""
Create and return a `FoundCandidates` instance.
:param specifier: An optional object implementing `filter`
(e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
versions.
Return the applicable candidates from a list of candidates.
"""
if
specifier
is
None
:
specifier
=
specifiers
.
SpecifierSet
()
# Using None infers from the specifier instead.
allow_prereleases
=
self
.
_allow_all_prereleases
or
None
versions
=
{
...
...
@@ -543,6 +536,28 @@ class CandidateEvaluator(object):
applicable_candidates
=
[
c
for
c
in
candidates
if
str
(
c
.
version
)
in
versions
]
return
applicable_candidates
def
make_found_candidates
(
self
,
candidates
,
# type: List[InstallationCandidate]
specifier
=
None
,
# type: Optional[specifiers.BaseSpecifier]
):
# type: (...) -> FoundCandidates
"""
Create and return a `FoundCandidates` instance.
:param specifier: An optional object implementing `filter`
(e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
versions.
"""
if
specifier
is
None
:
specifier
=
specifiers
.
SpecifierSet
()
applicable_candidates
=
self
.
get_applicable_candidates
(
candidates
=
candidates
,
specifier
=
specifier
,
)
return
FoundCandidates
(
candidates
,
...
...
tests/unit/test_index.py
浏览文件 @
4a9e3066
...
...
@@ -205,6 +205,23 @@ class TestCandidateEvaluator:
return
candidate
def
test_get_applicable_candidates
(
self
):
specifier
=
SpecifierSet
(
'<= 1.11'
)
versions
=
[
'1.10'
,
'1.11'
,
'1.12'
]
candidates
=
[
self
.
make_mock_candidate
(
version
)
for
version
in
versions
]
evaluator
=
CandidateEvaluator
.
create
()
actual
=
evaluator
.
get_applicable_candidates
(
candidates
,
specifier
=
specifier
,
)
expected_applicable
=
candidates
[:
2
]
assert
[
str
(
c
.
version
)
for
c
in
expected_applicable
]
==
[
'1.10'
,
'1.11'
,
]
assert
actual
==
expected_applicable
def
test_make_found_candidates
(
self
):
specifier
=
SpecifierSet
(
'<= 1.11'
)
versions
=
[
'1.10'
,
'1.11'
,
'1.12'
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录