Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
94b77130
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,发现更多精彩内容 >>
未验证
提交
94b77130
编写于
2月 01, 2020
作者:
S
Stéphane Bidoul
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add WheelCache method to inform which cache was used
Return whether the link was found in the persistent or ephemeral cache.
上级
f7794473
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
2 deletion
+55
-2
src/pip/_internal/cache.py
src/pip/_internal/cache.py
+32
-2
tests/unit/test_cache.py
tests/unit/test_cache.py
+23
-0
未找到文件。
src/pip/_internal/cache.py
浏览文件 @
94b77130
...
...
@@ -270,6 +270,16 @@ class EphemWheelCache(SimpleWheelCache):
)
class
CacheEntry
(
object
):
def
__init__
(
self
,
link
,
# type: Link
persistent
,
# type: bool
):
self
.
link
=
link
self
.
persistent
=
persistent
class
WheelCache
(
Cache
):
"""Wraps EphemWheelCache and SimpleWheelCache into a single Cache
...
...
@@ -304,16 +314,36 @@ class WheelCache(Cache):
supported_tags
,
# type: List[Tag]
):
# type: (...) -> Link
cache_entry
=
self
.
get_cache_entry
(
link
,
package_name
,
supported_tags
)
if
cache_entry
is
None
:
return
link
return
cache_entry
.
link
def
get_cache_entry
(
self
,
link
,
# type: Link
package_name
,
# type: Optional[str]
supported_tags
,
# type: List[Tag]
):
# type: (...) -> Optional[CacheEntry]
"""Returns a CacheEntry with a link to a cached item if it exists or
None. The cache entry indicates if the item was found in the persistent
or ephemeral cache.
"""
retval
=
self
.
_wheel_cache
.
get
(
link
=
link
,
package_name
=
package_name
,
supported_tags
=
supported_tags
,
)
if
retval
is
not
link
:
return
retval
return
CacheEntry
(
retval
,
persistent
=
True
)
ret
urn
self
.
_ephem_cache
.
get
(
ret
val
=
self
.
_ephem_cache
.
get
(
link
=
link
,
package_name
=
package_name
,
supported_tags
=
supported_tags
,
)
if
retval
is
not
link
:
return
CacheEntry
(
retval
,
persistent
=
False
)
return
None
tests/unit/test_cache.py
浏览文件 @
94b77130
...
...
@@ -90,3 +90,26 @@ def test_get_with_legacy_entry_only(tmpdir):
os
.
path
.
normcase
(
os
.
path
.
dirname
(
cached_link
.
file_path
))
==
os
.
path
.
normcase
(
legacy_path
)
)
def
test_get_cache_entry
(
tmpdir
):
wc
=
WheelCache
(
tmpdir
,
FormatControl
())
persi_link
=
Link
(
"https://g.c/o/r/persi"
)
persi_path
=
wc
.
get_path_for_link
(
persi_link
)
ensure_dir
(
persi_path
)
with
open
(
os
.
path
.
join
(
persi_path
,
"persi-1.0.0-py3-none-any.whl"
),
"w"
):
pass
ephem_link
=
Link
(
"https://g.c/o/r/ephem"
)
ephem_path
=
wc
.
get_ephem_path_for_link
(
ephem_link
)
ensure_dir
(
ephem_path
)
with
open
(
os
.
path
.
join
(
ephem_path
,
"ephem-1.0.0-py3-none-any.whl"
),
"w"
):
pass
other_link
=
Link
(
"https://g.c/o/r/other"
)
supported_tags
=
[
Tag
(
"py3"
,
"none"
,
"any"
)]
assert
(
wc
.
get_cache_entry
(
persi_link
,
"persi"
,
supported_tags
).
persistent
)
assert
(
not
wc
.
get_cache_entry
(
ephem_link
,
"ephem"
,
supported_tags
).
persistent
)
assert
wc
.
get_cache_entry
(
other_link
,
"other"
,
supported_tags
)
is
None
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录