Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def create_main_parser():

pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
parser.version = 'pip %s from %s (python %s)' % (
__version__, pip_pkg_dir, sys.version[:3])
__version__, pip_pkg_dir, sys.version[:3])

# add the general options
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
Expand Down Expand Up @@ -247,8 +247,10 @@ def from_dist(cls, dist, dependency_links, find_tags=False):
if ver_match or date_match:
svn_backend = vcs.get_backend('svn')
if svn_backend:
svn_location = svn_backend(
).get_location(dist, dependency_links)
svn_location = svn_backend().get_location(
dist,
dependency_links,
)
if not svn_location:
logger.warn(
'Warning: cannot find svn location for %s' % req)
Expand Down
8 changes: 4 additions & 4 deletions pip/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def make(self):
skip_requirements_regex,
exists_action,
cert,
]
}
]
}

index_group = {
'name': 'Package Index Options',
Expand All @@ -375,5 +375,5 @@ def make(self):
allow_unsafe,
no_allow_unsafe,
process_dependency_links,
]
}
]
}
4 changes: 2 additions & 2 deletions pip/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def run(self, options, args):
for item in os.listdir(lib_dir):
shutil.move(
os.path.join(lib_dir, item),
os.path.join(options.target_dir, item)
)
os.path.join(options.target_dir, item),
)
shutil.rmtree(temp_target_dir)
return requirement_set
8 changes: 4 additions & 4 deletions pip/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
already_cached = (
os.path.exists(cache_file) and
os.path.exists(cache_content_type_file)
)
)
if not os.path.isdir(download_cache):
create_download_cache_folder(download_cache)

Expand All @@ -545,7 +545,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
logger.warn(
'Previously-downloaded file %s has bad hash, '
're-downloading.' % temp_location
)
)
temp_location = None
os.unlink(already_downloaded)
already_downloaded = None
Expand All @@ -564,7 +564,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
logger.warn(
'Cached file %s has bad hash, '
're-downloading.' % temp_location
)
)
temp_location = None
os.unlink(cache_file)
os.unlink(cache_content_type_file)
Expand Down Expand Up @@ -654,7 +654,7 @@ def unpack_file_url(link, location, download_dir=None):
logger.warn(
'Previously-downloaded file %s has bad hash, '
're-downloading.' % link_path
)
)
os.unlink(download_path)
else:
already_downloaded = True
Expand Down
2 changes: 1 addition & 1 deletion pip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def set_is_archive(self, url, value=True):
self._archives[url] = value

def add_page_failure(self, url, level):
self._failures[url] = self._failures.get(url, 0)+level
self._failures[url] = self._failures.get(url, 0) + level

def add_page(self, urls, page):
for url in urls:
Expand Down
2 changes: 1 addition & 1 deletion pip/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def distutils_scheme(dist_name, user=False, home=None, root=None):
i.root = root or i.root
i.finalize_options()
for key in SCHEME_KEYS:
scheme[key] = getattr(i, 'install_'+key)
scheme[key] = getattr(i, 'install_' + key)

if running_under_virtualenv():
scheme['headers'] = os.path.join(
Expand Down
11 changes: 6 additions & 5 deletions pip/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def egg_info_path(self, filename):
if (
os.path.exists(
os.path.join(root, dir, 'bin', 'python')
)
)
or os.path.exists(
os.path.join(
root, dir, 'Scripts', 'Python.exe'
Expand Down Expand Up @@ -703,9 +703,10 @@ def archive(self, build_dir):
logger.notify('Saved %s' % display_path(archive_path))

def _clean_zip_name(self, name, prefix):
assert name.startswith(prefix+os.path.sep), (
"name %r doesn't start with prefix %r" % (name, prefix))
name = name[len(prefix)+1:]
assert name.startswith(prefix + os.path.sep), (
"name %r doesn't start with prefix %r" % (name, prefix)
)
name = name[len(prefix) + 1:]
name = name.replace(os.path.sep, '/')
return name

Expand Down Expand Up @@ -805,7 +806,7 @@ def prepend_root(path):
)
f.close()
f = open(os.path.join(egg_info_dir, 'installed-files.txt'), 'w')
f.write('\n'.join(new_lines)+'\n')
f.write('\n'.join(new_lines) + '\n')
f.close()
finally:
if os.path.exists(record_filename):
Expand Down
9 changes: 5 additions & 4 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
self.unpack_url(
url, location, download_dir,
do_download,
)
)
except HTTPError as exc:
logger.fatal(
'Could not install requirement %s because '
Expand Down Expand Up @@ -728,8 +728,9 @@ def bundle_requirements(self):
return ''.join(parts)

def _clean_zip_name(self, name, prefix):
assert name.startswith(prefix+os.path.sep), (
"name %r doesn't start with prefix %r" % (name, prefix))
name = name[len(prefix)+1:]
assert name.startswith(prefix + os.path.sep), (
"name %r doesn't start with prefix %r" % (name, prefix)
)
name = name[len(prefix) + 1:]
name = name.replace(os.path.sep, '/')
return name
18 changes: 9 additions & 9 deletions pip/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ def normalize_name(name):


def format_size(bytes):
if bytes > 1000*1000:
return '%.1fMB' % (bytes/1000.0/1000)
elif bytes > 10*1000:
return '%ikB' % (bytes/1000)
if bytes > 1000 * 1000:
return '%.1fMB' % (bytes / 1000.0 / 1000)
elif bytes > 10 * 1000:
return '%ikB' % (bytes / 1000)
elif bytes > 1000:
return '%.1fkB' % (bytes/1000.0)
return '%.1fkB' % (bytes / 1000.0)
else:
return '%ibytes' % bytes

Expand Down Expand Up @@ -274,7 +274,7 @@ def make_path_relative(path, rel_to):
while path_parts and rel_to_parts and path_parts[0] == rel_to_parts[0]:
path_parts.pop(0)
rel_to_parts.pop(0)
full_parts = ['..']*len(rel_to_parts) + path_parts + [path_filename]
full_parts = ['..'] * len(rel_to_parts) + path_parts + [path_filename]
if full_parts == ['']:
return '.' + os.path.sep
return os.path.sep.join(full_parts)
Expand Down Expand Up @@ -540,7 +540,7 @@ def unzip_file(filename, location, flatten=True):
if mode and stat.S_ISREG(mode) and mode & 0o111:
# make dest file have execute for user/group/world
# (chmod +x) no-op on windows per python docs
os.chmod(fn, (0o777-current_umask() | 0o111))
os.chmod(fn, (0o777 - current_umask() | 0o111))
finally:
zipfp.close()

Expand Down Expand Up @@ -615,7 +615,7 @@ def untar_file(filename, location):
if member.mode & 0o111:
# make dest file have execute for user/group/world
# no-op on windows per python docs
os.chmod(path, (0o777-current_umask() | 0o111))
os.chmod(path, (0o777 - current_umask() | 0o111))
finally:
tar.close()

Expand All @@ -632,7 +632,7 @@ def cache_download(target_file, temp_location, content_type):
'Storing download in cache at %s' % display_path(target_file)
)
shutil.copyfile(temp_location, target_file)
fp = open(target_file+'.content-type', 'w')
fp = open(target_file + '.content-type', 'w')
fp.write(content_type)
fp.close()

Expand Down
2 changes: 1 addition & 1 deletion pip/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def uninstallation_paths(dist):
if path.endswith('.py'):
dn, fn = os.path.split(path)
base = fn[:-3]
path = os.path.join(dn, base+'.pyc')
path = os.path.join(dn, base + '.pyc')
yield path


Expand Down
12 changes: 6 additions & 6 deletions tests/functional/test_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_create_bundle(script, tmpdir, data):
index (pip itself).

"""
fspkg = path_to_url(data.packages/'FSPkg')
fspkg = path_to_url(data.packages / 'FSPkg')
script.pip('install', '-e', fspkg)
pkg_lines = textwrap.dedent(
'''
Expand Down Expand Up @@ -61,13 +61,13 @@ def test_cleanup_after_create_bundle(script, tmpdir, data):
),
])
script.pip(*args)
build = script.venv_path/"build"
src = script.venv_path/"src"
build = script.venv_path / "build"
src = script.venv_path / "src"
assert not exists(build), "build/ dir still exists: %s" % build
assert exists(src), "expected src/ dir doesn't exist: %s" % src

# Make the bundle.
fspkg = path_to_url(data.packages/'FSPkg')
fspkg = path_to_url(data.packages / 'FSPkg')
pkg_lines = textwrap.dedent(
'''
-e %s
Expand All @@ -86,8 +86,8 @@ def test_cleanup_after_create_bundle(script, tmpdir, data):
script.pip(
'bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle',
)
build_bundle = script.scratch_path/"build-bundle"
src_bundle = script.scratch_path/"src-bundle"
build_bundle = script.scratch_path / "build-bundle"
src_bundle = script.scratch_path / "src-bundle"
assert not exists(build_bundle), (
"build-bundle/ dir still exists: %s" % build_bundle
)
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def banner(msg):
return '\n========== %s ==========\n' % msg
assert checker.check_output(expected, actual, ELLIPSIS), (
banner('EXPECTED') + expected + banner('ACTUAL') + actual +
banner(6*'=')
banner(6 * '=')
)


Expand All @@ -51,7 +51,7 @@ def test_freeze_basic(script):
simple2<=3.0
"""))
result = script.pip_install_local(
'-r', script.scratch_path/'initools-req.txt',
'-r', script.scratch_path / 'initools-req.txt',
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Expand Down Expand Up @@ -178,7 +178,7 @@ def test_freeze_mercurial_clone(script, tmpdir):
)
result = script.run(
'python', 'setup.py', 'develop',
cwd=script.scratch_path/'pip-test-package',
cwd=script.scratch_path / 'pip-test-package',
expect_stderr=True,
)
result = script.pip('freeze', expect_stderr=True)
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_freeze_bazaar_clone(script, tmpdir):
)
result = script.run(
'python', 'setup.py', 'develop',
cwd=script.scratch_path/'django-wikiapp',
cwd=script.scratch_path / 'django-wikiapp',
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Expand Down
Loading