HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_internal/index/__pycache__/sources.cpython-310.pyc
o

@%Ne��@s<ddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
ddlmZddl
mZmZddlmZe�e�Zee
ZeeZeegee
fZeegefZGdd�d�Zd	ed
efdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�Z dededededed
eeeeeffdd�Z!dS)�N)�Callable�Iterable�Optional�Tuple)�InstallationCandidate)�Link)�path_to_url�url_to_path)�is_urlc@s>eZdZedeefdd��Zdefdd�Zde	fdd�Z
dS)	�
LinkSource�returncC�t��)z,Returns the underlying link, if there's one.��NotImplementedError��self�r�=/usr/lib/python3/dist-packages/pip/_internal/index/sources.py�linkszLinkSource.linkcCr
)z9Candidates found by parsing an archive listing HTML file.rrrrr�page_candidates�zLinkSource.page_candidatescCr
)z,Links found by specifying archives directly.rrrrr�
file_linksrzLinkSource.file_linksN)�__name__�
__module__�__qualname__�propertyrrr�FoundCandidatesr�
FoundLinksrrrrrrs
r�file_urlrcCstj|dd�ddkS)NF)�strictrz	text/html)�	mimetypes�
guess_type)rrrr�
_is_html_file#sr"c@sXeZdZdZdededdfdd�Zedee	fdd	��Z
defd
d�Zde
fdd
�ZdS)�_FlatDirectorySourcez�Link source specified by ``--find-links=<path-to-dir>``.

    This looks the content of the directory, and returns:

    * ``page_candidates``: Links listed on each HTML file in the directory.
    * ``file_candidates``: Archives in the directory.
    �candidates_from_page�pathrNcCs||_t�tj�|��|_dS�N)�_candidates_from_page�pathlib�Path�osr%�realpath�_path)rr$r%rrr�__init__0sz_FlatDirectorySource.__init__cCsdSr&rrrrrr8sz_FlatDirectorySource.linkccs@�|j��D]}tt|��}t|�sq|�t|��EdHqdSr&)r,�iterdirr�strr"r'r�rr%�urlrrrr<s��z$_FlatDirectorySource.page_candidatesccs6�|j��D]}tt|��}t|�rqt|�VqdSr&)r,r.rr/r"rr0rrrrCs��z_FlatDirectorySource.file_links)rrr�__doc__�CandidatesFromPager/r-rrrrrrrrrrrrr#'s��
�r#c@�XeZdZdZdededdfdd�Zedeefdd	��Z	de
fd
d�Zdefdd
�Z
dS)�_LocalFileSourceaC``--find-links=<path-or-url>`` or ``--[extra-]index-url=<path-or-url>``.

    If a URL is supplied, it must be a ``file:`` URL. If a path is supplied to
    the option, it is converted to a URL first. This returns:

    * ``page_candidates``: Links listed on an HTML file.
    * ``file_candidates``: The non-HTML file.
    r$rrNcC�||_||_dSr&�r'�_link�rr$rrrrr-U�
z_LocalFileSource.__init__cC�|jSr&�r8rrrrr]rz_LocalFileSource.linkccs(�t|jj�s	dS|�|j�EdHdSr&)r"r8r1r'rrrrra��z _LocalFileSource.page_candidatesccs�t|jj�r	dS|jVdSr&)r"r8r1rrrrrfs�z_LocalFileSource.file_links�rrrr2r3rr-rrrrrrrrrrrr5Ks	��
�r5c@s\eZdZdZdedededdfdd�Zede	efd	d
��Z
defdd�Zde
fd
d�ZdS)�_RemoteFileSourcez�``--find-links=<url>`` or ``--[extra-]index-url=<url>``.

    This returns:

    * ``page_candidates``: Links listed on an HTML file.
    * ``file_candidates``: The non-HTML file.
    r$�page_validatorrrNcCs||_||_||_dSr&)r'�_page_validatorr8)rr$r@rrrrr-us
z_RemoteFileSource.__init__cCr;r&r<rrrrrrz_RemoteFileSource.linkccs(�|�|j�s	dS|�|j�EdHdSr&)rAr8r'rrrrr�r=z!_RemoteFileSource.page_candidatesccs�|jVdSr&r<rrrrr�s�z_RemoteFileSource.file_links)rrrr2r3�
PageValidatorrr-rrrrrrrrrrrr?ls���
�
r?c@r4)�_IndexDirectorySourcez�``--[extra-]index-url=<path-to-directory>``.

    This is treated like a remote URL; ``candidates_from_page`` contains logic
    for this by appending ``index.html`` to the link.
    r$rrNcCr6r&r7r9rrrr-�r:z_IndexDirectorySource.__init__cCr;r&r<rrrrr�rz_IndexDirectorySource.linkccs�|�|j�EdHdSr&r7rrrrr�s�z%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrr�sz _IndexDirectorySource.file_linksr>rrrrrC�s��
�rC�locationr$r@�
expand_dir�cache_link_parsingc	Csd}d}tj�|�rt|�}|}n|�d�r|}t|�}nt|�r#|}|dur1d}t�||�dS|durDt	||t
||d�d�}||fStj�|�rd|rVt||d�}||fSt
|t
||d�d�}||fStj�|�rxt|t
||d�d�}||fSt�d|�|dfS)	Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)rF)r$r@r)r$r%)r$rz?Location '%s' is ignored: it is neither a file nor a directory.)r*r%�existsr�
startswithr	r
�logger�warningr?r�isdirr#rC�isfiler5)	rDr$r@rErFr%r1�msg�sourcerrr�build_source�sZ	

�
��	�
�
��rO)"�loggingr r*r(�typingrrrr�pip._internal.models.candidater�pip._internal.models.linkr�pip._internal.utils.urlsrr	�pip._internal.vcsr
�	getLoggerrrIrrr3�boolrBrr/r"r#r5r?rCrOrrrr�<module>sB
$! ������