Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
5bc94f33
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,发现更多精彩内容 >>
提交
5bc94f33
编写于
4月 26, 2018
作者:
J
Jeremy Zafran
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move remove_auth_from_url and test from Subversion class to pip._internal.utils.misc
上级
e1abd238
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
49 deletion
+51
-49
src/pip/_internal/utils/misc.py
src/pip/_internal/utils/misc.py
+20
-1
src/pip/_internal/vcs/subversion.py
src/pip/_internal/vcs/subversion.py
+3
-21
tests/unit/test_utils.py
tests/unit/test_utils.py
+28
-1
tests/unit/test_vcs.py
tests/unit/test_vcs.py
+0
-26
未找到文件。
src/pip/_internal/utils/misc.py
浏览文件 @
5bc94f33
...
@@ -24,6 +24,7 @@ from pip._vendor import pkg_resources
...
@@ -24,6 +24,7 @@ from pip._vendor import pkg_resources
from
pip._vendor.retrying
import
retry
# type: ignore
from
pip._vendor.retrying
import
retry
# type: ignore
from
pip._vendor.six
import
PY2
from
pip._vendor.six
import
PY2
from
pip._vendor.six.moves
import
input
from
pip._vendor.six.moves
import
input
from
pip._vendor.six.moves.urllib
import
parse
as
urllib_parse
from
pip._internal.compat
import
console_to_str
,
expanduser
,
stdlib_pkgs
from
pip._internal.compat
import
console_to_str
,
expanduser
,
stdlib_pkgs
from
pip._internal.exceptions
import
InstallationError
from
pip._internal.exceptions
import
InstallationError
...
@@ -47,7 +48,7 @@ __all__ = ['rmtree', 'display_path', 'backup_dir',
...
@@ -47,7 +48,7 @@ __all__ = ['rmtree', 'display_path', 'backup_dir',
'unzip_file'
,
'untar_file'
,
'unpack_file'
,
'call_subprocess'
,
'unzip_file'
,
'untar_file'
,
'unpack_file'
,
'call_subprocess'
,
'captured_stdout'
,
'ensure_dir'
,
'captured_stdout'
,
'ensure_dir'
,
'ARCHIVE_EXTENSIONS'
,
'SUPPORTED_EXTENSIONS'
,
'ARCHIVE_EXTENSIONS'
,
'SUPPORTED_EXTENSIONS'
,
'get_installed_version'
]
'get_installed_version'
,
'remove_auth_from_url'
]
logger
=
std_logging
.
getLogger
(
__name__
)
logger
=
std_logging
.
getLogger
(
__name__
)
...
@@ -849,3 +850,21 @@ def enum(*sequential, **named):
...
@@ -849,3 +850,21 @@ def enum(*sequential, **named):
reverse
=
{
value
:
key
for
key
,
value
in
enums
.
items
()}
reverse
=
{
value
:
key
for
key
,
value
in
enums
.
items
()}
enums
[
'reverse_mapping'
]
=
reverse
enums
[
'reverse_mapping'
]
=
reverse
return
type
(
'Enum'
,
(),
enums
)
return
type
(
'Enum'
,
(),
enums
)
def
remove_auth_from_url
(
url
):
# Return a copy of url with 'username:password@' removed.
# username/pass params are passed to subversion through flags
# and are not recognized in the url.
# parsed url
purl
=
urllib_parse
.
urlsplit
(
url
)
stripped_netloc
=
\
purl
.
netloc
.
split
(
'@'
)[
-
1
]
# stripped url
url_pieces
=
(
purl
.
scheme
,
stripped_netloc
,
purl
.
path
,
purl
.
query
,
purl
.
fragment
)
surl
=
urllib_parse
.
urlunsplit
(
url_pieces
)
return
surl
src/pip/_internal/vcs/subversion.py
浏览文件 @
5bc94f33
...
@@ -8,7 +8,7 @@ from pip._vendor.six.moves.urllib import parse as urllib_parse
...
@@ -8,7 +8,7 @@ from pip._vendor.six.moves.urllib import parse as urllib_parse
from
pip._internal.index
import
Link
from
pip._internal.index
import
Link
from
pip._internal.utils.logging
import
indent_log
from
pip._internal.utils.logging
import
indent_log
from
pip._internal.utils.misc
import
display_path
,
rmtree
from
pip._internal.utils.misc
import
display_path
,
r
emove_auth_from_url
,
r
mtree
from
pip._internal.vcs
import
VersionControl
,
vcs
from
pip._internal.vcs
import
VersionControl
,
vcs
_svn_xml_url_re
=
re
.
compile
(
'url="([^"]+)"'
)
_svn_xml_url_re
=
re
.
compile
(
'url="([^"]+)"'
)
...
@@ -63,7 +63,7 @@ class Subversion(VersionControl):
...
@@ -63,7 +63,7 @@ class Subversion(VersionControl):
"""Export the svn repository at the url to the destination location"""
"""Export the svn repository at the url to the destination location"""
url
,
rev
=
self
.
get_url_rev
()
url
,
rev
=
self
.
get_url_rev
()
rev_options
=
get_rev_options
(
self
,
url
,
rev
)
rev_options
=
get_rev_options
(
self
,
url
,
rev
)
url
=
self
.
remove_auth_from_url
(
url
)
url
=
remove_auth_from_url
(
url
)
logger
.
info
(
'Exporting svn repository %s to %s'
,
url
,
location
)
logger
.
info
(
'Exporting svn repository %s to %s'
,
url
,
location
)
with
indent_log
():
with
indent_log
():
if
os
.
path
.
exists
(
location
):
if
os
.
path
.
exists
(
location
):
...
@@ -84,7 +84,7 @@ class Subversion(VersionControl):
...
@@ -84,7 +84,7 @@ class Subversion(VersionControl):
def
obtain
(
self
,
dest
):
def
obtain
(
self
,
dest
):
url
,
rev
=
self
.
get_url_rev
()
url
,
rev
=
self
.
get_url_rev
()
rev_options
=
get_rev_options
(
self
,
url
,
rev
)
rev_options
=
get_rev_options
(
self
,
url
,
rev
)
url
=
self
.
remove_auth_from_url
(
url
)
url
=
remove_auth_from_url
(
url
)
if
self
.
check_destination
(
dest
,
url
,
rev_options
):
if
self
.
check_destination
(
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
logger
.
info
(
...
@@ -221,24 +221,6 @@ class Subversion(VersionControl):
...
@@ -221,24 +221,6 @@ class Subversion(VersionControl):
"""Always assume the versions don't match"""
"""Always assume the versions don't match"""
return
False
return
False
@
staticmethod
def
remove_auth_from_url
(
url
):
# Return a copy of url with 'username:password@' removed.
# username/pass params are passed to subversion through flags
# and are not recognized in the url.
# parsed url
purl
=
urllib_parse
.
urlsplit
(
url
)
stripped_netloc
=
\
purl
.
netloc
.
split
(
'@'
)[
-
1
]
# stripped url
url_pieces
=
(
purl
.
scheme
,
stripped_netloc
,
purl
.
path
,
purl
.
query
,
purl
.
fragment
)
surl
=
urllib_parse
.
urlunsplit
(
url_pieces
)
return
surl
def
get_rev_options
(
vcs
,
url
,
rev
):
def
get_rev_options
(
vcs
,
url
,
rev
):
"""
"""
...
...
tests/unit/test_utils.py
浏览文件 @
5bc94f33
...
@@ -24,7 +24,8 @@ from pip._internal.utils.glibc import check_glibc_version
...
@@ -24,7 +24,8 @@ from pip._internal.utils.glibc import check_glibc_version
from
pip._internal.utils.hashes
import
Hashes
,
MissingHashes
from
pip._internal.utils.hashes
import
Hashes
,
MissingHashes
from
pip._internal.utils.misc
import
(
from
pip._internal.utils.misc
import
(
call_subprocess
,
egg_link_path
,
ensure_dir
,
get_installed_distributions
,
call_subprocess
,
egg_link_path
,
ensure_dir
,
get_installed_distributions
,
get_prog
,
normalize_path
,
rmtree
,
untar_file
,
unzip_file
,
get_prog
,
normalize_path
,
remove_auth_from_url
,
rmtree
,
untar_file
,
unzip_file
,
)
)
from
pip._internal.utils.packaging
import
check_dist_requires_python
from
pip._internal.utils.packaging
import
check_dist_requires_python
from
pip._internal.utils.temp_dir
import
TempDirectory
from
pip._internal.utils.temp_dir
import
TempDirectory
...
@@ -624,3 +625,29 @@ def test_call_subprocess_works_okay_when_just_given_nothing():
...
@@ -624,3 +625,29 @@ def test_call_subprocess_works_okay_when_just_given_nothing():
def
test_call_subprocess_closes_stdin
():
def
test_call_subprocess_closes_stdin
():
with
pytest
.
raises
(
InstallationError
):
with
pytest
.
raises
(
InstallationError
):
call_subprocess
([
sys
.
executable
,
'-c'
,
'input()'
])
call_subprocess
([
sys
.
executable
,
'-c'
,
'input()'
])
def
test_remove_auth_from_url
():
# Check that the url is doctored appropriately to remove auth elements
# from the url
svn_auth_url
=
'https://user:pass@svnrepo.org/svn/project/tags/v0.2'
expected_url
=
'https://svnrepo.org/svn/project/tags/v0.2'
url
=
remove_auth_from_url
(
svn_auth_url
)
assert
url
==
expected_url
# Check that this doesn't impact urls without authentication'
svn_noauth_url
=
'https://svnrepo.org/svn/project/tags/v0.2'
expected_url
=
svn_noauth_url
url
=
remove_auth_from_url
(
svn_noauth_url
)
assert
url
==
expected_url
# Check that links to specific revisions are handled properly
svn_rev_url
=
'https://user:pass@svnrepo.org/svn/project/trunk@8181'
expected_url
=
'https://svnrepo.org/svn/project/trunk@8181'
url
=
remove_auth_from_url
(
svn_rev_url
)
assert
url
==
expected_url
svn_rev_url
=
'https://svnrepo.org/svn/project/trunk@8181'
expected_url
=
'https://svnrepo.org/svn/project/trunk@8181'
url
=
remove_auth_from_url
(
svn_rev_url
)
assert
url
==
expected_url
tests/unit/test_vcs.py
浏览文件 @
5bc94f33
...
@@ -173,32 +173,6 @@ def test_bazaar_simple_urls():
...
@@ -173,32 +173,6 @@ def test_bazaar_simple_urls():
)
)
def
test_subversion_remove_auth_from_url
():
# Check that the url is doctored appropriately to remove auth elements
# from the url
svn_auth_url
=
'https://user:pass@svnrepo.org/svn/project/tags/v0.2'
expected_url
=
'https://svnrepo.org/svn/project/tags/v0.2'
url
=
Subversion
.
remove_auth_from_url
(
svn_auth_url
)
assert
url
==
expected_url
# Check that this doesn't impact urls without authentication'
svn_noauth_url
=
'https://svnrepo.org/svn/project/tags/v0.2'
expected_url
=
svn_noauth_url
url
=
Subversion
.
remove_auth_from_url
(
svn_noauth_url
)
assert
url
==
expected_url
# Check that links to specific revisions are handled properly
svn_rev_url
=
'https://user:pass@svnrepo.org/svn/project/trunk@8181'
expected_url
=
'https://svnrepo.org/svn/project/trunk@8181'
url
=
Subversion
.
remove_auth_from_url
(
svn_rev_url
)
assert
url
==
expected_url
svn_rev_url
=
'https://svnrepo.org/svn/project/trunk@8181'
expected_url
=
'https://svnrepo.org/svn/project/trunk@8181'
url
=
Subversion
.
remove_auth_from_url
(
svn_rev_url
)
assert
url
==
expected_url
def
test_get_git_version
():
def
test_get_git_version
():
git_version
=
Git
().
get_git_version
()
git_version
=
Git
().
get_git_version
()
assert
git_version
>=
parse_version
(
'1.0.0'
)
assert
git_version
>=
parse_version
(
'1.0.0'
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录