Skip to content

Commit 7256207

Browse files
committed
Move _clean_zip_name into a nested function
Why: Better models how it's used
1 parent 448303a commit 7256207

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/pip/_internal/req/req_install.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -749,19 +749,20 @@ def uninstall(self, auto_confirm=False, verbose=False,
749749
uninstalled_pathset.remove(auto_confirm, verbose)
750750
return uninstalled_pathset
751751

752-
def _clean_zip_name(self, name, prefix): # only used by archive.
753-
# type: (str, str) -> str
754-
assert name.startswith(prefix + os.path.sep), (
755-
"name %r doesn't start with prefix %r" % (name, prefix)
756-
)
757-
name = name[len(prefix) + 1:]
758-
name = name.replace(os.path.sep, '/')
759-
return name
760-
761752
def _get_archive_name(self, path, parentdir, rootdir):
762753
# type: (str, str, str) -> str
754+
755+
def _clean_zip_name(name, prefix):
756+
# type: (str, str) -> str
757+
assert name.startswith(prefix + os.path.sep), (
758+
"name %r doesn't start with prefix %r" % (name, prefix)
759+
)
760+
name = name[len(prefix) + 1:]
761+
name = name.replace(os.path.sep, '/')
762+
return name
763+
763764
path = os.path.join(parentdir, path)
764-
name = self._clean_zip_name(path, rootdir)
765+
name = _clean_zip_name(path, rootdir)
765766
return self.name + '/' + name
766767

767768
def archive(self, build_dir):

0 commit comments

Comments
 (0)