zLinkHash.=sUiRYYy1Us!)choicesc,|jtvsJyr!)r_SUPPORTED_HASHESselfs r& __post_init__zLinkHash.__post_init__Asyy----cx|jj|}|y|j\}}|||S)zGSearch a string for a checksum algorithm name and encoded output value.Nrr)_hash_url_fragment_researchgroups)clsurlmatchrrs r&find_hash_url_fragmentzLinkHash.find_hash_url_fragmentDs>))005 =lln eE**r.c2|j|jiSr!r0r+s r&as_dictzLinkHash.as_dictNs 4::&&r.cFt|j|jgiS)z@Return a Hashes instance which checks only for the current hash.)r rrr+s r& as_hasheszLinkHash.as_hashesQstyy4::,/00r.cV|y|j|j|jS)zI Return True if the current hash is allowed by `hashes`. F) hex_digest)is_hash_allowedrrr,hashess r&r>zLinkHash.is_hash_allowedUs* >%%diiDJJ%GGr.NreturnNone)r5rrBzLinkHash | None)rBdict[str, str]rBr r@z Hashes | NonerBbool)__name__ __module__ __qualname____doc____annotations__r"compileformatjoinr*r1r- classmethod functoolscacher7r9r;r>r.r&rr(s7 I J&BJJ #))HHUCTUU * .__++'1Hr.rc$eZdZUdZded<ddZy) MetadataFilezFInformation about a core metadata file associated with a distribution.dict[str, str] | Noner@cZ|jtd|jDsJyy)Nc3,K|] }|tvywr!)r*)r$rs r&r'z-MetadataFile.__post_init__..fsITt00Is)r@allr+s r&r-zMetadataFile.__post_init__ds) ;; "IT[[II II #r.NrA)rHrIrJrKrLr-rSr.r&rUrU^sP !!Jr.rUcv|y|jDcic]\}}|tvs||}}}|sy|Scc}}wr!)itemsr*)r@nvs r&supported_hashesr^isF~%||~ Htq!6G1Gad HF H  MIs55cztjjtjj|S)zP Clean a "part" of a URL path (i.e. after splitting on "@" characters). )urllibparsequoteunquote)parts r&_clean_url_path_partrets( <<  fll2248 99r.ctjjtjj|}|j dr|j d}|S)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). z///z//)r`request pathname2url url2pathname startswith removeprefix)rdrets r&_clean_file_url_pathrm|sH .. % %fnn&A&A$&G HC ~~et$ Jr.z(@|%2F)c,|rt}nt}tj|}g}t t j |dgD];\}}|j|||j|j=dj|S)z* Clean the path portion of a URL. ) rmre_reserved_chars_resplitr itertoolschainappendupperrO)path is_local_path clean_funcparts cleaned_partsto_cleanreserveds r&_clean_url_pathr}s) )   $ $T *EM&yurd'CD/(Z12X^^-./ 77= !!r.ctjj|}|j }t |j |}tjj |jd|}|j|ddz}|S)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. )rwfile)schemervN) r`raurlsplitnetlocr}rv urlunsplit_replacer)r5resultrwrvrls r&_ensure_quoted_urlrsp\\ " "3 'F %M 6;;m DD ,, ! !&//d/"K LC --#ab' !C Jr.ch|jdr|Stjj||S)zk A faster implementation of urllib.parse.urljoin with a shortcut for absolute http/https URLs. )zhttps://zhttp://)rjr`raurljoin)base_urlr5s r&_absolute_link_urlrs-  ~~-. ||##Hc22r.ceZdZdZgdZ d' d(dZe d)dZe d*dZd+dZ d+dZ d,d Z d-d Z d-d Z ed+d Zed+d Zed+dZed+dZed+dZed+dZed+dZd.dZed+dZed+dZej4dZej4dej8Zd/dZej4dZed/dZ d0dZ!d1dZ"ed/dZ#ed/dZ$ed+dZ%ed2d Z&d2d!Z'ed2d"Z(ed2d#Z)ed2d$Z*ed2d%Z+d3d&Z,y)4Linkz:Represents a parsed link from a Package Index's simple URL) _parsed_url_url_path_hashes comes_fromrequires_python yanked_reasonmetadata_file_datacache_link_parsing egg_fragmentNc|jdr t|}tjj ||_||_tjj|j j|_ tj|}|in|j} || |_ n i|| |_ ||_|r|nd|_||_||_||_|j'|_y)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)rjrr`rarrrrcrvrrr7r9rrrrrr _egg_fragmentr) r,r5rrrrrr@ link_hashhashes_from_links r&__init__z Link.__init__sP >>& !c"C!<<005 \\))$*:*:*?*?@ 33C8 !*!22 8I8I8K >+DL9f9(89DL$2At*"4"4 ..0r.c|jd}|ytt||}|jd}|jd}|jdi}|jd}||jd}t|trt t |} n|r t d} nd} |rt|tsd}n|sd}||||||| S) zZ Convert an pypi json document from a simple repository page into a Link. r5Nzrequires-pythonyankedr@z core-metadatazdist-info-metadataro)rrrr@r)getrr isinstancedictrUr^r) r4 file_datapage_urlfile_urlr5 pyrequirerr@ metadata_infors r& from_jsonzLink.from_jsons=='   !3Hh!GHMM"34 ! h/ x," o6  %MM*>?M mT *!-.>}.M!N  !-d!3 "&  M3!?M M %'1   r.c|jd}|sytt||}|jd}|jd}|jd}||jd}|dk(r td} nW|d} nR|j d\} } } | dk(rtt | | i} n!t jd |td} |||||| S) z_ Convert an anchor element's attributes in a simple repository page to a Link. hrefNzdata-requires-pythonz data-yankedzdata-core-metadatazdata-dist-info-metadatatrue=z8Index returned invalid data-dist-info-metadata value: %s)rrrr)rrrrU partitionr^loggerdebug) r4anchor_attribsrrrr5rrrrhashnamesephashvals r& from_elementzLink.from_elementJs !!&) !3Hd!CD"&&'=> &**=9 '**+?@  *../HIM F "!-d!3   "!% &3%<%rSr+s r&__repr__z Link.__repr__svQr.c,t|jSr!)hashr5r+s r&__hash__z Link.__hash__sDHH~r.c`t|tstS|j|jk(Sr!rrNotImplementedr5r,others r&__eq__z Link.__eq__s%%&! !xx599$$r.c`t|tstS|j|jkSr!rrs r&__lt__z Link.__lt__s%%&! !xx%))##r.c|jSr!)rr+s r&r5zLink.urls yyr.c,t|jSr!)r r5r+s r&rzLink.redacted_urls#DHH--r.c |jjd}tj|}|st |j \}}|St jj|}|sJd|jd|S)N/zURL z produced no filename) rvrstrip posixpathbasenamerrr`rarcr)r,rvrr user_passs r&filenamez Link.filenameswyy$!!$'!7t{{ C FIM||##D)>tDII=(=>>t r.c,t|jSr!)rr5r+s r& file_pathzLink.file_paths488$$r.c.|jjSr!)rrr+s r&rz Link.schemes&&&r.c.|jjS)z4 This can contain auth information. )rrr+s r&rz Link.netlocs &&&r.c|jSr!)rr+s r&rvz Link.paths zzr.cpttj|jj dS)Nr)rrrrvrr+s r&rz Link.splitexts' **499+;+;C+@ABBr.c(|jdSN)rr+s r&extzLink.exts}}q!!r.cn|j\}}}}}tjj||||dfS)Nro)rr`rar)r,rrrvqueryfragments r&url_without_fragmentzLink.url_without_fragments8040@0@-eX||&&eR'HIIr.z[#&]egg=([^&]*)z)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$c|jj|j}|sy|jd}|jj |st |dddd|S)Nrz2 contains an egg fragment with a non-PEP 508 name.z8to use the req @ url syntax, and remove the egg fragmentz26.0ie3)reason replacementgone_inissue)_egg_fragment_rer2rgroup_project_name_rer6r )r,r6 project_names r&rzLink._egg_fragmentsi%%,,TYY7{{1~ $$**<8 QRV  r.z[#&]subdirectory=([^&]*)ct|jj|j}|sy|jdSr)_subdirectory_fragment_rer2rr)r,r6s r&subdirectory_fragmentzLink.subdirectory_fragments0..55dii@{{1~r.c|jy|jd}|jj t|St||jjS)z  " " ) ) 1 % %L)@)@)G)GHHr.c~t|jjDcic] \}}||g c}}Scc}}wr!)r rr[)r,kr]s r&r;zLink.as_hashess2$,,*<*<*>?$!Qq1#v?@@?s9 c\tt|jjdSr!)nextiterrvaluesr+s r&rz Link.hashs!D,,./66r.c@tt|jdSr!)rrrr+s r&r%zLink.hash_namesD&--r.ctj|jjdddjdddS)N#rr?)rrrrqr+s r&show_urlz Link.show_urls9!!$))//#q"9!"<"B"B3"J1"MNNr.c |jdk(S)Nr)rr+s r&is_filez Link.is_files{{f$$r.cp|jxr)tjj|jSr!)rosrvisdirrr+s r&is_existing_dirzLink.is_existing_dir s"||= dnn ==r.c(|jtk(Sr!)rr r+s r&is_wheelz Link.is_wheelsxx?**r.c>ddlm}|j|jvS)Nr)vcs)pip._internal.vcsrr all_schemes)r,rs r&is_vcsz Link.is_vcss){{coo--r.c|jduSr!)rr+s r& is_yankedzLink.is_yankeds!!--r.c,t|jSr!)rGrr+s r&has_hashz Link.has_hashsDLL!!r.cbytfd|jjDS)zS Return True if the link has a hash and it is allowed by `hashes`. Fc3HK|]\}}j||ywr!)r>)r$rr]r@s r&r'z'Link.is_hash_allowed..&s"QDAq6))!Q/Qs")anyrr[r?s `r&r>zLink.is_hash_allowed s+ >QDLLrSr.r&rrsD I 15&*$(26#'+/?1 ?1.?1$ ?1 " ?1 0 ?1!?1)?1 ?1B0 !0 0   0 0 d1 -1 1  1  1 1 f% % $ ..  %%'''' C""JJ"rzz"45"rzz4bmm$!+ +F G  IA77..OO%%>++.. ..""Rr.rc:eZdZUdZded<ded<ded<ded <y ) _CleanResultaConvert 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. zurllib.parse.SplitResultparsedzdict[str, list[str]]rr subdirectoryrDr@N)rHrIrJrKrLrSr.r&rr)s!2 %$  r.rc|j}|jjddd}|jdk(r|sd}tj j |j}d|vrtjd| |dd }tDcic]}||vs|||d }}t|j|d d tj j |j|| S#ttf$rd }YzwxYwcc}w) N@rr localhosteggzIgnoring egg= fragment in %srrro)rrr)rrrr@)rrrsplitrr`raparse_qsrrr IndexErrorKeyErrorr*rrr)linkrrrrrr@s r& _clean_linkr Is   F ]] ! !#q )" -F }}v||$$V__5H  3T: /2 *; LAa8ma!Q LF L fBDll##FLL1!    ! MsC2 D  D 2DDc0t|t|k(Sr!)r )link1link2s r&links_equivalentr$cs u U!3 33r.)r@rVrBrV)rdrrBr)rvrrwrGrBr)r5rrBr)rrr5rrBr)rrrBr)r"rr#rrBrG)7 __future__rrQrrloggingrrr" urllib.parser`collections.abcr dataclassesrtypingrrrpip._internal.utils.deprecationr pip._internal.utils.filetypesr pip._internal.utils.hashesr pip._internal.utils.miscr r rrpip._internal.utils.urlsrrpip._internal.index.collectorr getLoggerrHrr*rrUr^rermrMrrpr}rrtotal_orderingrrr rRr$rSr.r&r3s2"  #! 79- >:   8 $ L $2H2H2Hj $JJJ:$ RZZ 2==9",&3 `R`R`RF :@4 44r.