U n a@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@eZdZdZd7fdd ZddZdd Zed d Zed d Z eddZ eddZ eddZ eddZ ddZeddZeddZedZeddZedZed d!Zed"Zed#d$Zed%d&Zed'd(Zed)d*Zd+d,Zed-d.Zed/d0Zed1d2Zed3d4Z d5d6Z!Z"S)8Linkz?Represents a parsed link from a Package Index's simple URL NTcs\|drt|}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. :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) startswithr urllib_parseurlsplit _parsed_url_url comes_fromrequires_python yanked_reasonsuperr__init__cache_link_parsing)selfurlrrrr __class__ZC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\models\link.pyrs  z Link.__init__cCsF|jrd|j}nd}|jr4dt|j|j|Stt|jSdS)Nz (requires-python:{})z{} (from {}){})rformatrrrstr)rrpr#r#r$__str__Jsz Link.__str__cCs d|S)Nz )r&rr#r#r$__repr__Vsz Link.__repr__cCs|jSN)rr*r#r#r$r ZszLink.urlcCsP|jd}t|}|s,t|j\}}|St|}|sLtdj ft |S)N/z&URL {self._url!r} produced no filename) pathrstrip posixpathbasenamernetlocrunquoteAssertionErrorr&locals)rr.namer2 user_passr#r#r$filename_s    z Link.filenamecCs t|jSr,)r r r*r#r#r$ file_pathoszLink.file_pathcCs|jjSr,)rschemer*r#r#r$r:tsz Link.schemecCs|jjS)z4 This can contain auth information. )rr2r*r#r#r$r2ysz Link.netloccCst|jjSr,)rr3rr.r*r#r#r$r.sz Link.pathcCstt|jdS)Nr-)rr0r1r.r/r*r#r#r$rsz Link.splitextcCs |dSN)rr*r#r#r$extszLink.extcCs$|j\}}}}}t||||dfSr,)rr urlunsplit)rr:r2r.queryfragmentr#r#r$url_without_fragmentszLink.url_without_fragmentz[#&]egg=([^&]*)cCs |j|j}|sdS|dSr;)_egg_fragment_researchrgrouprmatchr#r#r$ egg_fragmentszLink.egg_fragmentz[#&]subdirectory=([^&]*)cCs |j|j}|sdS|dSr;)_subdirectory_fragment_rerCrrDrEr#r#r$subdirectory_fragmentszLink.subdirectory_fragmentz2(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)cCs |j|j}|r|dSdS)N_hash_rerCrrDrEr#r#r$hashs z Link.hashcCs |j|j}|r|dSdSr;rKrEr#r#r$ hash_names zLink.hash_namecCs$t|jddddddS)N#r<r?)r0r1rsplitr*r#r#r$show_urlsz Link.show_urlcCs |jdkS)Nfile)r:r*r#r#r$is_filesz Link.is_filecCs|jotj|jSr,)rTosr.isdirr9r*r#r#r$is_existing_dirszLink.is_existing_dircCs |jtkSr,)r=rr*r#r#r$is_wheelsz Link.is_wheelcCsddlm}|j|jkS)Nr)vcs)pip._internal.vcsrYr: all_schemes)rrYr#r#r$is_vcss z Link.is_vcscCs |jdk Sr,)rr*r#r#r$ is_yankedszLink.is_yankedcCs |jdk Sr,)rNr*r#r#r$has_hashsz Link.has_hashcCs@|dks|jsdS|jdk s t|jdk s.t|j|j|jdS)zG Return True if the link has a hash and it is allowed. NF) hex_digest)r^rNr4rMis_hash_allowed)rhashesr#r#r$r`s zLink.is_hash_allowed)NNNT)#__name__ __module__ __qualname____doc__rr)r+propertyr r8r9r:r2r.rr=rArecompilerBrGrHrIrLrMrNrRrTrWrXr\r]r^r` __classcell__r#r#r!r$rsh/                     r)rUr0rgZpip._vendor.six.moves.urllibrrpip._internal.utils.filetypesrpip._internal.utils.miscrrrpip._internal.utils.modelsrpip._internal.utils.typingrpip._internal.utils.urlsr r typingr r r rpip._internal.index.collectorrpip._internal.utils.hashesrrr#r#r#r$s