Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
keewenaw
GitHub Repository: keewenaw/ethereum-wallet-cracker
Path: blob/main/test/lib/python3.9/site-packages/pip/_internal/models/index.py
4804 views
1
import urllib.parse
2
3
4
class PackageIndex:
5
"""Represents a Package Index and provides easier access to endpoints"""
6
7
__slots__ = ["url", "netloc", "simple_url", "pypi_url", "file_storage_domain"]
8
9
def __init__(self, url: str, file_storage_domain: str) -> None:
10
super().__init__()
11
self.url = url
12
self.netloc = urllib.parse.urlsplit(url).netloc
13
self.simple_url = self._url_for_path("simple")
14
self.pypi_url = self._url_for_path("pypi")
15
16
# This is part of a temporary hack used to block installs of PyPI
17
# packages which depend on external urls only necessary until PyPI can
18
# block such packages themselves
19
self.file_storage_domain = file_storage_domain
20
21
def _url_for_path(self, path: str) -> str:
22
return urllib.parse.urljoin(self.url, path)
23
24
25
PyPI = PackageIndex("https://pypi.org/", file_storage_domain="files.pythonhosted.org")
26
TestPyPI = PackageIndex(
27
"https://test.pypi.org/", file_storage_domain="test-files.pythonhosted.org"
28
)
29
30