a
    ˆÀàg/  ã                   @   s´   d dl Z d dlZd dl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 d dlmZmZ er d dlmZmZmZmZ d d	lmZ d d
lmZ G dd„ deƒZdS )é    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)ÚHashesc                       sH  e Zd ZdZg d¢Zd8‡ 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*d+„ ƒZd,d-„ Zed.d/„ ƒZed0d1„ ƒZed2d3„ ƒZ ed4d5„ ƒZ!d6d7„ Z"‡  Z#S )9ÚLinkz?Represents a parsed link from a Package Index's simple URL
    )Ú_parsed_urlÚ_urlÚ
comes_fromÚrequires_pythonÚyanked_reasonÚcache_link_parsingNTc                    s\   |  d¡rt|ƒ}t |¡| _|| _|| _|r2|nd| _|| _t	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   Úsuperr   Ú__init__r   )ÚselfÚurlr   r   r   r   ©Ú	__class__© úR/var/www/sistema_ama/venv/lib/python3.9/site-packages/pip/_internal/models/link.pyr   %   s    
zLink.__init__c                 C   sF   | j rd | j ¡}nd}| jr4d t| jƒ| j|¡S tt| jƒƒS d S )Nz (requires-python:{})Ú z{} (from {}){})r   Úformatr   r   r   Ústr)r   Úrpr#   r#   r$   Ú__str__T   s    ÿzLink.__str__c                 C   s
   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    d   s    zLink.urlc                 C   sT   | j  d¡}t |¡}|s,t| jƒ\}}|S t |¡}|sPJ djf i t	ƒ ¤Žƒ‚|S )Nú/z&URL {self._url!r} produced no filename)
ÚpathÚrstripÚ	posixpathÚbasenamer   Únetlocr   Úunquoter&   Úlocals)r   r.   Únamer2   Ú	user_passr#   r#   r$   Úfilenamei   s    

ÿzLink.filenamec                 C   s
   t | jƒS r,   )r
   r    r*   r#   r#   r$   Ú	file_pathy   s    zLink.file_pathc                 C   s   | j jS r,   )r   Úschemer*   r#   r#   r$   r9   ~   s    zLink.schemec                 C   s   | j jS )z4
        This can contain auth information.
        )r   r2   r*   r#   r#   r$   r2   ƒ   s    zLink.netlocc                 C   s   t  | jj¡S r,   )r   r3   r   r.   r*   r#   r#   r$   r.   ‹   s    z	Link.pathc                 C   s   t t | j d¡¡ƒS )Nr-   )r   r0   r1   r.   r/   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 ||||d f¡S r,   )r   r   Ú
urlunsplit)r   r9   r2   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_rerB   r   rC   rD   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_rerB   r   rC   rD   r#   r#   r$   Úhash·   s    
z	Link.hashc                 C   s    | j  | j¡}|r| d¡S d S r:   rJ   rD   r#   r#   r$   Ú	hash_name¿   s    
zLink.hash_namec                 C   s$   t  | j dd¡d  dd¡d ¡S )Nú#r;   r   ú?)r0   r1   r   Úsplitr*   r#   r#   r$   Úshow_urlÇ   s    zLink.show_urlc                 C   s
   | j dkS )NÚfile)r9   r*   r#   r#   r$   Úis_fileÌ   s    zLink.is_filec                 C   s   | j otj | j¡S r,   )rS   Úosr.   Úisdirr8   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v S )Nr   )Úvcs)Zpip._internal.vcsrX   r9   Zall_schemes)r   rX   r#   r#   r$   Úis_vcsÚ   s    zLink.is_vcsc                 C   s
   | j d uS r,   )r   r*   r#   r#   r$   Ú	is_yankedá   s    zLink.is_yankedc                 C   s
   | j d uS r,   )rM   r*   r#   r#   r$   Úhas_hashæ   s    zLink.has_hashc                 C   s@   |du s| j sdS | jdus J ‚| jdus.J ‚|j| j| jd�S )zG
        Return True if the link has a hash and it is allowed.
        NF)Ú
hex_digest)r[   rM   rL   Úis_hash_allowed)r   Úhashesr#   r#   r$   r]   ë   s
    zLink.is_hash_allowed)NNNT)$Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r)   r+   Úpropertyr    r7   r8   r9   r2   r.   r   r<   r@   ÚreÚcompilerA   rF   rG   rH   rK   rL   rM   rQ   rS   rV   rW   rY   rZ   r[   r]   Ú__classcell__r#   r#   r!   r$   r      sj       ú/











ÿ







r   )rT   r0   re   Zpip._vendor.six.moves.urllibr   r   Zpip._internal.utils.filetypesr   Úpip._internal.utils.miscr   r   r   Zpip._internal.utils.modelsr   Úpip._internal.utils.typingr   Úpip._internal.utils.urlsr	   r
   Útypingr   r   r   r   Zpip._internal.index.collectorr   Úpip._internal.utils.hashesr   r   r#   r#   r#   r$   Ú<module>   s   