U ÀÒ.eÌã@s´ddlZddlZddlZddlmZddlmZddlm Z m Z m Z ddl m Z ddlmZddlmZmZer ddlmZmZmZmZdd lmZdd lmZGd d „d e ƒZdS) éN)Úparse)ÚWHEEL_EXTENSION)Úredact_auth_from_urlÚsplit_auth_from_netlocÚsplitext)ÚKeyBasedCompareMixin)ÚMYPY_CHECK_RUNNING)Ú path_to_urlÚ url_to_path)ÚOptionalÚTextÚTupleÚUnion)ÚHTMLPage)ÚHashescs@eZdZdZd6‡fdd„ Zdd„Zdd„Zed d „ƒZed d „ƒZ ed d„ƒZ edd„ƒZ edd„ƒZ edd„ƒZ dd„Zedd„ƒZedd„ƒZe d¡Zedd„ƒZe d¡Zedd „ƒZe d!¡Zed"d#„ƒZed$d%„ƒZed&d'„ƒZed(d)„ƒZd*d+„Zed,d-„ƒZed.d/„ƒZed0d1„ƒZed2d3„ƒZ d4d5„Z!‡Z"S)7ÚLinkz?Represents a parsed link from a Package Index's simple URL NcsV| d¡rt|ƒ}t |¡|_||_||_|r2|nd|_||_t t |ƒj |t d�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. z\\N)ÚkeyZdefining_class) Ú startswithr Ú urllib_parseZurlsplitÚ _parsed_urlÚ_urlÚ comes_fromÚrequires_pythonÚ yanked_reasonÚsuperrÚ__init__)ÚselfÚurlrrr©Ú __class__©ú=/usr/lib/python3.8/site-packages/pip/_internal/models/link.pyrs  z Link.__init__cCsD|jrd|j}nd}|jr2dt|jƒ|j|fStt|jƒƒSdS)Nz (requires-python:%s)Úz%s (from %s)%s)rrrrÚstr)rZrpr r r!Ú__str__Es  ÿz Link.__str__cCsd|S)Nz r ©rr r r!Ú__repr__Psz Link.__repr__cCs|jS©N)rr%r r r!rSszLink.urlcCsL|j d¡}t |¡}|s,t|jƒ\}}|St |¡}|sHtd|j ƒ‚|S)Nú/zURL %r produced no filename) ÚpathÚrstripÚ posixpathÚbasenamerÚnetlocrÚunquoteÚAssertionErrorr)rr)Únamer-Z user_passr r r!ÚfilenameXs   z Link.filenamecCs t|jƒSr')r rr%r r r!Ú file_pathgszLink.file_pathcCs|jjSr')rÚschemer%r r r!r3lsz Link.schemecCs|jjS)z4 This can contain auth information. )rr-r%r r r!r-qsz Link.netloccCst |jj¡Sr')rr.rr)r%r r r!r)ysz Link.pathcCstt |j d¡¡ƒS)Nr()rr+r,r)r*r%r r r!r~sz Link.splitextcCs | ¡dS©Né)rr%r r r!Úext‚szLink.extcCs$|j\}}}}}t ||||df¡Sr')rrZ urlunsplit)rr3r-r)ZqueryZfragmentr r r!Úurl_without_fragment‡szLink.url_without_fragmentz[#&]egg=([^&]*)cCs |j |j¡}|sdS| d¡Sr4)Ú_egg_fragment_reÚsearchrÚgroup©rÚmatchr r r!Ú egg_fragment�szLink.egg_fragmentz[#&]subdirectory=([^&]*)cCs |j |j¡}|sdS| d¡Sr4)Ú_subdirectory_fragment_rer9rr:r;r r r!Úsubdirectory_fragment™szLink.subdirectory_fragmentz2(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)cCs |j |j¡}|r| d¡SdS)Né©Ú_hash_rer9rr:r;r r r!Úhash¥s z Link.hashcCs |j |j¡}|r| d¡SdSr4rAr;r r r!Ú hash_name­s zLink.hash_namecCs$t |j dd¡d dd¡d¡S)Nú#r5rú?)r+r,rÚsplitr%r r r!Úshow_urlµsz Link.show_urlcCs |jdkS)NÚfile)r3r%r r r!Úis_fileºsz Link.is_filecCs|jotj |j¡Sr')rJÚosr)Úisdirr2r%r r r!Úis_existing_dir¿szLink.is_existing_dircCs |jtkSr')r6rr%r r r!Úis_wheelÃsz Link.is_wheelcCsddlm}|j|jkS)Nr)Úvcs)Zpip._internal.vcsrOr3Z all_schemes)rrOr r r!Úis_vcsÈs z Link.is_vcscCs |jdk Sr')rr%r r r!Ú is_yankedÏszLink.is_yankedcCs |jdk Sr')rDr%r r r!Úhas_hashÔsz Link.has_hashcCs@|dks|jsdS|jdk s t‚|jdk s.t‚|j|j|jd�S)zG Return True if the link has a hash and it is allowed. NF)Z hex_digest)rRrDr/rCÚis_hash_allowed)rZhashesr r r!rSØs zLink.is_hash_allowed)NNN)#Ú__name__Ú __module__Ú __qualname__Ú__doc__rr$r&Úpropertyrr1r2r3r-r)rr6r7ÚreÚcompiler8r=r>r?rBrCrDrHrJrMrNrPrQrRrSÚ __classcell__r r rr!rsfû'             ÿ        r)rKr+rYZpip._vendor.six.moves.urllibrrZpip._internal.utils.filetypesrZpip._internal.utils.miscrrrZpip._internal.utils.modelsrZpip._internal.utils.typingrZpip._internal.utils.urlsr r Útypingr r r rZpip._internal.collectorrZpip._internal.utils.hashesrrr r r r!Ús