Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/pip/_internal/models/index.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import urllib.parse | |
2 | |
3 | |
4 class PackageIndex: | |
5 """Represents a Package Index and provides easier access to endpoints | |
6 """ | |
7 | |
8 __slots__ = ['url', 'netloc', 'simple_url', 'pypi_url', | |
9 'file_storage_domain'] | |
10 | |
11 def __init__(self, url, file_storage_domain): | |
12 # type: (str, str) -> None | |
13 super().__init__() | |
14 self.url = url | |
15 self.netloc = urllib.parse.urlsplit(url).netloc | |
16 self.simple_url = self._url_for_path('simple') | |
17 self.pypi_url = self._url_for_path('pypi') | |
18 | |
19 # This is part of a temporary hack used to block installs of PyPI | |
20 # packages which depend on external urls only necessary until PyPI can | |
21 # block such packages themselves | |
22 self.file_storage_domain = file_storage_domain | |
23 | |
24 def _url_for_path(self, path): | |
25 # type: (str) -> str | |
26 return urllib.parse.urljoin(self.url, path) | |
27 | |
28 | |
29 PyPI = PackageIndex( | |
30 'https://pypi.org/', file_storage_domain='files.pythonhosted.org' | |
31 ) | |
32 TestPyPI = PackageIndex( | |
33 'https://test.pypi.org/', file_storage_domain='test-files.pythonhosted.org' | |
34 ) |