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.urlcCs:|j�d�}t�|�}|s,t|j�\}}|St�|�}|S�N�/)�path�rstrip� posixpath�basenamer�netlocr�unquote)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���Sr()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|j|j|jd�S)zG Return True if the link has a hash and it is allowed. NF)Z hex_digest)rR�is_hash_allowedrDrC)rZhashesr r r!rS�szLink.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