Skip to content

Commit 57e4571

Browse files
author
Patrik Kopkan
committed
fixed english mistakes and some logical errors
1 parent 3156e56 commit 57e4571

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

news/6340.feature

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Added a new option `--save-wheel-names` to command `wheel`.
2-
The option takes path and creates file in which
3-
is saved the basenames of wheels outputed by `wheel` command.
1+
Added a new option ``--save-wheel-names`` to command ``wheel``.
2+
The option takes a path and creates a file in which
3+
the filenames of built or downloaded wheels will be stored,
4+
separated by newlines

src/pip/_internal/commands/wheel.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(self, *args, **kw):
102102
dest='path_to_wheelnames',
103103
action='store',
104104
metavar='path',
105-
help="stores the filenames of wheels in file of given path"
105+
help="stores the filenames of the built or downloaded wheels in a new file of given path"
106106
)
107107

108108
index_opts = cmdoptions.make_option_group(
@@ -191,13 +191,16 @@ def run(self, options, args):
191191
for req in requirement_set.requirements.values():
192192
if req.link.filename.endswith('whl'):
193193
entries_to_save.append(req.link.filename)
194-
195-
with open(wb.path_to_wheelnames, 'w') as file:
196-
file.write(
197-
'\n'.join(
198-
entries_to_save
199-
) + '\n'
200-
)
194+
try:
195+
with open(wb.path_to_wheelnames, 'w') as file:
196+
file.write(
197+
'\n'.join(
198+
entries_to_save
199+
) + '\n'
200+
)
201+
except PermissionError as e:
202+
logger.error('Cannot write to the given path: %s', wb.path_to_wheelnames)
203+
logger.error('PermissionError: %s', str(e))
201204

202205
except PreviousBuildDirError:
203206
options.no_clean = True

tests/functional/test_wheel.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ def test_legacy_wheels_are_not_confused_with_other_files(script, tmpdir, data):
249249

250250

251251
def test_pip_option_save_wheel_name(script, data):
252-
"""
253-
Test 'pip wheel ' success.
252+
"""Check if the option saves the filenames of built wheels
254253
"""
255254
script.pip(
256255
'wheel', '--no-index', '-f', data.find_links,
@@ -262,6 +261,6 @@ def test_pip_option_save_wheel_name(script, data):
262261
'simple-3.0-py%s-none-any.whl' % pyversion[0],
263262
]
264263
wheelnames_path = script.scratch_path / 'wheelnames'
265-
wheelnames_file = open(wheelnames_path, 'r')
266-
wheelnames_entries = (wheelnames_file.read()).splitlines()
264+
with open(wheelnames_path, 'r') as wheelnames_file:
265+
wheelnames_entries = (wheelnames_file.read()).splitlines()
267266
assert wheel_file_names == wheelnames_entries

0 commit comments

Comments
 (0)