
    жvg!                        d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
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e$de!f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e$de de"de!de!de$dee
e$         e
e#         f         fdZ+dS )    N)defaultdict)CallableDictIterableListOptionalTuple)InvalidSdistFilenameInvalidWheelFilenamecanonicalize_nameparse_sdist_filenameparse_wheel_filename)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    X/var/www/pixelcanvas.ch/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_filer0   +   s"    777:kIIr   c                       e Zd ZdZdeddfdZd	dZedee         fd            Z	ede
eee         f         fd            ZdS )
_FlatDirectoryToUrlsz"Scans directory and caches resultspathr   Nc                 b    || _         g | _        t          t                    | _        d| _        d S )NF)_path_page_candidatesr   list_project_name_to_urls_scanned_directory)r   r3   s     r   __init__z_FlatDirectoryToUrls.__init__2   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scandirr5   r   r3   r0   r6   appendr   namer   r   r
   r8   r9   )r   entryurlproject_filenames       r   _scan_directoryz$_FlatDirectoryToUrls._scan_directory8   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c                 F    | j         s|                                  | j        S N)r9   rC   r6   r   s    r   r    z$_FlatDirectoryToUrls.page_candidatesO   s(    & 	#  """$$r   c                 F    | j         s|                                  | j        S rE   )r9   rC   r8   r   s    r   project_name_to_urlsz)_FlatDirectoryToUrls.project_name_to_urlsV   s(    & 	#  """))r   )r   N)r$   r%   r&   __doc__strr:   rC   r'   r   r    r   rG   r*   r   r   r2   r2   /   s        ,,(S (T ( ( ( (' ' ' '. %c % % % X% *d3S	>&: * * * X* * *r   r2   c                       e Zd ZU dZi Zeeef         ed<   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 )_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.
    _paths_to_urlscandidates_from_pager3   project_namer   Nc                     || _         t          |          | _        || j        v r| j        |         | _        d S t          |          | _        | j        | j        |<   d S )N)r3   )_candidates_from_pager   _project_namerL   _path_to_urlsr2   )r   rM   r3   rN   s       r   r:   z_FlatDirectorySource.__init__i   sk     &:".|<< 4&&&!%!4T!:D!54!@!@!@D(,(:D%%%r   c                     d S rE   r*   r   s    r   r   z_FlatDirectorySource.linky   s    tr   c              #   x   K   | j         j        D ]*}|                     t          |                    E d {V  +d S rE   )rR   r    rP   r   r   rA   s     r   r    z$_FlatDirectorySource.page_candidates}   sT      %5 	= 	=C11$s))<<<<<<<<<<	= 	=r   c              #   `   K   | j         j        | j                 D ]}t          |          V  d S rE   )rR   rG   rQ   r   rU   s     r   r#   z_FlatDirectorySource.file_links   s>      %:4;MN 	 	Cs))OOOO	 	r   )r$   r%   r&   rH   rL   r   rI   r2   __annotations__CandidatesFromPager:   r'   r   r   r   r(   r    r)   r#   r*   r   r   rK   rK   ^   s           79ND223888;0; ; 	;
 
; ; ; ;  htn    X= = = = =J      r   rK   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.
    rM   r   r   Nc                 "    || _         || _        d S rE   rP   _linkr   rM   r   s      r   r:   z_LocalFileSource.__init__       
 &:"


r   c                     | j         S rE   r]   r   s    r   r   z_LocalFileSource.link   
    zr   c              #      K   t          | j        j                  sd S |                     | j                  E d {V  d S rE   )r0   r]   rA   rP   r   s    r   r    z _LocalFileSource.page_candidates   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 rE   )r0   r]   rA   r   s    r   r#   z_LocalFileSource.file_links   s3      (( 	Fjr   r$   r%   r&   rH   rX   r   r:   r'   r   r   r(   r    r)   r#   r*   r   r   rZ   rZ      s         0  
	    htn    X: : : : :
J      r   rZ   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.
    rM   page_validatorr   r   Nc                 0    || _         || _        || _        d S rE   )rP   _page_validatorr]   )r   rM   rh   r   s       r   r:   z_RemoteFileSource.__init__   s     &:"-


r   c                     | j         S rE   ra   r   s    r   r   z_RemoteFileSource.link   rb   r   c              #      K   |                      | j                  sd S |                     | j                  E d {V  d S rE   )rj   r]   rP   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 rE   ra   r   s    r   r#   z_RemoteFileSource.file_links   s      jr   )r$   r%   r&   rH   rX   PageValidatorr   r:   r'   r   r   r(   r    r)   r#   r*   r   r   rg   rg      s         0 & 	
 
    htn    X: : : : :
J      r   rg   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.
    rM   r   r   Nc                 "    || _         || _        d S rE   r\   r^   s      r   r:   z_IndexDirectorySource.__init__   r_   r   c                     | j         S rE   ra   r   s    r   r   z_IndexDirectorySource.link   rb   r   c              #   J   K   |                      | j                  E d {V  d S rE   r\   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   re   r*   r   r   rp   rp      s         0  
	    htn    X: : : : :J      r   rp   locationrM   rh   
expand_dircache_link_parsingrN   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)rw   )rM   rh   r   )rM   r3   rN   )rM   r   z?Location '%s' is ignored: it is neither a file nor a directory.)r<   r3   existsr   
startswithr   r   loggerwarningrg   r   isdirrK   rp   isfilerZ   )
ru   rM   rh   rv   rw   rN   r3   rA   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   ),loggingr.   r<   collectionsr   typingr   r   r   r   r   r	   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   boolrn   r   rI   r0   r2   rK   rZ   rg   rp   r   r*   r   r   <module>r      s        				 # # # # # # B B B B B B B B B B B B B B B B              A @ @ @ @ @ * * * * * * = = = = = = = = $ $ $ $ $ $		8	$	$01d^
tfh/D&EEF $&$ $ $ $ $ $ $ $JC JD J J J J,* ,* ,* ,* ,* ,* ,* ,*^% % % % %: % % %P    z   B    
   @    J   4;; -; "	;
 ; ; ; 8C=(:../; ; ; ; ; ;r   