
    e                        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 j        e          Zee
         Zee         Zeegee
         f         Zeegef         Z G d d          Zd	ed
efdZ G d de          Z G d de          Z G d de          Z G d de          Z dededededed
eee         ee         f         fdZ!dS )    N)CallableIterableOptionalTuple)InstallationCandidate)Link)path_to_urlurl_to_path)is_urlc                   N    e Zd Zedee         fd            ZdefdZde	fdZ
dS )
LinkSourcereturnc                     t                      )z,Returns the underlying link, if there's one.NotImplementedErrorselfs    R/var/www/html/api/venv/lib/python3.11/site-packages/pip/_internal/index/sources.pylinkzLinkSource.link   s     "###    c                     t                      )z9Candidates found by parsing an archive listing HTML file.r   r   s    r   page_candidateszLinkSource.page_candidates       !###r   c                     t                      )z,Links found by specifying archives directly.r   r   s    r   
file_linkszLinkSource.file_links   r   r   N)__name__
__module____qualname__propertyr   r   r   FoundCandidatesr   
FoundLinksr    r   r   r   r      ss        $htn $ $ $ X$$ $ $ $ $$J $ $ $ $ $ $r   r   file_urlr   c                 B    t          j        | d          d         dk    S )NF)strictr   z	text/html)	mimetypes
guess_type)r#   s    r   _is_html_filer(   #   s"    777:kIIr   c                   f    e Zd ZdZdededdfdZedee	         fd            Z
defdZdefd	ZdS )
_FlatDirectorySourcezLink 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                     || _         t          j        t          j                            |                    | _        d S N)_candidates_from_pagepathlibPathosr,   realpath_path)r   r+   r,   s      r   __init__z_FlatDirectorySource.__init__0   s1    
 &:"\"'"2"24"8"899


r   c                     d S r.   r"   r   s    r   r   z_FlatDirectorySource.link8   s    tr   c              #      K   | j                                         D ]V}t          t          |                    }t	          |          s.|                     t          |                    E d {V  Wd S r.   )r4   iterdirr	   strr(   r/   r   r   r,   urls      r   r   z$_FlatDirectorySource.page_candidates<   s      J&&(( 	= 	=Dc$ii((C %% 11$s))<<<<<<<<<<		= 	=r   c              #      K   | j                                         D ]?}t          t          |                    }t	          |          r.t          |          V  @d S r.   )r4   r8   r	   r9   r(   r   r:   s      r   r   z_FlatDirectorySource.file_linksC   sd      J&&(( 	 	Dc$ii((CS!! s))OOOO		 	r   )r   r   r   __doc__CandidatesFromPager9   r5   r   r   r   r   r    r   r!   r   r"   r   r   r*   r*   '   s         :0: : 
	: : : : htn    X= = = = =J      r   r*   c                   f    e Zd ZdZdededdfdZedee         fd            Z	de
fdZdef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                 "    || _         || _        d S r.   r/   _linkr   r+   r   s      r   r5   z_LocalFileSource.__init__U       
 &:"


r   c                     | j         S r.   rC   r   s    r   r   z_LocalFileSource.link]   
    zr   c              #      K   t          | j        j                  sd S |                     | j                  E d {V  d S r.   )r(   rC   r;   r/   r   s    r   r   z _LocalFileSource.page_candidatesa   sM      TZ^,, 	F--dj99999999999r   c              #   R   K   t          | j        j                  rd S | j        V  d S r.   )r(   rC   r;   r   s    r   r   z_LocalFileSource.file_linksf   s3      (( 	Fjr   r   r   r   r=   r>   r   r5   r   r   r   r    r   r!   r   r"   r   r   r@   r@   K   s         0  
	    htn    X: : : : :
J      r   r@   c                   j    e Zd ZdZdedededdfdZede	e         fd            Z
defd	Zdef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                 0    || _         || _        || _        d S r.   )r/   _page_validatorrC   )r   r+   rN   r   s       r   r5   z_RemoteFileSource.__init__u   s     &:"-


r   c                     | j         S r.   rG   r   s    r   r   z_RemoteFileSource.link   rH   r   c              #      K   |                      | j                  sd S |                     | j                  E d {V  d S r.   )rP   rC   r/   r   s    r   r   z!_RemoteFileSource.page_candidates   sQ      ##DJ// 	F--dj99999999999r   c              #      K   | j         V  d S r.   rG   r   s    r   r   z_RemoteFileSource.file_links   s      jr   )r   r   r   r=   r>   PageValidatorr   r5   r   r   r   r    r   r!   r   r"   r   r   rM   rM   l   s         0 & 	
 
    htn    X: : : : :
J      r   rM   c                   f    e Zd ZdZdededdfdZedee         fd            Z	de
fdZdefd	ZdS )
_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                 "    || _         || _        d S r.   rB   rD   s      r   r5   z_IndexDirectorySource.__init__   rE   r   c                     | j         S r.   rG   r   s    r   r   z_IndexDirectorySource.link   rH   r   c              #   J   K   |                      | j                  E d {V  d S r.   rB   r   s    r   r   z%_IndexDirectorySource.page_candidates   s4      --dj99999999999r   c                     dS )Nr"   r"   r   s    r   r   z _IndexDirectorySource.file_links   s    rr   rK   r"   r   r   rV   rV      s         0  
	    htn    X: : : : :J      r   rV   locationr+   rN   
expand_dircache_link_parsingc                   d }d }t           j                            |           rt          |           }| }n8|                     d          r| }t          |           }nt          |           r| }|d}t                              ||            dS |%t          ||t          ||                    }||fS t           j                            |          r8|rt          ||          }n t          |t          ||                    }||fS t           j                            |          r$t          |t          ||                    }||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)r]   )r+   rN   r   )r+   r,   )r+   r   z?Location '%s' is ignored: it is neither a file nor a directory.)r2   r,   existsr	   
startswithr
   r   loggerwarningrM   r   isdirr*   rV   isfiler@   )	r[   r+   rN   r\   r]   r,   r;   msgsources	            r   build_sourcerg      s    DC	w~~h (##			W	%	% 8$$			 
{K 	 	sH%%%||.!5)c.@AAA
 
 

 V}	w}}T  		)%9  FF
 +%9#2DEEE  F V}			 !!5c.@AAA
 
 
 V}
NNI   ;r   )"loggingr&   r2   r0   typingr   r   r   r   pip._internal.models.candidater   pip._internal.models.linkr   pip._internal.utils.urlsr	   r
   pip._internal.vcsr   	getLoggerr   ra   r    r!   r>   boolrT   r   r9   r(   r*   r@   rM   rV   rg   r"   r   r   <module>rp      sR        				  6 6 6 6 6 6 6 6 6 6 6 6 @ @ @ @ @ @ * * * * * * = = = = = = = = $ $ $ $ $ $		8	$	$01d^
tfh/D&EEF $&$ $ $ $ $ $ $ $JC JD J J J J! ! ! ! !: ! ! !H    z   B    
   @    J   4:: -: "	:
 : : 8C=(:../: : : : : :r   