ReY&`ddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZddlmZddlmZddlmZmZmZddlmZddlmZmZerddlmZejeZ d Z!Gd d eZ"Gd d e Z#de"de#fdZ$ej%dde"de"de&fdZ'dS)N) TYPE_CHECKINGDictList NamedTupleOptionalTupleUnion)WHEEL_EXTENSION)Hashes)redact_auth_from_urlsplit_auth_from_netlocsplitext)KeyBasedCompareMixin) path_to_url url_to_path)HTMLPage)sha1sha224sha384sha256sha512md5c eZdZdZgdZ d*dedeeedfdeed eed ed df fd Z d efd Z d efdZ e d efdZ e d efdZe d efdZe d efdZe d efdZe d efdZd eeeffdZe d efdZe d efdZejdZe d eefdZejdZe d eefdZejddeZ e d eefdZ!e d eefd Z"e d efd!Z#e d efd"Z$d efd#Z%e d efd$Z&e d efd%Z'e d efd&Z(e d efd'Z)d(ee*d efd)Z+xZ,S)+Linkz:Represents a parsed link from a Package Index's simple URL) _parsed_url_url comes_fromrequires_python yanked_reasoncache_link_parsingNTurlrrrrr returnc6|drt|}tj||_||_||_|r|nd|_||_ t |t||_ dS)a :param url: url of the resource pointed to (href of the link) :param comes_from: instance of HTMLPage 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 cache_link_parsing: A flag that is used elsewhere to determine whether resources retrieved from this link should be cached. PyPI index urls should generally have this set to False, for example. z\\N)keydefining_class) startswithrurllibparseurlsplitrrrrrsuper__init__rr )selfr!rrrr __class__s /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/models/link.pyr+z Link.__init__(s< >>& ! ! #c""C!<0055 $2AKt* S666"4c|jr d|jd}nd}|jr.dt|j|j|Stt |jS)Nz (requires-python:)z{} (from {}){})rrformatr rstr)r,rps r.__str__z Link.__str__Vst   =d&:===BBB ? 8#**$TY//" (DI77 7r/cd|dS)Nzr,s r.__repr__z Link.__repr__bsr/c|jSN)rr:s r.r!zLink.urles yr/c|jd}tj|}|st |j\}}|St j|}|sJd|j d|S)N/zURL z produced no filename) pathrstrip posixpathbasenamer netlocr'r(unquoter)r,r@namerD user_passs r.filenamez Link.filenameisy$$!$'' !7t{ C C FIM|##D))>>>DI>>>>>> r/c*t|jSr=)rr!r:s r. file_pathzLink.file_pathws48$$$r/c|jjSr=)rschemer:s r.rLz Link.scheme{s&&r/c|jjS)z4 This can contain auth information. )rrDr:s r.rDz Link.netlocs &&r/cTtj|jjSr=)r'r(rErr@r:s r.r@z Link.paths|##D$4$9:::r/ctttj|jdS)Nr?)rrBrCr@rAr:s r.rz Link.splitexts+ *49+;+;C+@+@AABBBr/c6|dSN)rr:s r.extzLink.exts}}q!!r/cd|j\}}}}}tj||||dfS)Nr2)rr'r( urlunsplit)r,rLrDr@queryfragments r.url_without_fragmentzLink.url_without_fragments6040@-eX|&&eR'HIIIr/z[#&]egg=([^&]*)cr|j|j}|sdS|dSrQ)_egg_fragment_researchrgroupr,matchs r. egg_fragmentzLink.egg_fragments7%,,TY77 4{{1~~r/z[#&]subdirectory=([^&]*)cr|j|j}|sdS|dSrQ)_subdirectory_fragment_rer[rr\r]s r.subdirectory_fragmentzLink.subdirectory_fragments7.55di@@ 4{{1~~r/z({choices})=([a-f0-9]+)|)choicescr|j|j}|r|dSdS)N_hash_rer[rr\r]s r.hashz Link.hash6 $$TY//  ";;q>> !tr/cr|j|j}|r|dSdSrQrgr]s r. hash_namezLink.hash_namerjr/ctj|jddddddS)N#rRr?)rBrCrsplitr:s r.show_urlz Link.show_urls=!$)//#q"9"9!"<"B"B3"J"J1"MNNNr/c|jdkS)Nfile)rLr:s r.is_filez Link.is_files{f$$r/cX|jo#tj|jSr=)rtosr@isdirrJr:s r.is_existing_dirzLink.is_existing_dirs|= dn = ==r/c"|jtkSr=)rSr r:s r.is_wheelz Link.is_wheelsx?**r/c*ddlm}|j|jvS)Nr)vcs)pip._internal.vcsr|rL all_schemes)r,r|s r.is_vcsz Link.is_vcss#)))))){co--r/c|jduSr=)rr:s r. is_yankedzLink.is_yankeds!--r/c|jduSr=)rlr:s r.has_hashz Link.has_hashs~T))r/hashesc~||jsdS|jJ|jJ||j|jS)zG Return True if the link has a hash and it is allowed. NF) hex_digest)rrlriis_hash_allowed)r,rs r.rzLink.is_hash_allowedsM >>5~)))y$$$%%dn%KKKr/)NNNT)-__name__ __module__ __qualname____doc__ __slots__r4rr boolr+r6r;propertyr!rHrJrLrDr@rrrSrXrecompilerZr_rarbr3join_SUPPORTED_HASHESrhrirlrqrtrxrzrrrr r __classcell__)r-s@r.rrsDDI8<)-'+#' ,5,5 ,5U3 ?34,5"# ,5  } ,5 ! ,5 ,5,5,5,5,5,5\ 8 8 8 8 8 #    SX #   X %3%%%X%''''X'''''X' ;c;;;X;C%S/CCCC"S"""X"JcJJJXJ"rz"455 hsmX !+ +F G G x}X rz"))#((;L2M2M)NNHhsmX 8C=X O#OOOXO%%%%X%>>>>>+$+++X+....X. .4...X.*$***X* Lhv&6 L4 L L L L L L L Lr/rc|eZdZUdZejjed<ee e e fed<e ed<ee e fed<dS) _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. parsedrV subdirectoryrN) rrrrr'r( SplitResult__annotations__rr4rr9r/r.rrsh2 L $$$$ T#Y  cNr/rlinkr"c|j}|jddd}|jdkr|sd}tj|jdvrt d| dd }n#ttf$rd }YnwxYwfd tD}t||d d tj|j|| S)N@rRrs localhosteggzIgnoring egg= fragment in %srrr2c6i|]}|v||dS)rr9).0krWs r. z_clean_link..s( L L LAa8mma!Qmmmr/)rDrVrW)rrVrr)rrDrsplitrLr'r(parse_qsrWloggerdebug IndexErrorKeyErrorrr_replacerV)rrrDrrrWs @r. _clean_linkrs  F ] ! !#q ) )" -F }v|$$V_55H  3T::: /2  ! M L L L): L L LF fBDDl##FL11!    s=B B"!B")maxsizelink1link2cBt|t|kSr=)r)rrs r.links_equivalentrs u  U!3!3 33r/)( functoolsloggingrvrBr urllib.parser'typingrrrrrrr pip._internal.utils.filetypesr pip._internal.utils.hashesr pip._internal.utils.miscr r rpip._internal.utils.modelsrpip._internal.utils.urlsrrpip._internal.index.collectorr getLoggerrrrrrr lru_cacherrr9r/r.rs   PPPPPPPPPPPPPPPPPP999999------ <;;;;;========7666666  8 $ $LELELELELEL ELELELP:@d|4T"""4D44$444#"444r/