
    dh!                       d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ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j4                  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dZ# G d d      Z$ G d de"      Z% G d de"      Z& G d de"      Z' G d de"      Z(	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ)y)    )annotationsN)defaultdict)Iterable)Callable)InvalidSdistFilenameInvalidWheelFilenamecanonicalize_nameparse_sdist_filenameparse_wheel_filename)InstallationCandidate)Link)path_to_urlurl_to_path)is_urlc                  .    e Zd Zedd       ZddZddZy)
LinkSourcec                    t               )z,Returns the underlying link, if there's one.NotImplementedErrorselfs    ]/var/www/html/vivango/api/ia/venv/lib/python3.12/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returnzLink | Noner!   FoundCandidatesr!   
FoundLinks)__name__
__module____qualname__propertyr   r   r    r   r   r   r      s    $ $$$r   r   c                <    t        j                  | d      d   dk(  S )NF)strictr   z	text/html)	mimetypes
guess_type)file_urls    r   _is_html_filer0   .   s    7:kIIr   c                  D    e Zd ZdZddZddZed	d       Zed
d       Zy)_FlatDirectoryToUrlsz"Scans directory and caches resultsc                V    || _         g | _        t        t              | _        d| _        y )NF)_path_page_candidatesr   list_project_name_to_urls_scanned_directory)r   paths     r   __init__z_FlatDirectoryToUrls.__init__5   s&    
+-;Ft;L""'r   c                   t        j                  | j                        D ]u  }t        |j                        }t        |      r| j                  j                  |       ?	 t        |j                        d   }| j                  |   j                  |       w d| _        y# t        $ r- 	 t        |j                        d   }n# t        $ r Y Y w xY wY ]w xY w)zrScans directory once and populates both page_candidates
        and project_name_to_urls at the same time
        r   TN)osscandirr4   r   r9   r0   r5   appendr   namer   r
   r   r7   r8   )r   entryurlproject_filenames       r   _scan_directoryz$_FlatDirectoryToUrls._scan_directory;   s     ZZ

+ 	EEejj)CS!%%,,S1#7

#CA#F  &&'78??D!	E" #' ( ';EJJ'G'J$+  %s6    B  	C*CC	CCCCCc                R    | j                   s| j                          | j                  S N)r8   rC   r5   r   s    r   r   z$_FlatDirectoryToUrls.page_candidatesR   s#    &&  "$$$r   c                R    | j                   s| j                          | j                  S rE   )r8   rC   r7   r   s    r   project_name_to_urlsz)_FlatDirectoryToUrls.project_name_to_urlsY   s#    &&  ")))r   N)r9   strr!   None)r!   rI   )r!   z	list[str])r!   zdict[str, list[str]])	r&   r'   r(   __doc__r:   rC   r)   r   rG   r*   r   r   r2   r2   2   s7    ,('. % % * *r   r2   c                  Z    e Zd ZU dZi Zded<   	 	 	 	 	 	 	 	 d	dZed
d       ZddZ	ddZ
y)_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.
    zdict[str, _FlatDirectoryToUrls]_paths_to_urlsc                    || _         t        |      | _        || j                  v r| j                  |   | _        y t        |      | _        | j                  | j                  |<   y )N)r9   )_candidates_from_pager	   _project_namerM   _path_to_urlsr2   )r   candidates_from_pager9   project_names       r   r:   z_FlatDirectorySource.__init__l   s_     &:".|< 4&&&!%!4!4T!:D!54!@D(,(:(:D%r   c                     y rE   r*   r   s    r   r   z_FlatDirectorySource.link|   s    r   c              #     K   | j                   j                  D ]$  }| j                  t        |            E d {    & y 7 wrE   )rQ   r   rO   r   r   rA   s     r   r   z$_FlatDirectorySource.page_candidates   s<     %%55 	=C11$s)<<<	=<s   7AAAc              #  v   K   | j                   j                  | j                     D ]  }t        |        y wrE   )rQ   rG   rP   r   rV   s     r   r   z_FlatDirectorySource.file_links   s5     %%::4;M;MN 	Cs)O	s   79N)rR   CandidatesFromPager9   rH   rS   rH   r!   rI   r    r"   r$   )r&   r'   r(   rJ   rM   __annotations__r:   r)   r   r   r   r*   r   r   rL   rL   a   s]     79N38;0; ; 	;
 
;   =r   rL   c                  F    e Zd ZdZ	 	 	 	 	 	 ddZedd       Zd	dZd
dZy)_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.
    c                     || _         || _        y rE   rO   _linkr   rR   r   s      r   r:   z_LocalFileSource.__init__       
 &:"
r   c                    | j                   S rE   r^   r   s    r   r   z_LocalFileSource.link       zzr   c              #     K   t        | j                  j                        sy | j                  | j                        E d {    y 7 wrE   )r0   r^   rA   rO   r   s    r   r   z _LocalFileSource.page_candidates   s1     TZZ^^,--djj999s   ?A	AA	c              #  h   K   t        | j                  j                        ry | j                   y wrE   )r0   r^   rA   r   s    r   r   z_LocalFileSource.file_links   s#     (jjs   02NrR   rX   r   r   r!   rI   r    r"   r$   	r&   r'   r(   rJ   r:   r)   r   r   r   r*   r   r   r[   r[      sF    0  
	  :
r   r[   c                  J    e Zd ZdZ	 	 	 	 	 	 	 	 ddZedd       Zd	dZd
dZy)_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.
    c                .    || _         || _        || _        y rE   )rO   _page_validatorr^   )r   rR   page_validatorr   s       r   r:   z_RemoteFileSource.__init__   s     &:"-
r   c                    | j                   S rE   rb   r   s    r   r   z_RemoteFileSource.link   rc   r   c              #     K   | j                  | j                        sy | j                  | j                        E d {    y 7 wrE   )rk   r^   rO   r   s    r   r   z!_RemoteFileSource.page_candidates   s3     ##DJJ/--djj999s   ;AAAc              #  (   K   | j                    y wrE   rb   r   s    r   r   z_RemoteFileSource.file_links   s     jjs   N)rR   rX   rl   PageValidatorr   r   r!   rI   r    r"   r$   rg   r*   r   r   ri   ri      sP    0 & 	
 
  :
r   ri   c                  F    e Zd ZdZ	 	 	 	 	 	 ddZedd       Zd	dZd
dZy)_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.
    c                     || _         || _        y rE   r]   r_   s      r   r:   z_IndexDirectorySource.__init__   r`   r   c                    | j                   S rE   rb   r   s    r   r   z_IndexDirectorySource.link   rc   r   c              #  V   K   | j                  | j                        E d {    y 7 wrE   r]   r   s    r   r   z%_IndexDirectorySource.page_candidates   s     --djj999s   )')c                     y)Nr*   r*   r   s    r   r   z _IndexDirectorySource.file_links   s    r   Nrf   r    r"   r$   rg   r*   r   r   rr   rr      sF    0  
	  :r   rr   c               x   d }d }t         j                  j                  |       rt        |       }| }n,| j	                  d      r| }t        |       }nt        |       r| }|d}t        j                  ||        y|t        ||t        ||            }	||	fS t         j                  j                  |      r0|rt        |||      }	||	fS t        |t        ||            }	||	fS t         j                  j                  |      rt        |t        ||            }	||	fS t        j                  d|        |d fS )	Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)cache_link_parsing)rR   rl   r   )rR   r9   rS   )rR   r   z?Location '%s' is ignored: it is neither a file nor a directory.)r<   r9   existsr   
startswithr   r   loggerwarningri   r   isdirrL   rr   isfiler[   )
locationrR   rl   
expand_dirrx   rS   r9   rA   msgsources
             r   build_sourcer      sP    DC	ww~~h(#			W	%8$		
{K 	 	sH%|.!5)c.@A

 V}	ww}}T)%9)F V}	 +%9#2DEF V}		!!5c.@A
 V}
NNI ;r   )r/   rH   r!   bool)r   rH   rR   rX   rl   rp   r   r   rx   r   rS   rH   r!   z$tuple[str | None, LinkSource | None])*
__future__r   loggingr-   r<   collectionsr   collections.abcr   typingr   pip._vendor.packaging.utilsr   r   r	   r
   r   pip._internal.models.candidater   pip._internal.models.linkr   pip._internal.utils.urlsr   r   pip._internal.vcsr   	getLoggerr&   r{   r#   r%   rX   r   rp   r   r0   r2   rL   r[   ri   rr   r   r*   r   r   <module>r      s   "   	 # $   A * = $			8	$01d^
tfh/D&EEF $&$ $J,* ,*^%: %Pz B
 @J 4;; -; "	;
 ; ; ; *;r   