Skip to content

Commit 7c1c29b

Browse files
committed
package-index: Extract fall-through methods _download_vcs and _download_other.
1 parent eb42e5c commit 7c1c29b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

setuptools/package_index.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -831,19 +831,24 @@ def _download_url(self, scheme, url, tmpdir):
831831

832832
filename = os.path.join(tmpdir, name)
833833

834-
# Download the file
835-
#
834+
return self._download_vcs(url, filename) or self._download_other(url, filename)
835+
836+
def _download_vcs(self, url, filename):
837+
scheme = urllib.parse.urlsplit(url).scheme
836838
if scheme == 'svn' or scheme.startswith('svn+'):
837839
return self._download_svn(url, filename)
838840
elif scheme == 'git' or scheme.startswith('git+'):
839841
return self._download_git(url, filename)
840842
elif scheme.startswith('hg+'):
841843
return self._download_hg(url, filename)
842-
elif scheme == 'file':
843-
return urllib.request.url2pathname(urllib.parse.urlparse(url)[2])
844-
else:
845-
self.url_ok(url, True) # raises error if not allowed
846-
return self._attempt_download(url, filename)
844+
845+
def _download_other(self, url, filename):
846+
scheme = urllib.parse.urlsplit(url).scheme
847+
if scheme == 'file':
848+
return urllib.request.url2pathname(urllib.parse.urlparse(url).path)
849+
# raise error if not allowed
850+
self.url_ok(url, True)
851+
return self._attempt_download(url, filename)
847852

848853
def scan_url(self, url):
849854
self.process_url(url, True)

0 commit comments

Comments
 (0)