Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hhhrrrttt222111
GitHub Repository: hhhrrrttt222111/Dorkify
Path: blob/master/venv/Lib/site-packages/pip/_internal/models/index.py
811 views
1
from pip._vendor.six.moves.urllib import parse as urllib_parse
2
3
4
class PackageIndex(object):
5
"""Represents a Package Index and provides easier access to endpoints
6
"""
7
8
def __init__(self, url, file_storage_domain):
9
# type: (str, str) -> None
10
super(PackageIndex, self).__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):
22
# type: (str) -> str
23
return urllib_parse.urljoin(self.url, path)
24
25
26
PyPI = PackageIndex(
27
'https://pypi.org/', file_storage_domain='files.pythonhosted.org'
28
)
29
TestPyPI = PackageIndex(
30
'https://test.pypi.org/', file_storage_domain='test-files.pythonhosted.org'
31
)
32
33