U .e@sddlZddlZddlZddlmZddlmZddlm Z m Z m Z ddl m Z ddlmZddlmZmZerddlmZmZmZmZdd lmZdd lmZGd d d e ZdS) N)parse)WHEEL_EXTENSION)redact_auth_from_urlsplit_auth_from_netlocsplitext)KeyBasedCompareMixin)MYPY_CHECK_RUNNING) path_to_url url_to_path)OptionalTextTupleUnion)HTMLPage)Hashescs@eZdZdZd6fdd ZddZddZed d Zed d Z ed dZ eddZ eddZ eddZ ddZeddZeddZedZeddZedZedd Zed!Zed"d#Zed$d%Zed&d'Zed(d)Zd*d+Zed,d-Zed.d/Zed0d1Zed2d3Z d4d5Z!Z"S)7Linkz?Represents a parsed link from a Package Index's simple URL NcsV|drt|}t||_||_||_|r2|nd|_||_t t |j |t ddS)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_fromrequires_python yanked_reasonsuperr__init__)selfurlrrr __class__=/usr/lib/python3.8/site-packages/pip/_internal/models/link.pyrs  z Link.__init__cCsD|jrd|j}nd}|jr2dt|j|j|fStt|jSdS)Nz (requires-python:%s)z%s (from %s)%s)rrrrstr)rZrpr r r!__str__Es  z Link.__str__cCsd|S)Nz r rr r r!__repr__Psz Link.__repr__cCs|jSN)rr%r r r!rSszLink.urlcCs:|jd}t|}|s,t|j\}}|St|}|SN/)pathrstrip posixpathbasenamernetlocrunquote)rr*namer.Z user_passr r r!filenameXs   z Link.filenamecCs t|jSr')r rr%r r r! file_pathgszLink.file_pathcCs|jjSr')rschemer%r r r!r3lsz Link.schemecCs|jjS)z4 This can contain auth information. )rr.r%r r r!r.qsz Link.netloccCst|jjSr')rr/rr*r%r r r!r*ysz Link.pathcCstt|jdSr()rr,r-r*r+r%r r r!r~sz Link.splitextcCs |dSN)rr%r r r!extszLink.extcCs$|j\}}}}}t||||dfSr')rrZ urlunsplit)rr3r.r*ZqueryZfragmentr r r!url_without_fragmentszLink.url_without_fragmentz[#&]egg=([^&]*)cCs |j|j}|sdS|dSr4)_egg_fragment_researchrgrouprmatchr r r! egg_fragmentszLink.egg_fragmentz[#&]subdirectory=([^&]*)cCs |j|j}|sdS|dSr4)_subdirectory_fragment_rer9rr:r;r r r!subdirectory_fragmentszLink.subdirectory_fragmentz2(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)cCs |j|j}|r|dSdS)N_hash_rer9rr:r;r r r!hashs z Link.hashcCs |j|j}|r|dSdSr4rAr;r r r! hash_names zLink.hash_namecCs$t|jddddddS)N#r5r?)r,r-rsplitr%r r r!show_urlsz Link.show_urlcCs |jdkS)Nfile)r3r%r r r!is_filesz Link.is_filecCs|jotj|jSr')rJosr*isdirr2r%r r r!is_existing_dirszLink.is_existing_dircCs |jtkSr')r6rr%r r r!is_wheelsz Link.is_wheelcCsddlm}|j|jkS)Nr)vcs)Zpip._internal.vcsrOr3Z all_schemes)rrOr r r!is_vcss z Link.is_vcscCs |jdk Sr')rr%r r r! is_yankedszLink.is_yankedcCs |jdk Sr')rDr%r r r!has_hashsz Link.has_hashcCs$|dks|jsdS|j|j|jdS)zG Return True if the link has a hash and it is allowed. NF)Z hex_digest)rRis_hash_allowedrDrC)rZhashesr r r!rSszLink.is_hash_allowed)NNN)#__name__ __module__ __qualname____doc__rr$r&propertyrr1r2r3r.r*rr6r7recompiler8r=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