summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Smith <qwcode@gmail.com>2013-02-16 14:17:22 -0800
committerMarcus Smith <qwcode@gmail.com>2013-02-16 14:17:22 -0800
commit22bf924b5289951d0cb15f316a63920fb738183c (patch)
treed822a82e93709df8740bfe408da8b0bb919b9617
parent809a9962c1877224d18b2355ae69099dbcddc062 (diff)
parentf00b015d7309dfa4d6367aae75a0b1322cf2e3bc (diff)
downloadpip-22bf924b5289951d0cb15f316a63920fb738183c.tar.gz
merge with develop
-rw-r--r--docs/development.txt23
-rw-r--r--docs/logic.txt9
-rw-r--r--docs/pipext.py11
-rw-r--r--docs/usage.txt1
-rwxr-xr-xpip/__init__.py1
-rw-r--r--pip/backwardcompat/__init__.py8
-rw-r--r--pip/basecommand.py29
-rw-r--r--pip/baseparser.py22
-rw-r--r--pip/cmdoptions.py2
-rw-r--r--pip/commands/bundle.py5
-rw-r--r--pip/commands/completion.py5
-rw-r--r--pip/commands/freeze.py3
-rw-r--r--pip/commands/help.py5
-rw-r--r--pip/commands/install.py32
-rw-r--r--pip/commands/list.py7
-rw-r--r--pip/commands/search.py3
-rw-r--r--pip/commands/show.py3
-rw-r--r--pip/commands/uninstall.py17
-rw-r--r--pip/commands/unzip.py1
-rw-r--r--pip/commands/zip.py13
-rw-r--r--pip/download.py5
-rw-r--r--pip/index.py17
-rw-r--r--pip/log.py15
-rw-r--r--pip/req.py11
-rw-r--r--pip/vcs/__init__.py4
-rw-r--r--pip/vcs/subversion.py6
-rw-r--r--tests/test_help.py5
27 files changed, 137 insertions, 126 deletions
diff --git a/docs/development.txt b/docs/development.txt
index cf39f385e..c8b8792ed 100644
--- a/docs/development.txt
+++ b/docs/development.txt
@@ -63,23 +63,34 @@ This process includes virtualenv, since pip releases necessitate a virtualenv re
:<oldv>/<newv>: refers to the old and new versions of virtualenv.
1. Upgrade distribute, if needed:
+
#. Upgrade distribute in ``virtualenv:develop`` using the :ref:`Refresh virtualenv` process.
#. Create a pull request against ``pip:develop`` with a modified ``.travis.yml`` file that installs virtualenv from ``virtualenv:develop``, to confirm the travis builds are still passing.
-3. Create Release branches:
+
+2. Create Release branches:
+
#. Create ``pip:<newp>`` branch.
#. In ``pip:develop``, change ``pip.version`` to '<newp>.post1'.
#. Create ``virtualenv:<newv>`` branch.
#. In ``virtualenv:develop``, change ``virtualenv.version`` to '<newv>.post1'.
-4. Prepare "rcX":
+
+3. Prepare "rcX":
+
#. In ``pip:<newp>``, change ``pip.version`` to '<newp>rcX', and tag with '<newp>rcX'.
#. Build a pip sdist from ``pip:<newp>``, and build it into ``virtualenv:<newv>`` using the :ref:`Refresh virtualenv` process.
#. In ``virtualenv:<newv>``, change ``virtualenv.version`` to '<newv>rcX', and tag with '<newv>rcX'.
-5. Announce ``pip-<newp>rcX`` and ``virtualenv-<newv>rcX`` with the :ref:`RC Install Instructions` and elicit feedback.
-6. Apply fixes to 'rcX':
+
+4. Announce ``pip-<newp>rcX`` and ``virtualenv-<newv>rcX`` with the :ref:`RC Install Instructions` and elicit feedback.
+
+5. Apply fixes to 'rcX':
+
#. Apply fixes to ``pip:<newp>`` and ``virtualenv:<newv>``
#. Periodically merge fixes to ``pip:develop`` and ``virtualenv:develop``
-7. Repeat #4 thru #6 if needed.
-8. Final Release:
+
+6. Repeat #4 thru #6 if needed.
+
+7. Final Release:
+
#. In ``pip:<newp>``, change ``pip.version`` to '<newp>', and tag with '<newp>'.
#. Merge ``pip:<newp>`` to ``pip:master``.
#. Build a pip sdist from ``pip:<newp>``, and load it into ``virtualenv:<newv>`` using the :ref:`Refresh virtualenv` process.
diff --git a/docs/logic.txt b/docs/logic.txt
index 78ecc1446..4b4130474 100644
--- a/docs/logic.txt
+++ b/docs/logic.txt
@@ -1,8 +1,8 @@
.. _`pip logic`:
-===================
+================
Internal Details
-===================
+================
.. _`Requirements File Format`:
@@ -141,9 +141,10 @@ Tags or revisions can be installed like this::
Finding Packages
================
-pip searches for packages on `PyPI <http://pypi.python.org>`_ using the `http simple interface <http://pypi.python.org/simple>`_,
+pip searches for packages on `PyPI <http://pypi.python.org>`_ using the
+`http simple interface <http://pypi.python.org/simple>`_,
which is documented `here <http://packages.python.org/distribute/easy_install.html#package-index-api>`_
-and `here <http://www.python.org/dev/peps/pep-0301/>`_
+and `there <http://www.python.org/dev/peps/pep-0301/>`_
pip offers a set of :ref:`Package Index Options <Package Index Options>` for modifying how packages are found.
diff --git a/docs/pipext.py b/docs/pipext.py
index 357357212..f2902ed0a 100644
--- a/docs/pipext.py
+++ b/docs/pipext.py
@@ -14,6 +14,7 @@ from pip.util import get_prog
class PipCommandUsage(rst.Directive):
required_arguments = 1
+
def run(self):
cmd = commands[self.arguments[0]]
prog = '%s %s' % (get_prog(), cmd.name)
@@ -21,18 +22,21 @@ class PipCommandUsage(rst.Directive):
node = nodes.literal_block(usage, usage)
return [node]
+
class PipCommandDescription(rst.Directive):
required_arguments = 1
+
def run(self):
node = nodes.paragraph()
node.document = self.state.document
desc = ViewList()
- description = dedent(commands[self.arguments[0]].description)
+ description = dedent(commands[self.arguments[0]].__doc__)
for line in description.split('\n'):
desc.append(line, "")
self.state.nested_parse(desc, 0, node)
return [node]
+
class PipOptions(rst.Directive):
def _format_option(self, option, cmd_name=None):
@@ -72,20 +76,25 @@ class PipOptions(rst.Directive):
self.state.nested_parse(self.view_list, 0, node)
return [node]
+
class PipGeneralOptions(PipOptions):
def process_options(self):
self._format_options(standard_options)
+
class PipIndexOptions(PipOptions):
def process_options(self):
self._format_options(cmdoptions.index_group['options'])
+
class PipCommandOptions(PipOptions):
required_arguments = 1
+
def process_options(self):
cmd = commands[self.arguments[0]](create_main_parser())
self._format_options(cmd.parser.option_groups[0].option_list, cmd_name=cmd.name)
+
def setup(app):
app.add_directive('pip-command-usage', PipCommandUsage)
app.add_directive('pip-command-description', PipCommandDescription)
diff --git a/docs/usage.txt b/docs/usage.txt
index 9453235b6..3192e050d 100644
--- a/docs/usage.txt
+++ b/docs/usage.txt
@@ -158,6 +158,7 @@ Examples
********
1) Uninstall a package.
+
::
$ pip uninstall simplejson
diff --git a/pip/__init__.py b/pip/__init__.py
index 8c33ef295..b13463aa5 100755
--- a/pip/__init__.py
+++ b/pip/__init__.py
@@ -4,7 +4,6 @@ import optparse
import sys
import re
-import difflib
from pip.exceptions import InstallationError, CommandError, PipError
from pip.log import logger
diff --git a/pip/backwardcompat/__init__.py b/pip/backwardcompat/__init__.py
index ee2051dab..99ed75531 100644
--- a/pip/backwardcompat/__init__.py
+++ b/pip/backwardcompat/__init__.py
@@ -7,7 +7,7 @@ import site
__all__ = ['WindowsError']
-uses_pycache = hasattr(imp,'cache_from_source')
+uses_pycache = hasattr(imp, 'cache_from_source')
try:
WindowsError = WindowsError
@@ -91,7 +91,8 @@ else:
from distutils.sysconfig import get_python_lib, get_python_version
#site.USER_SITE was created in py2.6
-user_site = getattr(site,'USER_SITE',None)
+user_site = getattr(site, 'USER_SITE', None)
+
def product(*args, **kwds):
# product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
@@ -99,10 +100,11 @@ def product(*args, **kwds):
pools = list(map(tuple, args)) * kwds.get('repeat', 1)
result = [[]]
for pool in pools:
- result = [x+[y] for x in result for y in pool]
+ result = [x + [y] for x in result for y in pool]
for prod in result:
yield tuple(prod)
+
def home_lib(home):
"""Return the lib dir under the 'home' installation scheme"""
if hasattr(sys, 'pypy_version_info'):
diff --git a/pip/basecommand.py b/pip/basecommand.py
index 08ede4ad4..df86e5449 100644
--- a/pip/basecommand.py
+++ b/pip/basecommand.py
@@ -1,7 +1,6 @@
"""Base Command class, and related routines"""
import os
-from pkgutil import walk_packages
import socket
import sys
import tempfile
@@ -33,14 +32,13 @@ class Command(object):
def __init__(self, main_parser):
parser_kw = {
- 'usage' : self.usage,
- 'prog' : '%s %s' % (get_prog(), self.name),
- 'formatter' : UpdatingDefaultsHelpFormatter(),
- 'add_help_option' : False,
- 'name' : self.name,
- 'description' : self.description
+ 'usage': self.usage,
+ 'prog': '%s %s' % (get_prog(), self.name),
+ 'formatter': UpdatingDefaultsHelpFormatter(),
+ 'add_help_option': False,
+ 'name': self.name,
+ 'description': self.__doc__,
}
-
self.main_parser = main_parser
self.parser = ConfigOptionParser(**parser_kw)
@@ -91,10 +89,10 @@ class Command(object):
options, args = self.parser.parse_args(args)
self.merge_options(initial_options, options)
- level = 1 # Notify
+ level = 1 # Notify
level += options.verbose
level -= options.quiet
- level = logger.level_for_integer(4-level)
+ level = logger.level_for_integer(4 - level)
complete_log = []
logger.consumers.extend(
[(level, sys.stdout),
@@ -172,11 +170,11 @@ class Command(object):
log_fn = options.log_file
text = '\n'.join(complete_log)
try:
- log_fp = open_logfile(log_fn, 'w')
+ log_fp = open_logfile(log_fn, 'w')
except IOError:
- temp = tempfile.NamedTemporaryFile(delete=False)
- log_fn = temp.name
- log_fp = open_logfile(log_fn, 'w')
+ temp = tempfile.NamedTemporaryFile(delete=False)
+ log_fn = temp.name
+ log_fp = open_logfile(log_fn, 'w')
logger.fatal('Storing complete log in %s' % log_fn)
log_fp.write(text)
log_fp.close()
@@ -206,7 +204,6 @@ def open_logfile(filename, mode='a'):
log_fp = open(filename, mode)
if exists:
- log_fp.write('%s\n' % ('-'*60))
+ log_fp.write('%s\n' % ('-' * 60))
log_fp.write('%s run on %s\n' % (sys.argv[0], time.strftime('%c')))
return log_fp
-
diff --git a/pip/baseparser.py b/pip/baseparser.py
index 957b89206..62491c975 100644
--- a/pip/baseparser.py
+++ b/pip/baseparser.py
@@ -64,10 +64,16 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter):
# leave full control over description to us
if description:
if hasattr(self.parser, 'main'):
- label = 'Commands:'
+ label = 'Commands'
else:
- label = 'Description:'
- description = label + ' %s\n' % self.indent_lines(textwrap.dedent(description), " ")
+ label = 'Description'
+ #some doc strings have inital newlines, some don't
+ description = description.lstrip('\n')
+ #some doc strings have final newlines and spaces, some don't
+ description = description.rstrip()
+ #dedent, then reindent
+ description = self.indent_lines(textwrap.dedent(description), " ")
+ description = '%s:\n%s\n' % (label, description)
return description
else:
return ''
@@ -222,11 +228,11 @@ except pkg_resources.DistributionNotFound:
def create_main_parser():
parser_kw = {
- 'usage' : '\n%prog <command> [options]',
- 'add_help_option' : False,
- 'formatter' : UpdatingDefaultsHelpFormatter(),
- 'name' : 'global',
- 'prog' : get_prog(),
+ 'usage': '\n%prog <command> [options]',
+ 'add_help_option': False,
+ 'formatter': UpdatingDefaultsHelpFormatter(),
+ 'name': 'global',
+ 'prog': get_prog(),
}
parser = ConfigOptionParser(**parser_kw)
diff --git a/pip/cmdoptions.py b/pip/cmdoptions.py
index f1b100843..4d8678885 100644
--- a/pip/cmdoptions.py
+++ b/pip/cmdoptions.py
@@ -1,7 +1,7 @@
"""shared options and groups"""
-
from optparse import make_option, OptionGroup
+
def make_option_group(group, parser):
"""
Return an OptionGroup object
diff --git a/pip/commands/bundle.py b/pip/commands/bundle.py
index 2a325402f..c2c02d01e 100644
--- a/pip/commands/bundle.py
+++ b/pip/commands/bundle.py
@@ -6,13 +6,11 @@ from pip.commands.install import InstallCommand
class BundleCommand(InstallCommand):
+ """Create pybundles (archives containing multiple packages)."""
name = 'bundle'
usage = """
%prog [options] <bundle name>.pybundle <package>..."""
summary = 'Create pybundles.'
- description = """
- Create pybundles (archives containing multiple packages)."""
-
bundle = True
def __init__(self, *args, **kw):
@@ -37,4 +35,3 @@ class BundleCommand(InstallCommand):
self.bundle_filename = args.pop(0)
requirement_set = super(BundleCommand, self).run(options, args)
return requirement_set
-
diff --git a/pip/commands/completion.py b/pip/commands/completion.py
index 361702569..5fa237620 100644
--- a/pip/commands/completion.py
+++ b/pip/commands/completion.py
@@ -28,10 +28,9 @@ compctl -K _pip_completion pip
class CompletionCommand(Command):
+ """A helper command to be used for command completion."""
name = 'completion'
summary = 'A helper command to be used for command completion'
- description = """
- A helper command to be used for command completion."""
hidden = True
def __init__(self, *args, **kw):
@@ -52,7 +51,7 @@ class CompletionCommand(Command):
def run(self, options, args):
"""Prints the completion code of the given shell"""
shells = COMPLETION_SCRIPTS.keys()
- shell_options = ['--'+shell for shell in sorted(shells)]
+ shell_options = ['--' + shell for shell in sorted(shells)]
if options.shell in shells:
script = COMPLETION_SCRIPTS.get(options.shell, '')
print(BASE_COMPLETION % {'script': script, 'shell': options.shell})
diff --git a/pip/commands/freeze.py b/pip/commands/freeze.py
index f34db084f..9c2ab7239 100644
--- a/pip/commands/freeze.py
+++ b/pip/commands/freeze.py
@@ -9,12 +9,11 @@ from pip.util import get_installed_distributions
class FreezeCommand(Command):
+ """Output installed packages in requirements format."""
name = 'freeze'
usage = """
%prog [options]"""
summary = 'Output installed packages in requirements format.'
- description = """
- Output installed packages in requirements format."""
def __init__(self, *args, **kw):
super(FreezeCommand, self).__init__(*args, **kw)
diff --git a/pip/commands/help.py b/pip/commands/help.py
index 3482ec4ab..4771db753 100644
--- a/pip/commands/help.py
+++ b/pip/commands/help.py
@@ -1,14 +1,13 @@
-from pip.basecommand import Command, SUCCESS, ERROR
+from pip.basecommand import Command, SUCCESS
from pip.exceptions import CommandError
class HelpCommand(Command):
+ """Show help for commands"""
name = 'help'
usage = """
%prog <command>"""
summary = 'Show help for commands.'
- description = """
- Show help for commands"""
def run(self, options, args):
from pip.commands import commands, get_similar_commands
diff --git a/pip/commands/install.py b/pip/commands/install.py
index 959e8900f..2de43453f 100644
--- a/pip/commands/install.py
+++ b/pip/commands/install.py
@@ -2,9 +2,7 @@ import os
import sys
import tempfile
import shutil
-import optparse
-from pip.req import InstallRequirement, RequirementSet
-from pip.req import parse_requirements
+from pip.req import InstallRequirement, RequirementSet, parse_requirements
from pip.log import logger
from pip.locations import build_prefix, src_prefix, virtualenv_no_global
from pip.basecommand import Command
@@ -15,6 +13,20 @@ from pip.cmdoptions import make_option_group, index_group
class InstallCommand(Command):
+ """
+ Install packages from:
+
+ - PyPI (and other indexes) using requirement specifiers.
+ - VCS project urls.
+ - Local project directories.
+ - Local or remote source archives.
+
+ pip also supports installing from "requirements files", which provide
+ an easy way to specify a whole environment to be installed.
+
+ See http://www.pip-installer.org for details on VCS url formats and
+ requirements files.
+ """
name = 'install'
usage = """
@@ -24,20 +36,6 @@ class InstallCommand(Command):
%prog [options] [-e] <local project path> ...
%prog [options] <archive url/path> ..."""
- description = """
- Install packages from:
-
- - PyPI (and other indexes) using requirement specifiers.
- - VCS project urls.
- - Local project directories.
- - Local or remote source archives.
-
- pip also supports installing from "requirements files", which provide
- an easy way to specify a whole environment to be installed.
-
- See http://www.pip-installer.org for details on VCS url formats and
- requirements files."""
-
summary = 'Install packages.'
bundle = False
diff --git a/pip/commands/list.py b/pip/commands/list.py
index 72abb246e..063f07e8a 100644
--- a/pip/commands/list.py
+++ b/pip/commands/list.py
@@ -1,4 +1,3 @@
-import pkg_resources
from pip.basecommand import Command
from pip.exceptions import DistributionNotFound, BestVersionAlreadyInstalled
from pip.index import PackageFinder
@@ -9,17 +8,15 @@ from pip.cmdoptions import make_option_group, index_group
class ListCommand(Command):
+ """List installed packages, including editables."""
name = 'list'
usage = """
%prog [options]"""
summary = 'List installed packages.'
- description = """
- List installed packages, including editables."""
def __init__(self, *args, **kw):
super(ListCommand, self).__init__(*args, **kw)
-
cmd_opts = self.cmd_opts
cmd_opts.add_option(
@@ -48,7 +45,6 @@ class ListCommand(Command):
self.parser.insert_option_group(0, index_opts)
self.parser.insert_option_group(0, cmd_opts)
-
def _build_package_finder(self, options, index_urls):
"""
Create a package finder appropriate to this list command.
@@ -134,4 +130,3 @@ class ListCommand(Command):
if dist.parsed_version == remote_version_parsed:
uptodate.append(dist)
self.output_package_listing(uptodate)
-
diff --git a/pip/commands/search.py b/pip/commands/search.py
index 82c104867..b001314cd 100644
--- a/pip/commands/search.py
+++ b/pip/commands/search.py
@@ -12,12 +12,11 @@ from distutils.version import StrictVersion, LooseVersion
class SearchCommand(Command):
+ """Search for PyPI packages whose name or summary contains <query>."""
name = 'search'
usage = """
%prog [options] <query>"""
summary = 'Search PyPI for packages.'
- description = """
- Search for PyPI packages whose name or summary contains <query>."""
def __init__(self, *args, **kw):
super(SearchCommand, self).__init__(*args, **kw)
diff --git a/pip/commands/show.py b/pip/commands/show.py
index 2404683ef..f47f4b01e 100644
--- a/pip/commands/show.py
+++ b/pip/commands/show.py
@@ -5,12 +5,11 @@ from pip.log import logger
class ShowCommand(Command):
+ """Show information about one or more installed packages."""
name = 'show'
usage = """
%prog [options] <package> ..."""
summary = 'Show information about installed packages.'
- description = """
- Show information about one or more installed packages."""
def __init__(self, *args, **kw):
super(ShowCommand, self).__init__(*args, **kw)
diff --git a/pip/commands/uninstall.py b/pip/commands/uninstall.py
index 136bb31ef..388053b20 100644
--- a/pip/commands/uninstall.py
+++ b/pip/commands/uninstall.py
@@ -4,19 +4,20 @@ from pip.exceptions import InstallationError
class UninstallCommand(Command):
+ """
+ Uninstall packages.
+
+ pip is able to uninstall most installed packages. Known exceptions are:
+
+ - Pure distutils packages installed with ``python setup.py install``, which
+ leave behind no metadata to determine what files were installed.
+ - Script wrappers installed by ``python setup.py develop``.
+ """
name = 'uninstall'
usage = """
%prog [options] <package> ...
%prog [options] -r <requirements file> ..."""
summary = 'Uninstall packages.'
- description = """
- Uninstall packages.
-
- pip is able to uninstall most installed packages. Known exceptions are:
-
- - Pure distutils packages installed with ``python setup.py install``, which
- leave behind no metadata to determine what files were installed.
- - Script wrappers installed by ``python setup.py develop``."""
def __init__(self, *args, **kw):
super(UninstallCommand, self).__init__(*args, **kw)
diff --git a/pip/commands/unzip.py b/pip/commands/unzip.py
index c09eafc66..7986514b7 100644
--- a/pip/commands/unzip.py
+++ b/pip/commands/unzip.py
@@ -2,5 +2,6 @@ from pip.commands.zip import ZipCommand
class UnzipCommand(ZipCommand):
+ """Unzip individual packages."""
name = 'unzip'
summary = 'Unzip individual packages.'
diff --git a/pip/commands/zip.py b/pip/commands/zip.py
index 92d2cf6dd..ca25412ce 100644
--- a/pip/commands/zip.py
+++ b/pip/commands/zip.py
@@ -11,12 +11,11 @@ from pip.basecommand import Command
class ZipCommand(Command):
+ """Zip individual packages."""
name = 'zip'
usage = """
%prog [options] <package> ..."""
summary = 'Zip individual packages.'
- description = """
- Zip individual packages."""
def __init__(self, *args, **kw):
super(ZipCommand, self).__init__(*args, **kw)
@@ -71,7 +70,7 @@ class ZipCommand(Command):
for match in self.select_paths:
match = os.path.normcase(os.path.abspath(match))
if '*' in match:
- if re.search(fnmatch.translate(match+'*'), path):
+ if re.search(fnmatch.translate(match + '*'), path):
result.append(path)
match_any.add(match)
break
@@ -86,8 +85,8 @@ class ZipCommand(Command):
for match in self.select_paths:
if match not in match_any and '*' not in match:
result.append(match)
- logger.debug("Adding path %s because it doesn't match anything already on sys.path"
- % match)
+ logger.debug("Adding path %s because it doesn't match "
+ "anything already on sys.path" % match)
return result
def run(self, options, args):
@@ -197,7 +196,7 @@ class ZipCommand(Command):
full = os.path.join(dirpath, fn)
dest = os.path.join(module_name, dirpath[len(filename):].lstrip(os.path.sep), fn)
if is_dir:
- zip.writestr(dest+'/', '')
+ zip.writestr(dest + '/', '')
else:
zip.write(full, dest)
zip.close()
@@ -246,7 +245,7 @@ class ZipCommand(Command):
f.close()
if lines and not lines[-1].endswith('\n'):
lines[-1] += '\n'
- lines.append(filename+'\n')
+ lines.append(filename + '\n')
else:
lines = [filename + '\n']
f = open(dest, 'wb')
diff --git a/pip/download.py b/pip/download.py
index caba5ed01..48d4bfefa 100644
--- a/pip/download.py
+++ b/pip/download.py
@@ -8,6 +8,7 @@ import shutil
import socket
import sys
import tempfile
+
from pip.backwardcompat import (xmlrpclib, urllib, urllib2, httplib,
urlparse, string_types, ssl)
if ssl:
@@ -435,7 +436,7 @@ def _download_url(resp, link, temp_location):
except (ValueError, KeyError, TypeError):
total_length = 0
downloaded = 0
- show_progress = total_length > 40*1000 or not total_length
+ show_progress = total_length > 40 * 1000 or not total_length
show_url = link.show_url
try:
if show_progress:
@@ -457,7 +458,7 @@ def _download_url(resp, link, temp_location):
if not total_length:
logger.show_progress('%s' % format_size(downloaded))
else:
- logger.show_progress('%3i%% %s' % (100*downloaded/total_length, format_size(downloaded)))
+ logger.show_progress('%3i%% %s' % (100 * downloaded / total_length, format_size(downloaded)))
if download_hash is not None:
download_hash.update(chunk)
fp.write(chunk)
diff --git a/pip/index.py b/pip/index.py
index 89ba1bfbb..4f73a2395 100644
--- a/pip/index.py
+++ b/pip/index.py
@@ -5,27 +5,28 @@ import os
import re
import gzip
import mimetypes
-try:
- import threading
-except ImportError:
- import dummy_threading as threading
import posixpath
import pkg_resources
import random
import socket
import string
import zlib
+
+try:
+ import threading
+except ImportError:
+ import dummy_threading as threading
+
from pip.log import logger
-from pip.util import Inf
-from pip.util import normalize_name, splitext
+from pip.util import Inf, normalize_name, splitext
from pip.exceptions import DistributionNotFound, BestVersionAlreadyInstalled
from pip.backwardcompat import (WindowsError, BytesIO,
Queue, urlparse,
URLError, HTTPError, u,
- product, url2pathname, ssl)
+ product, url2pathname, ssl
+ Empty as QueueEmpty)
if ssl:
from pip.backwardcompat import CertificateError
-from pip.backwardcompat import Empty as QueueEmpty
from pip.download import urlopen, path_to_url2, url_to_path, geturl, Urllib2HeadRequest
__all__ = ['PackageFinder']
diff --git a/pip/log.py b/pip/log.py
index a9e617d3a..9eb02b90d 100644
--- a/pip/log.py
+++ b/pip/log.py
@@ -8,16 +8,14 @@ from pip import backwardcompat
class Logger(object):
-
"""
Logging object for use in command-line script. Allows ranges of
levels, to avoid some redundancy of displayed information.
"""
-
- VERBOSE_DEBUG = logging.DEBUG-1
+ VERBOSE_DEBUG = logging.DEBUG - 1
DEBUG = logging.DEBUG
INFO = logging.INFO
- NOTIFY = (logging.INFO+logging.WARN)/2
+ NOTIFY = (logging.INFO + logging.WARN) / 2
WARN = WARNING = logging.WARN
ERROR = logging.ERROR
FATAL = logging.FATAL
@@ -68,7 +66,7 @@ class Logger(object):
rendered = msg % args
else:
rendered = msg
- rendered = ' '*self.indent + rendered
+ rendered = ' ' * self.indent + rendered
if self.explicit_levels:
## FIXME: should this be a name, not a level number?
rendered = '%02i %s' % (level, rendered)
@@ -87,7 +85,7 @@ class Logger(object):
"Tried to start_progress(%r) while in_progress %r"
% (msg, self.in_progress))
if self._show_progress():
- sys.stdout.write(' '*self.indent + msg)
+ sys.stdout.write(' ' * self.indent + msg)
sys.stdout.flush()
self.in_progress_hanging = True
else:
@@ -121,10 +119,11 @@ class Logger(object):
sys.stdout.flush()
else:
if self.last_message:
- padding = ' ' * max(0, len(self.last_message)-len(message))
+ padding = ' ' * max(0, len(self.last_message) - len(message))
else:
padding = ''
- sys.stdout.write('\r%s%s%s%s' % (' '*self.indent, self.in_progress, message, padding))
+ sys.stdout.write('\r%s%s%s%s' %
+ (' ' * self.indent, self.in_progress, message, padding))
sys.stdout.flush()
self.last_message = message
diff --git a/pip/req.py b/pip/req.py
index 9bf113c5f..14aa3a0ae 100644
--- a/pip/req.py
+++ b/pip/req.py
@@ -15,12 +15,11 @@ from pip.exceptions import (InstallationError, UninstallationError,
DistributionNotFound)
from pip.vcs import vcs
from pip.log import logger
-from pip.util import display_path, rmtree
-from pip.util import ask, ask_path_exists, backup_dir
-from pip.util import is_installable_dir, is_local, dist_is_local, dist_in_usersite, dist_in_site_packages
-from pip.util import renames, normalize_path, egg_link_path
-from pip.util import make_path_relative
-from pip.util import call_subprocess
+from pip.util import (display_path, rmtree, ask, ask_path_exists, backup_dir,
+ is_installable_dir, is_local, dist_is_local,
+ dist_in_usersite, dist_in_site_packages, renames,
+ normalize_path, egg_link_path, make_path_relative,
+ call_subprocess)
from pip.backwardcompat import (urlparse, urllib, uses_pycache,
ConfigParser, string_types, HTTPError,
get_python_version, b)
diff --git a/pip/vcs/__init__.py b/pip/vcs/__init__.py
index 36ad676c5..a56dd202b 100644
--- a/pip/vcs/__init__.py
+++ b/pip/vcs/__init__.py
@@ -6,7 +6,7 @@ import shutil
from pip.backwardcompat import urlparse, urllib
from pip.log import logger
from pip.util import (display_path, backup_dir, find_command,
- ask, rmtree, ask_path_exists)
+ rmtree, ask_path_exists)
__all__ = ['vcs', 'get_src_requirement']
@@ -117,7 +117,7 @@ class VersionControl(object):
Returns the correct repository URL and revision by parsing the given
repository URL
"""
- error_message= (
+ error_message = (
"Sorry, '%s' is a malformed VCS url. "
"The format is <vcs>+<protocol>://<url>, "
"e.g. svn+http://myrepo/svn/MyApp#egg=MyApp")
diff --git a/pip/vcs/subversion.py b/pip/vcs/subversion.py
index f131ceda7..b84095220 100644
--- a/pip/vcs/subversion.py
+++ b/pip/vcs/subversion.py
@@ -126,7 +126,7 @@ class Subversion(VersionControl):
dirurl, localrev = self._get_svn_url_rev(base)
if base == location:
- base_url = dirurl+'/' # save the root url
+ base_url = dirurl + '/' # save the root url
elif not dirurl or not dirurl.startswith(base_url):
dirs[:] = []
continue # not part of the same svn tree, skip it
@@ -163,13 +163,13 @@ class Subversion(VersionControl):
data = list(map(str.splitlines, data.split('\n\x0c\n')))
del data[0][0] # get rid of the '8'
url = data[0][3]
- revs = [int(d[9]) for d in data if len(d)>9 and d[9]]+[0]
+ revs = [int(d[9]) for d in data if len(d) > 9 and d[9]] + [0]
elif data.startswith('<?xml'):
match = _svn_xml_url_re.search(data)
if not match:
raise ValueError('Badly formatted data: %r' % data)
url = match.group(1) # get repository URL
- revs = [int(m.group(1)) for m in _svn_rev_re.finditer(data)]+[0]
+ revs = [int(m.group(1)) for m in _svn_rev_re.finditer(data)] + [0]
else:
try:
# subversion >= 1.7
diff --git a/tests/test_help.py b/tests/test_help.py
index 31f1aa2e8..4ee634239 100644
--- a/tests/test_help.py
+++ b/tests/test_help.py
@@ -1,8 +1,7 @@
from pip.exceptions import CommandError
from pip.baseparser import create_main_parser
-from pip.commands.help import (HelpCommand,
- SUCCESS,
- ERROR,)
+from pip.basecommand import ERROR, SUCCESS
+from pip.commands.help import HelpCommand
from pip.commands import commands
from mock import Mock
from nose.tools import assert_raises