XylotrechusZ
U
��.e� � @ s� d dl Z d dlZd dlZd dlmZ d dlmZ d dlm Z m
Z
mZ d dlm
Z
d dlmZ d dlmZmZ er�d dlmZmZmZmZ d d lmZ d d
lmZ G dd� de
�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)�Hashesc s@ e Zd ZdZd6� fdd� Zdd� Zdd� Zed d
� �Zedd� �Z ed
d� �Z
edd� �Zedd� �Zedd� �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
Nc sV |� 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�urlr r r �� __class__� �=/usr/lib/python3.8/site-packages/pip/_internal/models/link.pyr s
z
Link.__init__c C sD | j rd| j }nd}| jr2dt| j�| j|f S tt| j��S d S )Nz (requires-python:%s)� z%s (from %s)%s)r r r r �str)r Zrpr r r! �__str__E s
�zLink.__str__c C s d| S )Nz <Link %s>r �r r r r! �__repr__P s z
Link.__repr__c C s | j S �N)r r% r r r! r S s zLink.urlc C sL | j �d�}t�|�}|s,t| j�\}}|S t�|�}|sHtd| j ��|S )N�/zURL %r produced no filename)
�path�rstrip� posixpath�basenamer �netlocr �unquote�AssertionErrorr )r r) �namer- Z user_passr r r! �filenameX s
z
Link.filenamec C s
t | j�S r'