o
    Ëý°j�  ã                   @   s<  d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZmZ d dlmZ e  e¡Zee
 Zee Zeegee
 f Zeegef ZG dd„ dƒZd	ed
efdd„ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ dededededed
eee ee f fdd„Z!dS )é    N)ÚCallableÚIterableÚOptionalÚTuple)ÚInstallationCandidate)ÚLink)Úpath_to_urlÚurl_to_path)Úis_urlc                   @   s>   e Zd Zedee fdd„ƒZdefdd„Zde	fdd„Z
dS )	Ú
LinkSourceÚreturnc                 C   ó   t ƒ ‚)z,Returns the underlying link, if there's one.©ÚNotImplementedError©Úself© r   úŽ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/index/sources.pyÚlink   s   zLinkSource.linkc                 C   r   )z9Candidates found by parsing an archive listing HTML file.r   r   r   r   r   Úpage_candidates   ó   zLinkSource.page_candidatesc                 C   r   )z,Links found by specifying archives directly.r   r   r   r   r   Ú
file_links   r   zLinkSource.file_linksN)Ú__name__Ú
__module__Ú__qualname__Úpropertyr   r   r   ÚFoundCandidatesr   Ú
FoundLinksr   r   r   r   r   r      s
    r   Úfile_urlr   c                 C   s   t j| dd�d dkS )NF)Ústrictr   z	text/html)Ú	mimetypesÚ
guess_type)r   r   r   r   Ú_is_html_file#   s   r"   c                   @   sX   e Zd ZdZdededdfdd„Zedee	 fdd	„ƒZ
defd
d„Zdefdd„ZdS )Ú_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   Nc                 C   s   || _ t tj |¡¡| _d S ©N)Ú_candidates_from_pageÚpathlibÚPathÚosr%   ÚrealpathÚ_path)r   r$   r%   r   r   r   Ú__init__0   s   z_FlatDirectorySource.__init__c                 C   s   d S r&   r   r   r   r   r   r   8   s   z_FlatDirectorySource.linkc                 c   s@   � | j  ¡ D ]}tt|ƒƒ}t|ƒsq|  t|ƒ¡E d H  qd S r&   )r,   Úiterdirr   Ústrr"   r'   r   ©r   r%   Úurlr   r   r   r   <   s   €üz$_FlatDirectorySource.page_candidatesc                 c   s6   � | j  ¡ D ]}tt|ƒƒ}t|ƒrqt|ƒV  qd S r&   )r,   r.   r   r/   r"   r   r0   r   r   r   r   C   s   €üz_FlatDirectorySource.file_links)r   r   r   Ú__doc__ÚCandidatesFromPager/   r-   r   r   r   r   r   r   r   r   r   r   r   r   r#   '   s    þý
ür#   c                   @   óX   e Zd ZdZdededdfdd„Zedee fdd	„ƒZ	de
fd
d„Zdefdd„ZdS )Ú_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$   r   r   Nc                 C   ó   || _ || _d S r&   ©r'   Ú_link©r   r$   r   r   r   r   r-   U   ó   
z_LocalFileSource.__init__c                 C   ó   | j S r&   ©r8   r   r   r   r   r   ]   r   z_LocalFileSource.linkc                 c   s(   � t | jjƒs	d S |  | j¡E d H  d S r&   )r"   r8   r1   r'   r   r   r   r   r   a   ó   €z _LocalFileSource.page_candidatesc                 c   s   � t | jjƒr	d S | jV  d S r&   )r"   r8   r1   r   r   r   r   r   f   s   €z_LocalFileSource.file_links©r   r   r   r2   r3   r   r-   r   r   r   r   r   r   r   r   r   r   r   r5   K   s    	þý
ür5   c                   @   s\   e Zd ZdZdedededdfdd„Zede	e fd	d
„ƒZ
defdd„Zdefdd„ZdS )Ú_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_validatorr   r   Nc                 C   s   || _ || _|| _d S r&   )r'   Ú_page_validatorr8   )r   r$   r@   r   r   r   r   r-   u   s   
z_RemoteFileSource.__init__c                 C   r;   r&   r<   r   r   r   r   r      r   z_RemoteFileSource.linkc                 c   s(   � |   | j¡s	d S |  | j¡E d H  d S r&   )rA   r8   r'   r   r   r   r   r   ƒ   r=   z!_RemoteFileSource.page_candidatesc                 c   s   � | j V  d S r&   r<   r   r   r   r   r   ˆ   s   €z_RemoteFileSource.file_links)r   r   r   r2   r3   ÚPageValidatorr   r-   r   r   r   r   r   r   r   r   r   r   r   r?   l   s    þýü
û
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$   r   r   Nc                 C   r6   r&   r7   r9   r   r   r   r-   “   r:   z_IndexDirectorySource.__init__c                 C   r;   r&   r<   r   r   r   r   r   ›   r   z_IndexDirectorySource.linkc                 c   s   � |   | j¡E d H  d S r&   r7   r   r   r   r   r   Ÿ   s   €z%_IndexDirectorySource.page_candidatesc                 C   s   dS )Nr   r   r   r   r   r   r   ¢   s   z _IndexDirectorySource.file_linksr>   r   r   r   r   rC   Œ   s    þý
ürC   Úlocationr$   r@   Ú
expand_dirÚcache_link_parsingc          	      C   s  d }d }t j | ¡rt| ƒ}| }n|  d¡r| }t| ƒ}nt| ƒr#| }|d u r1d}t || ¡ dS |d u rDt	||t
||d�d�}||fS t j |¡rd|rVt||d�}||fS t|t
||d�d�}||fS t j |¡rxt|t
||d�d�}||fS t d| ¡ |d fS )	Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)rF   )r$   r@   r   )r$   r%   )r$   r   z?Location '%s' is ignored: it is neither a file nor a directory.)r*   r%   Úexistsr   Ú
startswithr	   r
   ÚloggerÚwarningr?   r   Úisdirr#   rC   Úisfiler5   )	rD   r$   r@   rE   rF   r%   r1   ÚmsgÚsourcer   r   r   Úbuild_source¦   sZ   	

ÿ
ýþ	ü
þ
þþrO   )"Úloggingr    r*   r(   Útypingr   r   r   r   Úpip._internal.models.candidater   Úpip._internal.models.linkr   Úpip._internal.utils.urlsr   r	   Úpip._internal.vcsr
   Ú	getLoggerr   rI   r   r   r3   ÚboolrB   r   r/   r"   r#   r5   r?   rC   rO   r   r   r   r   Ú<module>   sB    
$! ÿýüûúù