
    ;ȋh!                       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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&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)dS )(    )annotationsN)defaultdict)Iterable)Callable)InvalidSdistFilenameInvalidWheelFilenamecanonicalize_nameparse_sdist_filenameparse_wheel_filename)InstallationCandidate)Link)path_to_urlurl_to_path)is_urlc                  6    e Zd Zed	d            Zd
dZddZdS )
LinkSourcereturnLink | Nonec                    t                      )z,Returns the underlying link, if there's one.NotImplementedErrorselfs    X/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/pip/_internal/index/sources.pylinkzLinkSource.link    s     "###    FoundCandidatesc                    t                      )z9Candidates found by parsing an archive listing HTML file.r   r   s    r   page_candidateszLinkSource.page_candidates%       !###r   
FoundLinksc                    t                      )z,Links found by specifying archives directly.r   r   s    r   
file_linkszLinkSource.file_links)   r    r   Nr   r   r   r   r   r!   )__name__
__module____qualname__propertyr   r   r#    r   r   r   r      sZ        $ $ $ X$$ $ $ $$ $ $ $ $ $r   r   file_urlstrr   boolc                B    t          j        | d          d         dk    S )NF)strictr   z	text/html)	mimetypes
guess_type)r,   s    r   _is_html_filer3   .   s"    777:kIIr   c                  R    e Zd ZdZddZddZedd	            Zedd            ZdS )_FlatDirectoryToUrlsz"Scans directory and caches resultspathr-   r   Nonec                b    || _         g | _        t          t                    | _        d| _        d S )NF)_path_page_candidatesr   list_project_name_to_urls_scanned_directory)r   r6   s     r   __init__z_FlatDirectoryToUrls.__init__5   s/    
+-;Ft;L;L""'r   c                   t          j        | j                  D ]}t          |j                  }t          |          r| j                            |           @	 t          |j	                  d         }n=# t          $ r0 	 t          |j	                  d         }n# t          $ r Y Y w xY wY nw xY w| j        |                             |           d| _        dS )zrScans directory once and populates both page_candidates
        and project_name_to_urls at the same time
        r   TN)osscandirr9   r   r6   r3   r:   appendr   namer   r
   r   r<   r=   )r   entryurlproject_filenames       r   _scan_directoryz$_FlatDirectoryToUrls._scan_directory;   s	    Z
++ 	E 	EEej))CS!! %,,S111#7
#C#CA#F  '   ';EJ'G'G'J$$+   HH %$ &'78??DDDD"&s6   A66
B0BB0
B*&B0)B**B0/B0	list[str]c                F    | j         s|                                  | j        S N)r=   rG   r:   r   s    r   r   z$_FlatDirectoryToUrls.page_candidatesR   s(    & 	#  """$$r   dict[str, list[str]]c                F    | j         s|                                  | j        S rJ   )r=   rG   r<   r   s    r   project_name_to_urlsz)_FlatDirectoryToUrls.project_name_to_urlsY   s(    & 	#  """))r   N)r6   r-   r   r7   )r   r7   )r   rH   )r   rK   )	r'   r(   r)   __doc__r>   rG   r*   r   rM   r+   r   r   r5   r5   2   s        ,,( ( ( (' ' ' '. % % % X% * * * X* * *r   r5   c                  R    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
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.
    zdict[str, _FlatDirectoryToUrls]_paths_to_urlscandidates_from_pageCandidatesFromPager6   r-   project_namer   r7   c                    || _         t          |          | _        || j        v r| j        |         | _        d S t          |          | _        | j        | j        |<   d S )N)r6   )_candidates_from_pager	   _project_namerQ   _path_to_urlsr5   )r   rR   r6   rT   s       r   r>   z_FlatDirectorySource.__init__l   sk     &:".|<< 4&&&!%!4T!:D!54!@!@!@D(,(:D%%%r   r   c                    d S rJ   r+   r   s    r   r   z_FlatDirectorySource.link|   s    tr   r   c              #  x   K   | j         j        D ]*}|                     t          |                    E d {V  +d S rJ   )rX   r   rV   r   r   rE   s     r   r   z$_FlatDirectorySource.page_candidates   sT      %5 	= 	=C11$s))<<<<<<<<<<	= 	=r   r!   c              #  `   K   | j         j        | j                 D ]}t          |          V  d S rJ   )rX   rM   rW   r   r[   s     r   r#   z_FlatDirectorySource.file_links   s>      %:4;MN 	 	Cs))OOOO	 	r   N)rR   rS   r6   r-   rT   r-   r   r7   r$   r%   r&   )r'   r(   r)   rN   rQ   __annotations__r>   r*   r   r   r#   r+   r   r   rP   rP   a   s           79N8888; ; ; ;     X= = = =     r   rP   c                  B    e Zd ZdZddZedd
            ZddZ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.
    rR   rS   r   r   r   r7   c                "    || _         || _        d S rJ   rV   _linkr   rR   r   s      r   r>   z_LocalFileSource.__init__       
 &:"


r   r   c                    | j         S rJ   rb   r   s    r   r   z_LocalFileSource.link   
    zr   r   c              #     K   t          | j        j                  sd S |                     | j                  E d {V  d S rJ   )r3   rb   rE   rV   r   s    r   r   z _LocalFileSource.page_candidates   sM      TZ^,, 	F--dj99999999999r   r!   c              #  R   K   t          | j        j                  rd S | j        V  d S rJ   )r3   rb   rE   r   s    r   r#   z_LocalFileSource.file_links   s3      (( 	Fjr   NrR   rS   r   r   r   r7   r$   r%   r&   	r'   r(   r)   rN   r>   r*   r   r   r#   r+   r   r   r_   r_      sz                X: : : :
     r   r_   c                  B    e Zd ZdZdd
Zedd            ZddZ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.
    rR   rS   page_validatorPageValidatorr   r   r   r7   c                0    || _         || _        || _        d S rJ   )rV   _page_validatorrb   )r   rR   rn   r   s       r   r>   z_RemoteFileSource.__init__   s     &:"-


r   r   c                    | j         S rJ   rf   r   s    r   r   z_RemoteFileSource.link   rg   r   r   c              #     K   |                      | j                  sd S |                     | j                  E d {V  d S rJ   )rq   rb   rV   r   s    r   r   z!_RemoteFileSource.page_candidates   sQ      ##DJ// 	F--dj99999999999r   r!   c              #     K   | j         V  d S rJ   rf   r   s    r   r#   z_RemoteFileSource.file_links   s      jr   N)rR   rS   rn   ro   r   r   r   r7   r$   r%   r&   rk   r+   r   r   rm   rm      sz                X: : : :
     r   rm   c                  B    e Zd ZdZddZedd
            ZddZd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.
    rR   rS   r   r   r   r7   c                "    || _         || _        d S rJ   ra   rc   s      r   r>   z_IndexDirectorySource.__init__   rd   r   r   c                    | j         S rJ   rf   r   s    r   r   z_IndexDirectorySource.link   rg   r   r   c              #  J   K   |                      | j                  E d {V  d S rJ   ra   r   s    r   r   z%_IndexDirectorySource.page_candidates   s4      --dj99999999999r   r!   c                    dS )Nr+   r+   r   s    r   r#   z _IndexDirectorySource.file_links   s    rr   Nrj   r$   r%   r&   rk   r+   r   r   rv   rv      sz                X: : : :     r   rv   locationrR   rS   rn   ro   
expand_dircache_link_parsingrT   $tuple[str | None, LinkSource | None]c                  d }d }t           j                            |           rt          |           }| }n8|                     d          r| }t          |           }nt          |           r| }|d}t                              ||            dS |%t          ||t          ||                    }	||	fS t           j                            |          r9|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}   )rR   rn   r   )rR   r6   rT   )rR   r   z?Location '%s' is ignored: it is neither a file nor a directory.)r@   r6   existsr   
startswithr   r   loggerwarningrm   r   isdirrP   rv   isfiler_   )
r{   rR   rn   r|   r}   rT   r6   rE   msgsources
             r   build_sourcer      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   )r,   r-   r   r.   )r{   r-   rR   rS   rn   ro   r|   r.   r}   r.   rT   r-   r   r~   )*
__future__r   loggingr1   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!   rS   r.   ro   r   r3   r5   rP   r_   rm   rv   r   r+   r   r   <module>r      s   " " " " " "      				 # # # # # # $ $ $ $ $ $                    A @ @ @ @ @ * * * * * * = = = = = = = = $ $ $ $ $ $		8	$	$01d^
tfh/D&EEF $&$ $ $ $ $ $ $ $J J J J,* ,* ,* ,* ,* ,* ,* ,*^% % % % %: % % %P    z   B    
   @    J   4; ; ; ; ; ;r   