
    q"hT                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
JrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJrJrJrJr  S SKJ r J!r!  \(       a  S S	K"J#r#  \RH                  " \%5      r&S
r'\	" SS9 " S S5      5       r(\	" SS9 " S S5      5       r)S\\\*\*4      S\\\*\*4      4S jr+S\*S\*4S jr,S\*S\*4S jr-\R\                  " S\R^                  5      r0S\*S\1S\*4S jr2S\*S\*4S jr3S\*S\*S\*4S jr4\ Rj                   " S S 5      5       r6 " S! S"\5      r7S#\6S\74S$ jr8\ Rr                  " SS%9S&\6S'\6S\14S( j5       r:g))    N)	dataclass)	TYPE_CHECKINGAnyDictListMapping
NamedTupleOptionalTupleUnion)
deprecated)WHEEL_EXTENSION)Hashes)pairwiseredact_auth_from_urlsplit_auth_from_netlocsplitext)path_to_urlurl_to_path)IndexContent)sha512sha384sha256sha224sha1md5T)frozenc                   (   \ rS rSr% Sr\\S'   \\S'   \R                  " SR                  SR                  S \ 5       5      S95      rSS jr\\R                   " S
S9S\S	\S    4S j5       5       rS	\\\4   4S jrS	\4S jrS\\   S	\4S jrSrg
)LinkHash+   a  Links to content may have embedded hash values. This class parses those.

`name` must be any member of `_SUPPORTED_HASHES`.

This class can be converted to and from `ArchiveInfo`. While ArchiveInfo intends to
be JSON-serializable to conform to PEP 610, this class contains the logic for
parsing a hash name and value for correctness, and then checking whether that hash
conforms to a schema with `.is_hash_allowed()`.namevaluez[#&]({choices})=([^&]*)|c              #   N   #    U  H  n[         R                  " U5      v   M     g 7fN)reescape).0	hash_names     K/var/www/html/env/lib/python3.13/site-packages/pip/_internal/models/link.py	<genexpr>LinkHash.<genexpr>@   s     UCTiRYYy11CTs   #%)choicesreturnNc                 0    U R                   [        ;   d   eg r%   )r!   _SUPPORTED_HASHESselfs    r*   __post_init__LinkHash.__post_init__D   s    yy----    maxsizeurlc                 p    U R                   R                  U5      nUc  gUR                  5       u  p4U " X4S9$ )zGSearch a string for a checksum algorithm name and encoded output value.Nr!   r"   )_hash_url_fragment_researchgroups)clsr8   matchr!   r"   s        r*   find_hash_url_fragmentLinkHash.find_hash_url_fragmentG   s:     ))005=lln**r5   c                 2    U R                   U R                  0$ r%   r:   r1   s    r*   as_dictLinkHash.as_dictQ   s    		4::&&r5   c                 F    [        U R                  U R                  /05      $ )z@Return a Hashes instance which checks only for the current hash.)r   r!   r"   r1   s    r*   	as_hashesLinkHash.as_hashesT   s    tyy4::,/00r5   hashesc                 R    Uc  gUR                  U R                  U R                  S9$ )z9
Return True if the current hash is allowed by `hashes`.
F)
hex_digest)is_hash_allowedr!   r"   r2   rH   s     r*   rK   LinkHash.is_hash_allowedX   s*     >%%diiDJJ%GGr5    r.   N)__name__
__module____qualname____firstlineno____doc__str__annotations__r&   compileformatjoinr0   r;   r3   classmethod	functools	lru_cacher
   r@   r   rC   r   rF   boolrK   __static_attributes__rN   r5   r*   r   r   +   s    7 IJJJ 	#))HHUCTUU 	* 	
	. &+ +*1E + ' +'c3h '16 1Hhv&6 H4 Hr5   r   c                   >    \ rS rSr% Sr\\\\4      \S'   SS jr	Sr
g)MetadataFilea   zFInformation about a core metadata file associated with a distribution.rH   Nc                 f    U R                   b$  [        S U R                    5       5      (       d   eg g )Nc              3   2   #    U  H  o[         ;   v   M     g 7fr%   )r0   )r(   r!   s     r*   r+   -MetadataFile.__post_init__.<locals>.<genexpr>i   s     I[T00[s   )rH   allr1   s    r*   r3   MetadataFile.__post_init__g   s,    ;;"IT[[IIIII #r5   rN   rO   )rP   rQ   rR   rS   rT   r
   r   rU   rV   r3   r^   rN   r5   r*   r`   r`   a   s    PT#s(^$$Jr5   r`   rH   r.   c                     U c  g U R                  5        VVs0 s H  u  pU[        ;   d  M  X_M     n nnU (       d  g U $ s  snnf r%   )itemsr0   )rH   nvs      r*   supported_hashesrk   l   sE     ~%||~H~tq6G1Gdad~FHM Is   ??partc                 z    [         R                  R                  [         R                  R                  U 5      5      $ )zH
Clean a "part" of a URL path (i.e. after splitting on "@" characters).
)urllibparsequoteunquoterl   s    r*   _clean_url_path_partrs   w   s(    
 <<fll224899r5   c                 z    [         R                  R                  [         R                  R                  U 5      5      $ )z
Clean the first part of a URL path that corresponds to a local
filesystem path (i.e. the first part after splitting on "@" characters).
)rn   requestpathname2urlurl2pathnamerr   s    r*   _clean_file_url_pathrx      s(     >>&&v~~'B'B4'HIIr5   z(@|%2F)pathis_local_pathc                 :   U(       a  [         nO[        n[        R                  U 5      n/ n[	        [
        R                  " US/5      5       H;  u  pVUR                  U" U5      5        UR                  UR                  5       5        M=     SR                  U5      $ )z"
Clean the path portion of a URL.
 )
rx   rs   _reserved_chars_resplitr   	itertoolschainappendupperrY   )ry   rz   
clean_funcpartscleaned_partsto_cleanreserveds          r*   _clean_url_pathr      s     )
)
 $$T*EM&yurd'CDZ12X^^-. E
 77=!!r5   r8   c                     [         R                  R                  U 5      nUR                  (       + n[	        UR
                  US9n[         R                  R                  UR                  US95      $ )z
Make sure a link is fully quoted.
For example, if ' ' occurs in the URL, it will be replaced with "%20",
and without double-quoting other characters.
)rz   )ry   )rn   ro   urlsplitnetlocr   ry   
urlunsplit_replace)r8   resultrz   ry   s       r*   _ensure_quoted_urlr      sT     \\""3'F%M6;;mDD<<""6???#=>>r5   base_urlc                 p    UR                  S5      (       a  U$ [        R                  R                  X5      $ )z_
A faster implementation of urllib.parse.urljoin with a shortcut
for absolute http/https URLs.
)zhttps://zhttp://)
startswithrn   ro   urljoin)r   r8   s     r*   _absolute_link_urlr      s.    
 ~~-..
||##H22r5   c                      \ rS rSrSr/ SQr      S7S\S\\\S4      S\\   S	\\   S
\\	   S\
S\\\\4      SS4S jjr\S\\\4   S\S\S    4S j5       r\S\\\\   4   S\S\S\S    4S j5       rS\4S jrS\4S jrS\4S jrS\S\
4S jrS\S\
4S jr\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S  j5       r\S\4S! j5       rS\ \\4   4S" jr!\S\4S# j5       r"\S\4S$ j5       r#\$RJ                  " S%5      r&\$RJ                  " S&\$RN                  5      r(S\\   4S' jr)\$RJ                  " S(5      r*\S\\   4S) j5       r+S\S    4S* jr,S\-4S+ jr.\S\\   4S, j5       r/\S\\   4S- j5       r0\S\4S. j5       r1\S\
4S/ j5       r2S\
4S0 jr3\S\
4S1 j5       r4\S\
4S2 j5       r5\S\
4S3 j5       r6\S\
4S4 j5       r7S\\-   S\
4S5 jr8S6r9g)8Link   z:Represents a parsed link from a Package Index's simple URL)
_parsed_url_url_path_hashes
comes_fromrequires_pythonyanked_reasonmetadata_file_datacache_link_parsingegg_fragmentNr8   r   r   r   r   r   r   rH   r.   c                    UR                  S5      (       a  [        U5      n[        R                  R	                  U5      U l        Xl        [        R                  R                  U R
                  R                  5      U l	        [        R                  U5      nUc  0 OUR                  5       n	Uc  Xl        O0 UEU	EU l        X l        U(       a  UOSU l        X@l        XPl        X`l        U R'                  5       U l        g)a  
:param url: url of the resource pointed to (href of the link)
:param comes_from: instance of IndexContent where the link was found,
    or string.
:param requires_python: String containing the `Requires-Python`
    metadata field, specified in PEP 345. This may be specified by
    a data-requires-python attribute in the HTML link tag, as
    described in PEP 503.
:param yanked_reason: the reason the file has been yanked, if the
    file has been yanked, or None if the file hasn't been yanked.
    This is the value of the "data-yanked" attribute, if present, in
    a simple repository HTML link. If the file has been yanked but
    no reason was provided, this should be the empty string. See
    PEP 592 for more information and the specification.
:param metadata_file_data: the metadata attached to the file, or None if
    no such metadata is provided. This argument, if not None, indicates
    that a separate metadata file exists, and also optionally supplies
    hashes for that file.
:param cache_link_parsing: A flag that is used elsewhere to determine
    whether resources retrieved from this link should be cached. PyPI
    URLs should generally have this set to False, for example.
:param hashes: A mapping of hash names to digests to allow us to
    determine the validity of a download.
z\\N)r   r   rn   ro   r   r   r   rq   ry   r   r   r@   rC   r   r   r   r   r   r   _egg_fragmentr   )
r2   r8   r   r   r   r   r   rH   	link_hashhashes_from_links
             r*   __init__Link.__init__   s    P >>&!!c"C!<<005 	\\))$*:*:*?*?@
33C8	!*!22	8I8I8K>+L9f9(89DL$2At*"4"4 ..0r5   	file_datapage_urlc           	         UR                  S5      nUc  g[        [        X#5      5      nUR                  S5      nUR                  S5      nUR                  S0 5      nUR                  S5      nUc  UR                  S5      n[        U[        5      (       a  [        [        U5      5      n	OU(       a  [        S5      n	OSn	U(       a  [        U[        5      (       d  SnO	U(       d  SnU " UUUUUU	S	9$ )
zJ
Convert an pypi json document from a simple repository page into a Link.
r8   Nzrequires-pythonyankedrH   zcore-metadatazdist-info-metadatar|   )r   r   r   rH   r   )getr   r   
isinstancedictr`   rk   rU   )
r>   r   r   file_urlr8   	pyrequirer   rH   metadata_infor   s
             r*   	from_jsonLink.from_json  s     ==' !3H!GHMM"34	!h/x, "o6 %MM*>?M mT**!-.>}.M!N!-d!3 "& M3!?!?M M%'1
 	
r5   anchor_attribsr   c                    UR                  S5      nU(       d  g[        [        X45      5      nUR                  S5      nUR                  S5      nUR                  S5      nUc  UR                  S5      nUS:X  a  [        S5      n	OWUc  Sn	OQUR	                  S5      u  pnUS:X  a  [        [        X05      5      n	O![        R                  S	U5        [        S5      n	U " UUUUU	S
9$ )zO
Convert an anchor element's attributes in a simple repository page to a Link.
hrefNzdata-requires-pythonzdata-yankedzdata-core-metadatazdata-dist-info-metadatatrue=z8Index returned invalid data-dist-info-metadata value: %s)r   r   r   r   )r   r   r   r`   	partitionrk   loggerdebug)r>   r   r   r   r   r8   r   r   r   r   hashnamesephashvals                r*   from_elementLink.from_elementE  s    !!&) !3H!CD"&&'=>	&**=9 '**+?@ *../HIM F"!-d!3"!% &3%<%<S%A"H7cz%12BHCV2W%X" N! &2$%7"%'1
 	
r5   c                     U R                   (       a  SU R                    S3nOSnU R                  (       a  U R                   SU R                   SU 3$ U R                  $ )Nz (requires-python:)r|   z (from )r   r   redacted_url)r2   rps     r*   __str__Link.__str__y  s[    %d&:&:%;1=BB??''(/@"FF$$$r5   c                     SU  S3$ )Nz<Link >rN   r1   s    r*   __repr__Link.__repr__  s    vQr5   c                 ,    [        U R                  5      $ r%   )hashr8   r1   s    r*   __hash__Link.__hash__  s    DHH~r5   otherc                 j    [        U[        5      (       d  [        $ U R                  UR                  :H  $ r%   r   r   NotImplementedr8   r2   r   s     r*   __eq__Link.__eq__  s(    %&&!!xx599$$r5   c                 j    [        U[        5      (       d  [        $ U R                  UR                  :  $ r%   r   r   s     r*   __lt__Link.__lt__  s(    %&&!!xx%))##r5   c                     U R                   $ r%   )r   r1   s    r*   r8   Link.url  s    yyr5   c                 ,    [        U R                  5      $ r%   )r   r8   r1   s    r*   r   Link.redacted_url  s    #DHH--r5   c                     U R                   R                  S5      n[        R                  " U5      nU(       d  [	        U R
                  5      u  p4U$ [        R                  R                  U5      nU(       d   SU R                  < S35       eU$ )N/zURL z produced no filename)
ry   rstrip	posixpathbasenamer   r   rn   ro   rq   r   )r2   ry   r!   r   	user_passs        r*   filenameLink.filename  su    yy$!!$' !7t{{ CFM||##D)>tDII=(=>>tr5   c                 ,    [        U R                  5      $ r%   )r   r8   r1   s    r*   	file_pathLink.file_path  s    488$$r5   c                 .    U R                   R                  $ r%   )r   schemer1   s    r*   r   Link.scheme  s    &&&r5   c                 .    U R                   R                  $ )z$
This can contain auth information.
)r   r   r1   s    r*   r   Link.netloc  s    
 &&&r5   c                     U R                   $ r%   )r   r1   s    r*   ry   	Link.path  s    zzr5   c                 r    [        [        R                  " U R                  R	                  S5      5      5      $ )Nr   )r   r   r   ry   r   r1   s    r*   r   Link.splitext  s'    	**499+;+;C+@ABBr5   c                 (    U R                  5       S   $ N   )r   r1   s    r*   extLink.ext  s    }}q!!r5   c                 f    U R                   u  pp4n[        R                  R                  XX4S45      $ )Nr|   )r   rn   ro   r   )r2   r   r   ry   queryfragments         r*   url_without_fragmentLink.url_without_fragment  s0    040@0@-X||&&R'HIIr5   z[#&]egg=([^&]*)z)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$c                     U R                   R                  U R                  5      nU(       d  g UR                  S5      nU R                  R                  U5      (       d  [        U  S3SSSS9  U$ )Nr   z2 contains an egg fragment with a non-PEP 508 name.z8to use the req @ url syntax, and remove the egg fragmentz25.2ie3  )reasonreplacementgone_inissue)_egg_fragment_rer<   r   group_project_name_rer?   r   )r2   r?   project_names      r*   r   Link._egg_fragment  sl    %%,,TYY7 {{1~$$**<88QRV	 r5   z[#&]subdirectory=([^&]*)c                 ~    U R                   R                  U R                  5      nU(       d  g UR                  S5      $ r   )_subdirectory_fragment_rer<   r   r  )r2   r?   s     r*   subdirectory_fragmentLink.subdirectory_fragment  s0    ..55dii@{{1~r5   c                     U R                   c  gU R                   S3nU R                   R                  c  [        U5      $ [        XR                   R                  S9$ )z<Return a link to the associated core metadata file (if any).Nz	.metadata)rH   )r   r   rH   r   )r2   metadata_urls     r*   metadata_linkLink.metadata_link  sX    ""*334I>""))1%%L)@)@)G)GHHr5   c                     [        U R                  R                  5        VVs0 s H  u  pX/_M
     snn5      $ s  snnf r%   )r   r   rh   )r2   krj   s      r*   rF   Link.as_hashes  s4    $,,*<*<*>?*>$!q#v*>?@@?s   :
c                 \    [        [        U R                  R                  5       5      S 5      $ r%   )nextiterr   valuesr1   s    r*   r   	Link.hash  s!    D,,./66r5   c                 @    [        [        U R                  5      S 5      $ r%   )r  r  r   r1   s    r*   r)   Link.hash_name  s    D&--r5   c                     [         R                  " U R                  R                  SS5      S   R                  SS5      S   5      $ )N#r   r   ?)r   r   r   r~   r1   s    r*   show_urlLink.show_url  s9    !!$))//#q"9!"<"B"B3"J1"MNNr5   c                      U R                   S:H  $ )Nfile)r   r1   s    r*   is_fileLink.is_file  s    {{f$$r5   c                 z    U R                   =(       a)    [        R                  R                  U R                  5      $ r%   )r  osry   isdirr   r1   s    r*   is_existing_dirLink.is_existing_dir  s"    ||=dnn ==r5   c                 (    U R                   [        :H  $ r%   )r   r   r1   s    r*   is_wheelLink.is_wheel	  s    xx?**r5   c                 @    SSK Jn  U R                  UR                  ;   $ )Nr   )vcs)pip._internal.vcsr)  r   all_schemes)r2   r)  s     r*   is_vcsLink.is_vcs  s    ){{coo--r5   c                     U R                   S L$ r%   )r   r1   s    r*   	is_yankedLink.is_yanked  s    !!--r5   c                 ,    [        U R                  5      $ r%   )r]   r   r1   s    r*   has_hashLink.has_hash  s    DLL!!r5   c                 f   ^ Tc  g[        U4S jU R                  R                  5        5       5      $ )zC
Return True if the link has a hash and it is allowed by `hashes`.
Fc              3   J   >#    U  H  u  pTR                  X5      v   M     g 7fr%   )rK   )r(   r  rj   rH   s      r*   r+   'Link.is_hash_allowed.<locals>.<genexpr>!  s#     Q<PDA6))!//<Ps    #)anyr   rh   rL   s    `r*   rK   Link.is_hash_allowed  s+     >QDLL<N<N<PQQQr5   )
r   r   r   r   r   r   r   r   r   r   )NNNNTN):rP   rQ   rR   rS   rT   	__slots__rU   r
   r   r`   r]   r   r   rZ   r   r   r   r   r   r   intr   r   r   propertyr8   r   r   r   r   r   ry   r   r   r   r   r&   rW   r   
IGNORECASEr  r   r  r  r  r   rF   r   r)   r  r  r#  r&  r,  r/  r2  rK   r^   rN   r5   r*   r   r      s   DI  <@)-'+59#'.2?1?1 U3#678?1 "#	?1
  }?1 %\2?1 !?1 c*+?1 
?1B 0
S>0
 0
 
&		0
 0
d 1
S(3-/01
 1
 	1

 
&	1
 1
f% % #  # %C %D %
$C $D $
 S   .c . . #   %3 % % ' ' ' ' ' ' c  C%S/ C "S " " Jc J J zz"45 zz4bmmx} $ !#

+F Gx}  Ix/ IA6 A 7hsm 7 7 .8C= . . O# O O % % %> > +$ + + . . .
 .4 . . "$ " "Rhv&6 R4 Rr5   r   c                       \ rS rSr% Sr\R                  R                  \S'   \	\
\\
   4   \S'   \
\S'   \	\
\
4   \S'   Srg)	_CleanResulti$  aE  Convert link for equivalency check.

This is used in the resolver to check whether two URL-specified requirements
likely point to the same distribution and can be considered equivalent. This
equivalency logic avoids comparing URLs literally, which can be too strict
(e.g. "a=1&b=2" vs "b=2&a=1") and produce conflicts unexpecting to users.

Currently this does three things:

1. Drop the basic auth part. This is technically wrong since a server can
   serve different content based on auth, but if it does that, it is even
   impossible to guarantee two URLs without auth are equivalent, since
   the user can input different auth information when prompted. So the
   practical solution is to assume the auth doesn't affect the response.
2. Parse the query to avoid the ordering issue. Note that ordering under the
   same key in the query are NOT cleaned; i.e. "a=1&a=2" and "a=2&a=1" are
   still considered different.
3. Explicitly drop most of the fragment part, except ``subdirectory=`` and
   hash values, since it should have no impact the downloaded content. Note
   that this drops the "egg=" part historically used to denote the requested
   project (and extras), which is wrong in the strictest sense, but too many
   people are supplying it inconsistently to cause superfluous resolution
   conflicts, so we choose to also ignore them.
parsedr   subdirectoryrH   rN   N)rP   rQ   rR   rS   rT   rn   ro   SplitResultrV   r   rU   r   r^   rN   r5   r*   r>  r>  $  s@    2 LL$$$T#YcNr5   r>  linkc                 *   U R                   nUR                  R                  SS5      S   nUR                  S:X  a	  U(       d  Sn[        R
                  R                  UR                  5      nSU;   a  [        R                  SU 5         US   S	   n[         Vs0 s H  oUU;   d  M
  XSU   S	   _M     nn[        UR                  US
S
S9[        R
                  R                  UR                  5      UUS9$ ! [        [        4 a    S
n Nyf = fs  snf )N@r   r  	localhosteggzIgnoring egg= fragment in %sr@  r   r|   )r   r   r   )r?  r   r@  rH   )r   r   rsplitr   rn   ro   parse_qsr   r   r   
IndexErrorKeyErrorr0   r>  r   r   )rB  r?  r   r   r@  r  rH   s          r*   _clean_linkrL  D  s   F]]!!#q)"-F}}v||$$V__5H3T:  /2
 *;L):A8ma!Q):FLfBDll##FLL1!	  !  Ms   C8 	D(D8DDr6   link1link2c                 0    [        U 5      [        U5      :H  $ r%   )rL  )rM  rN  s     r*   links_equivalentrP  ^  s    uU!333r5   );r[   r   loggingr!  r   r&   urllib.parsern   dataclassesr   typingr   r   r   r   r   r	   r
   r   r   pip._internal.utils.deprecationr   pip._internal.utils.filetypesr   pip._internal.utils.hashesr   pip._internal.utils.miscr   r   r   r   pip._internal.utils.urlsr   r   pip._internal.index.collectorr   	getLoggerrP   r   r0   r   r`   rU   rk   rs   rx   rW   r<  r}   r]   r   r   r   total_orderingr   r>  rL  r\   rP  rN   r5   r*   <module>r]     s      	  	  !
 
 
 7 9 -  >:			8	$
 L  $2H 2H 2Hj $J J JXd38n5 (4S>:R :s :s :
Js 
Js 
J ZZ	2==9 "# "d "s ",?C ?C ?3 33 33 3 `R `R `RF: @d | 4 T"4D 4 4$ 4 #4r5   