Current File : //lib/python3.9/site-packages/pip/_internal/index/__pycache__/sources.cpython-39.pyc
a

[��f��	@s0ddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
ddlmZddl
mZmZddlmZe�e�Zee
ZeeZeegee
fZeegefZGdd�d�Zeed	�d
d�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�Z eeeeeeeeeefd�dd�Z!dS)�N)�Callable�Iterable�Optional�Tuple)�InstallationCandidate)�Link)�path_to_url�url_to_path)�is_urlc@s>eZdZeeed�dd��Zed�dd�Ze	d�dd�Z
dS)	�
LinkSource��returncCs
t��dS)z,Returns the underlying link, if there's one.N��NotImplementedError��self�r�?/usr/lib/python3.9/site-packages/pip/_internal/index/sources.py�linkszLinkSource.linkcCs
t��dS)z9Candidates found by parsing an archive listing HTML file.Nrrrrr�page_candidatesszLinkSource.page_candidatescCs
t��dS)z,Links found by specifying archives directly.Nrrrrr�
file_linksszLinkSource.file_linksN)�__name__�
__module__�__qualname__�propertyrrr�FoundCandidatesr�
FoundLinksrrrrrrsr)�file_urlr
cCstj|dd�ddkS)NF)�strictrz	text/html)�	mimetypesZ
guess_type)rrrr�
_is_html_file#sr c@sTeZdZdZeedd�dd�Zeee	d�dd��Z
ed�d	d
�Ze
d�dd�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.
    N)�candidates_from_page�pathr
cCs||_t�tj�|��|_dS�N)�_candidates_from_page�pathlib�Path�osr#�realpath�_path)rr"r#rrr�__init__0sz_FlatDirectorySource.__init__rcCsdSr$rrrrrr8sz_FlatDirectorySource.linkccs>|j��D].}tt|��}t|�s$q
|�t|��EdHq
dSr$)r*�iterdirr�strr r%r�rr#�urlrrrr<s
z$_FlatDirectorySource.page_candidatesccs4|j��D]$}tt|��}t|�r$q
t|�Vq
dSr$)r*r,rr-r rr.rrrrCs
z_FlatDirectorySource.file_links)rrr�__doc__�CandidatesFromPager-r+rrrrrrrrrrrrr!'s
�r!c@sTeZdZdZeedd�dd�Zeeed�dd��Z	e
d�d	d
�Zed�dd�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.
    N�r"rr
cCs||_||_dSr$�r%�_link�rr"rrrrr+Usz_LocalFileSource.__init__rcCs|jSr$�r5rrrrr]sz_LocalFileSource.linkccs&t|jj�sdS|�|j�EdHdSr$)r r5r/r%rrrrrasz _LocalFileSource.page_candidatesccst|jj�rdS|jVdSr$)r r5r/rrrrrfsz_LocalFileSource.file_links�rrrr0r1rr+rrrrrrrrrrrr2Ks�r2c@sVeZdZdZeeedd�dd�Zee	ed�dd��Z
ed�d	d
�Ze
d�dd�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.
    N)r"�page_validatorrr
cCs||_||_||_dSr$)r%�_page_validatorr5)rr"r:rrrrr+usz_RemoteFileSource.__init__rcCs|jSr$r7rrrrrsz_RemoteFileSource.linkccs&|�|j�sdS|�|j�EdHdSr$)r;r5r%rrrrr�sz!_RemoteFileSource.page_candidatesccs|jVdSr$r7rrrrr�sz_RemoteFileSource.file_links)rrrr0r1�
PageValidatorrr+rrrrrrrrrrrr9ls
�
r9c@sTeZdZdZeedd�dd�Zeeed�dd��Z	e
d�d	d
�Zed�dd�Z
dS)
�_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.
    Nr3cCs||_||_dSr$r4r6rrrr+�sz_IndexDirectorySource.__init__rcCs|jSr$r7rrrrr�sz_IndexDirectorySource.linkccs|�|j�EdHdSr$r4rrrrr�sz%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrr�sz _IndexDirectorySource.file_linksr8rrrrr=�s�r=)�locationr"r:�
expand_dir�cache_link_parsingr
c	Cs�d}d}tj�|�r"t|�}|}n$|�d�r:|}t|�}nt|�rF|}|durbd}t�||�dS|dur�t	||t
||d�d�}||fStj�|�r�|r�t||d�}nt
|t
||d�d�}||fStj�|�r�t|t
||d�d�}||fSt�d|�|dfS)	Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)r@)r"r:r)r"r#)r"rz?Location '%s' is ignored: it is neither a file nor a directory.)r(r#�existsr�
startswithr	r
�loggerZwarningr9r�isdirr!r=�isfiler2)	r>r"r:r?r@r#r/�msg�sourcerrr�build_source�sX	

�
��
�
��rH)"Zloggingrr(r&�typingrrrrZpip._internal.models.candidaterZpip._internal.models.linkrZpip._internal.utils.urlsrr	Zpip._internal.vcsr
Z	getLoggerrrCrrr1�boolr<rr-r r!r2r9r=rHrrrr�<module>s4
$! �