Path: blob/main/test/lib/python3.9/site-packages/pip/_internal/models/index.py
4804 views
import urllib.parse123class PackageIndex:4"""Represents a Package Index and provides easier access to endpoints"""56__slots__ = ["url", "netloc", "simple_url", "pypi_url", "file_storage_domain"]78def __init__(self, url: str, file_storage_domain: str) -> None:9super().__init__()10self.url = url11self.netloc = urllib.parse.urlsplit(url).netloc12self.simple_url = self._url_for_path("simple")13self.pypi_url = self._url_for_path("pypi")1415# This is part of a temporary hack used to block installs of PyPI16# packages which depend on external urls only necessary until PyPI can17# block such packages themselves18self.file_storage_domain = file_storage_domain1920def _url_for_path(self, path: str) -> str:21return urllib.parse.urljoin(self.url, path)222324PyPI = PackageIndex("https://pypi.org/", file_storage_domain="files.pythonhosted.org")25TestPyPI = PackageIndex(26"https://test.pypi.org/", file_storage_domain="test-files.pythonhosted.org"27)282930