Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
0cb85d57
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
0cb85d57
编写于
10月 09, 2019
作者:
X
Xavier Fernandez
提交者:
Xavier Fernandez
10月 10, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bump contextlib2 to latest version 0.6.0
上级
af3062af
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
7 deletion
+89
-7
news/contextlib2.vendor
news/contextlib2.vendor
+1
-1
src/pip/_vendor/contextlib2.py
src/pip/_vendor/contextlib2.py
+87
-5
src/pip/_vendor/vendor.txt
src/pip/_vendor/vendor.txt
+1
-1
未找到文件。
news/contextlib2.vendor
浏览文件 @
0cb85d57
Add contextlib2 as a vendored dependency.
Add contextlib2
0.6.0
as a vendored dependency.
src/pip/_vendor/contextlib2.py
浏览文件 @
0cb85d57
"""contextlib2 - backports and enhancements to the contextlib module"""
import
abc
import
sys
import
warnings
from
collections
import
deque
from
functools
import
wraps
__all__
=
[
"contextmanager"
,
"closing"
,
"ContextDecorator"
,
"ExitStack"
,
__all__
=
[
"contextmanager"
,
"closing"
,
"nullcontext"
,
"AbstractContextManager"
,
"ContextDecorator"
,
"ExitStack"
,
"redirect_stdout"
,
"redirect_stderr"
,
"suppress"
]
# Backwards compatibility
__all__
+=
[
"ContextStack"
]
# Backport abc.ABC
if
sys
.
version_info
[:
2
]
>=
(
3
,
4
):
_abc_ABC
=
abc
.
ABC
else
:
_abc_ABC
=
abc
.
ABCMeta
(
'ABC'
,
(
object
,),
{
'__slots__'
:
()})
# Backport classic class MRO
def
_classic_mro
(
C
,
result
):
if
C
in
result
:
return
result
.
append
(
C
)
for
B
in
C
.
__bases__
:
_classic_mro
(
B
,
result
)
return
result
# Backport _collections_abc._check_methods
def
_check_methods
(
C
,
*
methods
):
try
:
mro
=
C
.
__mro__
except
AttributeError
:
mro
=
tuple
(
_classic_mro
(
C
,
[]))
for
method
in
methods
:
for
B
in
mro
:
if
method
in
B
.
__dict__
:
if
B
.
__dict__
[
method
]
is
None
:
return
NotImplemented
break
else
:
return
NotImplemented
return
True
class
AbstractContextManager
(
_abc_ABC
):
"""An abstract base class for context managers."""
def
__enter__
(
self
):
"""Return `self` upon entering the runtime context."""
return
self
@
abc
.
abstractmethod
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
"""Raise any exception triggered within the runtime context."""
return
None
@
classmethod
def
__subclasshook__
(
cls
,
C
):
"""Check whether subclass is considered a subclass of this ABC."""
if
cls
is
AbstractContextManager
:
return
_check_methods
(
C
,
"__enter__"
,
"__exit__"
)
return
NotImplemented
class
ContextDecorator
(
object
):
"
A base class or mixin that enables context managers to work as decorators.
"
"
""A base class or mixin that enables context managers to work as decorators.""
"
def
refresh_cm
(
self
):
"""Returns the context manager used to actually wrap the call to the
...
...
@@ -176,8 +235,10 @@ class closing(object):
"""
def
__init__
(
self
,
thing
):
self
.
thing
=
thing
def
__enter__
(
self
):
return
self
.
thing
def
__exit__
(
self
,
*
exc_info
):
self
.
thing
.
close
()
...
...
@@ -289,7 +350,7 @@ else:
# but use exec to avoid SyntaxError in Python 3
def
_reraise_with_existing_context
(
exc_details
):
exc_type
,
exc_value
,
exc_tb
=
exc_details
exec
(
"raise exc_type, exc_value, exc_tb"
)
exec
(
"raise exc_type, exc_value, exc_tb"
)
# Handle old-style classes if they exist
try
:
...
...
@@ -302,8 +363,9 @@ else:
def
_get_type
(
obj
):
obj_type
=
type
(
obj
)
if
obj_type
is
InstanceType
:
return
obj
.
__class__
# Old-style class
return
obj_type
# New-style class
return
obj
.
__class__
# Old-style class
return
obj_type
# New-style class
# Inspired by discussions on http://bugs.python.org/issue13585
class
ExitStack
(
object
):
...
...
@@ -417,6 +479,7 @@ class ExitStack(object):
_reraise_with_existing_context
(
exc_details
)
return
received_exc
and
suppressed_exc
# Preserve backwards compatibility
class
ContextStack
(
ExitStack
):
"""Backwards compatibility alias for ExitStack"""
...
...
@@ -434,3 +497,22 @@ class ContextStack(ExitStack):
def
preserve
(
self
):
return
self
.
pop_all
()
class
nullcontext
(
AbstractContextManager
):
"""Context manager that does no additional processing.
Used as a stand-in for a normal context manager, when a particular
block of code is only sometimes used with a normal context manager:
cm = optional_cm if condition else nullcontext()
with cm:
# Perform operation, using optional_cm if condition is True
"""
def
__init__
(
self
,
enter_result
=
None
):
self
.
enter_result
=
enter_result
def
__enter__
(
self
):
return
self
.
enter_result
def
__exit__
(
self
,
*
excinfo
):
pass
src/pip/_vendor/vendor.txt
浏览文件 @
0cb85d57
appdirs==1.4.3
CacheControl==0.12.5
colorama==0.4.1
contextlib2==0.
5.5
contextlib2==0.
6.0
distlib==0.2.9.post0
distro==1.4.0
html5lib==1.0.1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录