HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_internal/models/__pycache__/link.cpython-310.pyc
o

@%NeY&�@sddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZddlmZmZmZddlmZddlmZmZerVddlmZe�e�Z d	Z!Gd
d�de�Z"Gdd
�d
e�Z#de"de#fdd�Z$ej%dd�de"de"de&fdd��Z'dS)�N)�
TYPE_CHECKING�Dict�List�
NamedTuple�Optional�Tuple�Union)�WHEEL_EXTENSION)�Hashes)�redact_auth_from_url�split_auth_from_netloc�splitext)�KeyBasedCompareMixin)�path_to_url�url_to_path)�HTMLPage)�sha1�sha224�sha384�sha256�sha512�md5c
s6eZdZdZgd�Z				dBdedeeedfdeed	eed
eddf�fdd
�
Z	defdd�Z
defdd�Zedefdd��Z
edefdd��Zedefdd��Zedefdd��Zedefdd��Zedefdd��Zdeeeffdd�Zedefd d!��Zedefd"d#��Ze�d$�Zedeefd%d&��Ze�d'�Zedeefd(d)��Ze�d*jd+�e�d,��Z edeefd-d.��Z!edeefd/d0��Z"edefd1d2��Z#edefd3d4��Z$defd5d6�Z%edefd7d8��Z&edefd9d:��Z'edefd;d<��Z(edefd=d>��Z)d?ee*defd@dA�Z+�Z,S)C�Linkz:Represents a parsed link from a Package Index's simple URL)�_parsed_url�_url�
comes_from�requires_python�
yanked_reason�cache_link_parsingNT�urlrrrrr�returncsZ|�d�r	t|�}tj�|�|_||_||_|r|nd|_||_	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.
        :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�urlsplitrrrrr�super�__init__rr)�selfrrrrr��	__class__��;/usr/lib/python3/dist-packages/pip/_internal/models/link.pyr((s

z
Link.__init__cCsD|jrd|j�d�}nd}|jrd�t|j�|j|�Stt|j��S)Nz (requires-python:�)�z{} (from {}){})rr�formatrr�str)r)�rpr,r,r-�__str__Vs�zLink.__str__cCsd|�d�S)Nz<Link �>r,�r)r,r,r-�__repr__bsz
Link.__repr__cCs|jS�N)rr5r,r,r-reszLink.urlcCsR|j�d�}t�|�}|st|j�\}}|Stj�|�}|s'Jd|j	�d���|S)N�/zURL z produced no filename)
�path�rstrip�	posixpath�basenamer�netlocr$r%�unquoter)r)r9�namer=�	user_passr,r,r-�filenameis
z
Link.filenamecCs
t|j�Sr7)rrr5r,r,r-�	file_pathw�
zLink.file_pathcC�|jjSr7)r�schemer5r,r,r-rE{szLink.schemecCrD)z4
        This can contain auth information.
        )rr=r5r,r,r-r=szLink.netloccCstj�|jj�Sr7)r$r%r>rr9r5r,r,r-r9��z	Link.pathcCstt�|j�d���S)Nr8)r
r;r<r9r:r5r,r,r-r
�sz
Link.splitextcCs|��dS�N�)r
r5r,r,r-�ext�szLink.extcCs&|j\}}}}}tj�||||df�S)Nr/)rr$r%�
urlunsplit)r)rEr=r9�query�fragmentr,r,r-�url_without_fragment�szLink.url_without_fragmentz[#&]egg=([^&]*)cC� |j�|j�}|sdS|�d�SrG)�_egg_fragment_re�searchr�group�r)�matchr,r,r-�egg_fragment��
zLink.egg_fragmentz[#&]subdirectory=([^&]*)cCrNrG)�_subdirectory_fragment_rerPrrQrRr,r,r-�subdirectory_fragment�rUzLink.subdirectory_fragmentz({choices})=([a-f0-9]+)�|)�choicescC� |j�|j�}|r|�d�SdS)N���_hash_rerPrrQrRr,r,r-�hash��
z	Link.hashcCrZrGr\rRr,r,r-�	hash_name�r_zLink.hash_namecCs$t�|j�dd�d�dd�d�S)N�#rHr�?)r;r<r�splitr5r,r,r-�show_url�s$z
Link.show_urlcCs
|jdkS)N�file)rEr5r,r,r-�is_file�rCzLink.is_filecCs|jo	tj�|j�Sr7)rf�osr9�isdirrBr5r,r,r-�is_existing_dir�szLink.is_existing_dircCs
|jtkSr7)rIr	r5r,r,r-�is_wheel�rCz
Link.is_wheelcCsddlm}|j|jvS)Nr)�vcs)�pip._internal.vcsrkrE�all_schemes)r)rkr,r,r-�is_vcs�szLink.is_vcscC�
|jduSr7)rr5r,r,r-�	is_yanked�rCzLink.is_yankedcCror7)r`r5r,r,r-�has_hash�rCz
Link.has_hash�hashescCs@|dus|js	dS|jdusJ�|jdusJ�|j|j|jd�S)zG
        Return True if the link has a hash and it is allowed.
        NF)�
hex_digest)rqr`r^�is_hash_allowed)r)rrr,r,r-rt�s
zLink.is_hash_allowed)NNNT)-�__name__�
__module__�__qualname__�__doc__�	__slots__r1rr�boolr(r3r6�propertyrrArBrEr=r9rr
rIrM�re�compilerOrTrVrWr0�join�_SUPPORTED_HASHESr]r^r`rdrfrirjrnrprqr
rt�
__classcell__r,r,r*r-rs��������.


�rc@sJeZdZUdZejjed<ee	e
e	fed<e	ed<ee	e	fed<dS)�_CleanResulta�Convert link for equivalency check.

    This is used in the resolver to check whether two URL-specified requirements
    likely point to the same distribution and can be considered equivalent. This
    equivalency logic avoids comparing URLs literally, which can be too strict
    (e.g. "a=1&b=2" vs "b=2&a=1") and produce conflicts unexpecting to users.

    Currently this does three things:

    1. Drop the basic auth part. This is technically wrong since a server can
       serve different content based on auth, but if it does that, it is even
       impossible to guarantee two URLs without auth are equivalent, since
       the user can input different auth information when prompted. So the
       practical solution is to assume the auth doesn't affect the response.
    2. Parse the query to avoid the ordering issue. Note that ordering under the
       same key in the query are NOT cleaned; i.e. "a=1&a=2" and "a=2&a=1" are
       still considered different.
    3. Explicitly drop most of the fragment part, except ``subdirectory=`` and
       hash values, since it should have no impact the downloaded content. Note
       that this drops the "egg=" part historically used to denote the requested
       project (and extras), which is wrong in the strictest sense, but too many
       people are supplying it inconsistently to cause superfluous resolution
       conflicts, so we choose to also ignore them.
    �parsedrK�subdirectoryrrN)rurvrwrxr$r%�SplitResult�__annotations__rr1rr,r,r,r-r��s
r��linkr c	s�|j}|j�dd�d}|jdkr|sd}tj�|j��d�vr&t�	d|�z�dd	}Wn
t
tfy;d
}Ynw�fdd�tD�}t
|j|d
d
d
�tj�|j�||d�S)N�@rH���re�	localhost�eggzIgnoring egg= fragment in %sr�rr/cs"i|]
}|�vr|�|d�qS)rr,)�.0�k�rLr,r-�
<dictcomp>s"z_clean_link.<locals>.<dictcomp>)r=rKrL)r�rKr�rr)rr=�rsplitrEr$r%�parse_qsrL�logger�debug�
IndexError�KeyErrorrr��_replacerK)r�r�r=r�rrr,r�r-�_clean_links&��r�)�maxsize�link1�link2cCst|�t|�kSr7)r�)r�r�r,r,r-�links_equivalentrFr�)(�	functools�loggingrgr;r|�urllib.parser$�typingrrrrrrr�pip._internal.utils.filetypesr	�pip._internal.utils.hashesr
�pip._internal.utils.miscrrr
�pip._internal.utils.modelsr�pip._internal.utils.urlsrr�pip._internal.index.collectorr�	getLoggerrur�rrr�r��	lru_cacherzr�r,r,r,r-�<module>s,$
I