Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
9b11ed23
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,发现更多精彩内容 >>
提交
9b11ed23
编写于
6月 16, 2014
作者:
D
Donald Stufft
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1854 from Ivoz/compat-cleaning
Remove unnecessary imports, move some to six
上级
31e5f418
b7770c50
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
28 addition
and
41 deletion
+28
-41
pip/baseparser.py
pip/baseparser.py
+3
-2
pip/commands/search.py
pip/commands/search.py
+3
-2
pip/compat.py
pip/compat.py
+1
-18
pip/download.py
pip/download.py
+2
-2
pip/req/req_install.py
pip/req/req_install.py
+6
-7
pip/util.py
pip/util.py
+5
-4
pip/vcs/mercurial.py
pip/vcs/mercurial.py
+3
-3
pip/wheel.py
pip/wheel.py
+3
-2
tests/unit/test_download.py
tests/unit/test_download.py
+2
-1
未找到文件。
pip/baseparser.py
浏览文件 @
9b11ed23
...
...
@@ -6,7 +6,8 @@ import os
import
textwrap
from
distutils.util
import
strtobool
from
pip.compat
import
ConfigParser
,
string_types
from
pip._vendor.six
import
string_types
from
pip._vendor.six.moves
import
configparser
from
pip.locations
import
(
default_config_file
,
default_config_basename
,
running_under_virtualenv
,
)
...
...
@@ -128,7 +129,7 @@ class ConfigOptionParser(CustomOptionParser):
configuration files and environmental variables"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
config
=
ConfigP
arser
.
RawConfigParser
()
self
.
config
=
configp
arser
.
RawConfigParser
()
self
.
name
=
kwargs
.
pop
(
'name'
)
self
.
files
=
self
.
get_config_files
()
if
self
.
files
:
...
...
pip/commands/search.py
浏览文件 @
9b11ed23
...
...
@@ -4,10 +4,11 @@ import textwrap
from
pip.basecommand
import
Command
,
SUCCESS
from
pip.util
import
get_terminal_size
from
pip.log
import
logger
from
pip.compat
import
xmlrpclib
,
reduce
,
cmp
from
pip.compat
import
reduce
,
cmp
from
pip.exceptions
import
CommandError
from
pip.status_codes
import
NO_MATCHES_FOUND
from
pip._vendor
import
pkg_resources
from
pip._vendor.six.moves
import
xmlrpc_client
from
distutils.version
import
StrictVersion
,
LooseVersion
...
...
@@ -48,7 +49,7 @@ class SearchCommand(Command):
return
NO_MATCHES_FOUND
def
search
(
self
,
query
,
index_url
):
pypi
=
xmlrpc
lib
.
ServerProxy
(
index_url
)
pypi
=
xmlrpc
_client
.
ServerProxy
(
index_url
)
hits
=
pypi
.
search
({
'name'
:
query
,
'summary'
:
query
},
'or'
)
return
hits
...
...
pip/compat.py
浏览文件 @
9b11ed23
...
...
@@ -44,18 +44,13 @@ except NameError:
if
sys
.
version_info
>=
(
3
,):
from
io
import
StringIO
,
BytesIO
from
io
import
StringIO
from
functools
import
reduce
from
urllib.error
import
URLError
,
HTTPError
from
queue
import
Queue
,
Empty
from
urllib.request
import
url2pathname
,
urlretrieve
,
pathname2url
from
email
import
message
as
emailmessage
import
urllib.parse
as
urllib
import
urllib.request
as
urllib2
import
configparser
as
ConfigParser
import
xmlrpc.client
as
xmlrpclib
import
urllib.parse
as
urlparse
import
http.client
as
httplib
def
cmp
(
a
,
b
):
return
(
a
>
b
)
-
(
a
<
b
)
...
...
@@ -75,21 +70,13 @@ if sys.version_info >= (3,):
def
get_http_message_param
(
http_message
,
param
,
default_value
):
return
http_message
.
get_param
(
param
,
default_value
)
bytes
=
bytes
string_types
=
(
str
,)
raw_input
=
input
else
:
from
cStringIO
import
StringIO
from
urllib2
import
URLError
,
HTTPError
from
Queue
import
Queue
,
Empty
from
urllib
import
url2pathname
,
urlretrieve
,
pathname2url
from
email
import
Message
as
emailmessage
import
urllib
import
urllib2
import
urlparse
import
ConfigParser
import
xmlrpclib
import
httplib
def
b
(
s
):
return
s
...
...
@@ -104,12 +91,8 @@ else:
result
=
http_message
.
getparam
(
param
)
return
result
or
default_value
bytes
=
str
string_types
=
(
basestring
,)
reduce
=
reduce
cmp
=
cmp
raw_input
=
raw_input
BytesIO
=
StringIO
def
get_path_uid
(
path
):
...
...
pip/download.py
浏览文件 @
9b11ed23
...
...
@@ -12,7 +12,7 @@ import tempfile
import
pip
from
pip.compat
import
urllib
,
urlparse
,
raw_input
from
pip.compat
import
urllib
,
urlparse
from
pip.exceptions
import
InstallationError
,
HashMismatch
from
pip.util
import
(
splitext
,
rmtree
,
format_size
,
display_path
,
backup_dir
,
ask_path_exists
,
unpack_file
)
...
...
@@ -117,7 +117,7 @@ class MultiDomainBasicAuth(AuthBase):
parsed
=
urlparse
.
urlparse
(
resp
.
url
)
# Prompt the user for a new username and password
username
=
raw_
input
(
"User for %s: "
%
parsed
.
netloc
)
username
=
six
.
moves
.
input
(
"User for %s: "
%
parsed
.
netloc
)
password
=
getpass
.
getpass
(
"Password: "
)
# Store the new username and password to use for future requests
...
...
pip/req/req_install.py
浏览文件 @
9b11ed23
...
...
@@ -10,9 +10,8 @@ from email.parser import FeedParser
import
pip.wheel
from
pip._vendor
import
pkg_resources
,
six
from
pip.compat
import
(
urllib
,
ConfigParser
,
string_types
,
)
from
pip._vendor.six.moves
import
configparser
from
pip.compat
import
urllib
from
pip.download
import
is_url
,
url_to_path
,
path_to_url
,
is_archive_file
from
pip.exceptions
import
(
InstallationError
,
UninstallationError
,
UnsupportedWheel
,
...
...
@@ -38,7 +37,7 @@ class InstallRequirement(object):
url
=
None
,
as_egg
=
False
,
update
=
True
,
prereleases
=
None
,
editable_options
=
None
,
pycompile
=
True
):
self
.
extras
=
()
if
isinstance
(
req
,
string_types
):
if
isinstance
(
req
,
s
ix
.
s
tring_types
):
req
=
pkg_resources
.
Requirement
.
parse
(
req
)
self
.
extras
=
req
.
extras
self
.
req
=
req
...
...
@@ -168,7 +167,7 @@ class InstallRequirement(object):
if
self
.
satisfied_by
is
not
None
:
s
+=
' in %s'
%
display_path
(
self
.
satisfied_by
.
location
)
if
self
.
comes_from
:
if
isinstance
(
self
.
comes_from
,
string_types
):
if
isinstance
(
self
.
comes_from
,
s
ix
.
s
tring_types
):
comes_from
=
self
.
comes_from
else
:
comes_from
=
self
.
comes_from
.
from_path
()
...
...
@@ -181,7 +180,7 @@ class InstallRequirement(object):
return
None
s
=
str
(
self
.
req
)
if
self
.
comes_from
:
if
isinstance
(
self
.
comes_from
,
string_types
):
if
isinstance
(
self
.
comes_from
,
s
ix
.
s
tring_types
):
comes_from
=
self
.
comes_from
else
:
comes_from
=
self
.
comes_from
.
from_path
()
...
...
@@ -619,7 +618,7 @@ exec(compile(
# find console_scripts
if
dist
.
has_metadata
(
'entry_points.txt'
):
config
=
ConfigP
arser
.
SafeConfigParser
()
config
=
configp
arser
.
SafeConfigParser
()
config
.
readfp
(
FakeFile
(
dist
.
get_metadata_lines
(
'entry_points.txt'
))
)
...
...
pip/util.py
浏览文件 @
9b11ed23
...
...
@@ -11,15 +11,16 @@ import zipfile
from
pip.exceptions
import
InstallationError
,
BadCommand
from
pip.compat
import
(
string_types
,
raw_input
,
console_to_str
,
stdlib_pkgs
console_to_str
,
stdlib_pkgs
)
from
pip.locations
import
(
site_packages
,
user_site
,
running_under_virtualenv
,
virtualenv_no_global
,
write_delete_marker_file
)
from
pip.log
import
logger
from
pip._vendor
import
pkg_resources
from
pip._vendor
import
pkg_resources
,
six
from
pip._vendor.distlib
import
version
from
pip._vendor.six.moves
import
input
__all__
=
[
'rmtree'
,
'display_path'
,
'backup_dir'
,
'find_command'
,
'ask'
,
'Inf'
,
...
...
@@ -85,7 +86,7 @@ def find_command(cmd, paths=None, pathext=None):
"""Searches the PATH for the given command and returns its path"""
if
paths
is
None
:
paths
=
os
.
environ
.
get
(
'PATH'
,
''
).
split
(
os
.
pathsep
)
if
isinstance
(
paths
,
string_types
):
if
isinstance
(
paths
,
s
ix
.
s
tring_types
):
paths
=
[
paths
]
# check if there are funny path extensions for executables, e.g. Windows
if
pathext
is
None
:
...
...
@@ -131,7 +132,7 @@ def ask(message, options):
'No input was expected ($PIP_NO_INPUT set); question: %s'
%
message
)
response
=
raw_
input
(
message
)
response
=
input
(
message
)
response
=
response
.
strip
().
lower
()
if
response
not
in
options
:
print
(
...
...
pip/vcs/mercurial.py
浏览文件 @
9b11ed23
...
...
@@ -7,7 +7,7 @@ from pip.util import display_path, rmtree
from
pip.log
import
logger
from
pip.vcs
import
vcs
,
VersionControl
from
pip.download
import
path_to_url
from
pip.
compat
import
ConfigP
arser
from
pip.
_vendor.six.moves
import
configp
arser
class
Mercurial
(
VersionControl
):
...
...
@@ -29,14 +29,14 @@ class Mercurial(VersionControl):
def
switch
(
self
,
dest
,
url
,
rev_options
):
repo_config
=
os
.
path
.
join
(
dest
,
self
.
dirname
,
'hgrc'
)
config
=
ConfigP
arser
.
SafeConfigParser
()
config
=
configp
arser
.
SafeConfigParser
()
try
:
config
.
read
(
repo_config
)
config
.
set
(
'paths'
,
'default'
,
url
)
config_file
=
open
(
repo_config
,
'w'
)
config
.
write
(
config_file
)
config_file
.
close
()
except
(
OSError
,
ConfigP
arser
.
NoSectionError
)
as
exc
:
except
(
OSError
,
configp
arser
.
NoSectionError
)
as
exc
:
logger
.
warn
(
'Could not switch Mercurial repository to %s: %s'
%
(
url
,
exc
))
...
...
pip/wheel.py
浏览文件 @
9b11ed23
...
...
@@ -15,7 +15,7 @@ import sys
from
base64
import
urlsafe_b64encode
from
email.parser
import
Parser
from
pip.compat
import
ConfigParser
,
StringIO
,
binary
from
pip.compat
import
StringIO
,
binary
from
pip.exceptions
import
InvalidWheelFilename
,
UnsupportedWheel
from
pip.locations
import
distutils_scheme
from
pip.log
import
logger
...
...
@@ -23,6 +23,7 @@ from pip import pep425tags
from
pip.util
import
call_subprocess
,
normalize_path
,
make_path_relative
from
pip._vendor.distlib.scripts
import
ScriptMaker
from
pip._vendor
import
pkg_resources
from
pip._vendor.six.moves
import
configparser
wheel_ext
=
'.whl'
...
...
@@ -114,7 +115,7 @@ def get_entrypoints(filename):
data
.
write
(
"
\n
"
)
data
.
seek
(
0
)
cp
=
ConfigP
arser
.
RawConfigParser
()
cp
=
configp
arser
.
RawConfigParser
()
cp
.
readfp
(
data
)
console
=
{}
...
...
tests/unit/test_download.py
浏览文件 @
9b11ed23
import
hashlib
import
os
from
io
import
BytesIO
from
shutil
import
rmtree
,
copy
from
tempfile
import
mkdtemp
...
...
@@ -7,7 +8,7 @@ from mock import Mock, patch
import
pytest
import
pip
from
pip.compat
import
BytesIO
,
b
,
pathname2url
from
pip.compat
import
b
,
pathname2url
from
pip.exceptions
import
HashMismatch
from
pip.download
import
(
PipSession
,
SafeFileCache
,
path_to_url
,
unpack_http_url
,
url_to_path
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录