U
    +|j0  ã                   @   s¬   d dl Z d dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
mZ d dlmZ d dlmZmZmZ d dlmZ d dlmZmZ er�d dlmZ G d	d
„ d
eƒZdd„ ZdS )é    N)ÚTYPE_CHECKINGÚOptionalÚTupleÚUnion)ÚWHEEL_EXTENSION)ÚHashes)Úredact_auth_from_urlÚsplit_auth_from_netlocÚsplitext)ÚKeyBasedCompareMixin)Úpath_to_urlÚurl_to_path)ÚHTMLPagec                       sP  e Zd ZdZddddddgZd=‡ fd
d„	Zdd„ Zdd„ Zedd„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zedd„ ƒZed d!„ ƒZe d"¡Zed#d$„ ƒZe d%¡Zed&d'„ ƒZe d(¡Zed)d*„ ƒZed+d,„ ƒZed-d.„ ƒZed/d0„ ƒZd1d2„ Zed3d4„ ƒZed5d6„ ƒZed7d8„ ƒZ ed9d:„ ƒZ!d;d<„ Z"‡  Z#S )>ÚLinkz?Represents a parsed link from a Package Index's simple URL
    Ú_parsed_urlÚ_urlÚ
comes_fromÚrequires_pythonÚyanked_reasonÚcache_link_parsingNTc                    sZ   |  d¡rt|ƒ}tj |¡| _|| _|| _|r4|nd| _|| _	t
ƒ j|td� || _dS )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)ÚkeyÚdefining_class)Ú
startswithr   ÚurllibÚparseÚurlsplitr   r   r   r   r   ÚsuperÚ__init__r   r   )ÚselfÚurlr   r   r   r   ©Ú	__class__© úaC:\Users\snmko\Desktop\web_content\django_cbt\venv\Lib\site-packages\pip/_internal/models/link.pyr   "   s    
zLink.__init__c                 C   sH   | j rd| j › d�}nd}| jr6d t| jƒ| j|¡S tt| jƒƒS d S )Nz (requires-python:ú)Ú z{} (from {}){})r   r   Úformatr   r   Ústr)r   Úrpr"   r"   r#   Ú__str__Q   s      ÿzLink.__str__c                 C   s   d| › d�S )Nz<Link ú>r"   ©r   r"   r"   r#   Ú__repr__]   s    zLink.__repr__c                 C   s   | j S ©N)r   r+   r"   r"   r#   r   a   s    zLink.urlc                 C   sR   | j  d¡}t |¡}|s,t| jƒ\}}|S tj |¡}|sNt	d| j
›d�ƒ‚|S )Nú/zURL z produced no filename)ÚpathÚrstripÚ	posixpathÚbasenamer	   Únetlocr   r   ÚunquoteÚAssertionErrorr   )r   r/   Únamer3   Ú	user_passr"   r"   r#   Úfilenamef   s    
zLink.filenamec                 C   s
   t | jƒS r-   )r   r   r+   r"   r"   r#   Ú	file_pathu   s    zLink.file_pathc                 C   s   | j jS r-   )r   Úschemer+   r"   r"   r#   r:   z   s    zLink.schemec                 C   s   | j jS )z4
        This can contain auth information.
        )r   r3   r+   r"   r"   r#   r3      s    zLink.netlocc                 C   s   t j | jj¡S r-   )r   r   r4   r   r/   r+   r"   r"   r#   r/   ‡   s    z	Link.pathc                 C   s   t t | j d¡¡ƒS )Nr.   )r
   r1   r2   r/   r0   r+   r"   r"   r#   r
   Œ   s    zLink.splitextc                 C   s   |   ¡ d S ©Né   )r
   r+   r"   r"   r#   Úext�   s    zLink.extc                 C   s&   | j \}}}}}tj ||||d f¡S r-   )r   r   r   Ú
urlunsplit)r   r:   r3   r/   ÚqueryÚfragmentr"   r"   r#   Úurl_without_fragment•   s    zLink.url_without_fragmentz[#&]egg=([^&]*)c                 C   s    | j  | j¡}|sd S | d¡S r;   )Ú_egg_fragment_reÚsearchr   Úgroup©r   Úmatchr"   r"   r#   Úegg_fragment�   s    zLink.egg_fragmentz[#&]subdirectory=([^&]*)c                 C   s    | j  | j¡}|sd S | d¡S r;   )Ú_subdirectory_fragment_rerC   r   rD   rE   r"   r"   r#   Úsubdirectory_fragment§   s    zLink.subdirectory_fragmentz2(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)c                 C   s    | j  | j¡}|r| d¡S d S )Né   ©Ú_hash_rerC   r   rD   rE   r"   r"   r#   Úhash³   s    
z	Link.hashc                 C   s    | j  | j¡}|r| d¡S d S r;   rK   rE   r"   r"   r#   Ú	hash_name»   s    
zLink.hash_namec                 C   s$   t  | j dd¡d  dd¡d ¡S )Nú#r<   r   ú?)r1   r2   r   Úsplitr+   r"   r"   r#   Úshow_urlÃ   s    zLink.show_urlc                 C   s
   | j dkS )NÚfile)r:   r+   r"   r"   r#   Úis_fileÈ   s    zLink.is_filec                 C   s   | j otj | j¡S r-   )rT   Úosr/   Úisdirr9   r+   r"   r"   r#   Úis_existing_dirÍ   s    zLink.is_existing_dirc                 C   s
   | j tkS r-   )r=   r   r+   r"   r"   r#   Úis_wheelÑ   s    zLink.is_wheelc                 C   s   ddl m} | j|jkS )Nr   )Úvcs)Úpip._internal.vcsrY   r:   Úall_schemes)r   rY   r"   r"   r#   Úis_vcsÖ   s    zLink.is_vcsc                 C   s
   | j d k	S r-   )r   r+   r"   r"   r#   Ú	is_yankedÝ   s    zLink.is_yankedc                 C   s
   | j d k	S r-   )rN   r+   r"   r"   r#   Úhas_hashâ   s    zLink.has_hashc                 C   s@   |dks| j sdS | jdk	s t‚| jdk	s.t‚|j| j| jd�S )zG
        Return True if the link has a hash and it is allowed.
        NF)Ú
hex_digest)r^   rN   r5   rM   Úis_hash_allowed)r   Úhashesr"   r"   r#   r`   ç   s
    zLink.is_hash_allowed)NNNT)$Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r)   r,   Úpropertyr   r8   r9   r:   r3   r/   r
   r=   rA   ÚreÚcompilerB   rG   rH   rI   rL   rM   rN   rR   rT   rW   rX   r\   r]   r^   r`   Ú__classcell__r"   r"   r    r#   r      sv   ú    ú/











ÿ







r   c                 C   s   | |kS r-   r"   )Úlink1Úlink2r"   r"   r#   Úlinks_equivalentö   s    rm   )rU   r1   rh   Úurllib.parser   Útypingr   r   r   r   Úpip._internal.utils.filetypesr   Úpip._internal.utils.hashesr   Úpip._internal.utils.miscr   r	   r
   Úpip._internal.utils.modelsr   Úpip._internal.utils.urlsr   r   Úpip._internal.index.collectorr   r   rm   r"   r"   r"   r#   Ú<module>   s    b