3 (\@sddlZddlZddlmZddlmZddlmZm Z m Z ddl m Z ddl mZerxddlmZmZmZddlmZGd d d e ZdS) N)parse) path_to_url)WHEEL_EXTENSIONredact_password_from_urlsplitext)KeyBasedCompareMixin)MYPY_CHECK_RUNNING)OptionalTupleUnion)HTMLPagecseZdZdZd(fdd ZddZddZed d Zed d Z ed dZ eddZ ddZ eddZ eddZejdZeddZejdZeddZejdZeddZed d!Zed"d#Zed$d%Zed&d'ZZS))Linkz?Represents a parsed link from a Package Index's simple URL NcsF|jdrt|}||_||_|r&|nd|_tt|j|jtddS)a url: url of the resource pointed to (href of the link) comes_from: instance of HTMLPage where the link was found, or string. 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. z\\N)keyZdefining_class) startswithrurl comes_fromrequires_pythonsuperr __init__)selfrrr) __class__l/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-k1a8l1r5/pip/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)rrprrr__str__0s   z Link.__str__cCsd|S)Nz r)rrrr__repr__;sz Link.__repr__cCsJtj|j\}}}}}tj|jdp(|}tj|}|sFtd|j|S)N/zURL %r produced no filename) urllib_parseurlsplitr posixpathbasenamerstripunquoteAssertionError)r_netlocpathnamerrrfilename>s  z Link.filenamecCstj|jdS)Nr)rr r)rrrrschemeGsz Link.schemecCstj|jdS)N)rr r)rrrrr'Lsz Link.netloccCstjtj|jdS)N)rr$r r)rrrrr(Qsz Link.pathcCsttj|jjdS)Nr)rr!r"r(r#)rrrrrVsz Link.splitextcCs |jdS)Nr,)r)rrrrextZszLink.extcCs*tj|j\}}}}}tj||||dfS)N)rr r urlunsplit)rr+r'r(queryfragmentrrrurl_without_fragment_szLink.url_without_fragmentz[#&]egg=([^&]*)cCs |jj|j}|sdS|jdS)Nr,)_egg_fragment_researchrgroup)rmatchrrr egg_fragmentgszLink.egg_fragmentz[#&]subdirectory=([^&]*)cCs |jj|j}|sdS|jdS)Nr,)_subdirectory_fragment_rer4rr5)rr6rrrsubdirectory_fragmentqszLink.subdirectory_fragmentz2(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)cCs |jj|j}|r|jdSdS)Nr-)_hash_rer4rr5)rr6rrrhash}s z Link.hashcCs |jj|j}|r|jdSdS)Nr,)r:r4rr5)rr6rrr hash_names zLink.hash_namecCs$tj|jjdddjdddS)N#r,r?)r!r"rsplit)rrrrshow_urlsz Link.show_urlcCs |jtkS)N)r.r)rrrris_wheelsz Link.is_wheelcCs ddlm}|j|jkrdSdS)z Determines if this points to an actual artifact (e.g. a tarball) or if it points to an "abstract" thing like a path or a VCS location. r)vcsFT)Zpip._internal.vcsrBr+ all_schemes)rrBrrr is_artifacts  zLink.is_artifact)NN)__name__ __module__ __qualname____doc__rrrpropertyr*r+r'r(rr.r2recompiler3r7r8r9r:r;r<r@rArD __classcell__rr)rrr s,              r )r!rJZpip._vendor.six.moves.urllibrrZpip._internal.downloadrZpip._internal.utils.miscrrrZpip._internal.utils.modelsrZpip._internal.utils.typingrZtypingr r r Zpip._internal.indexr r rrrrs