JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/pip/_internal/network/__pycache__/lazy_wheel.cpython-39.pyc

a

[��f��@s�dZddgZddlmZmZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZddlmZmZdd	lmZdd
lmZmZddlmZmZmZddlmZdd
lmZm Z m!Z!Gdd�de"�Z#e$e$eed�dd�Z%Gdd�d�Z&dS)zLazy ZIP over HTTP�HTTPRangeRequestUnsupported�dist_from_wheel_url�)�bisect_left�bisect_right)�contextmanager)�NamedTemporaryFile)�Any�Dict�Iterator�List�Optional�Tuple)�
BadZipfile�ZipFile)�canonicalize_name)�CONTENT_CHUNK_SIZE�Response)�BaseDistribution�MemoryWheel�get_wheel_distribution)�
PipSession)�HEADERS�raise_for_status�response_chunksc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�D/usr/lib/python3.9/site-packages/pip/_internal/network/lazy_wheel.pyrs)�name�url�session�returncCsHt||��*}t|j|�}t|t|��Wd�S1s:0YdS)aReturn a distribution object from the given wheel URL.

    This uses HTTP range requests to only fetch the potion of the wheel
    containing metadata, just enough for the object to be constructed.
    If such requests are not supported, HTTPRangeRequestUnsupported
    is raised.
    N)�LazyZipOverHTTPrrrr)rr r!�zfZwheelrrrrsc@szeZdZdZefeeedd�dd�Ze	ed�dd��Z
e	ed�d	d
��Zed�dd�Z
dd�d
d�Ze	ed�dd��Zd3eed�dd�Zed�dd�Zd4eeed�dd�Zed�dd�Zd5eeed�dd�Zed�dd �Zdd�d!d"�Zeeed#�d$d%�Zeedd�d&d'��Zdd�d(d)�Zefeee eefe!d*�d+d,�Z"eeeeee#eefd-�d.d/�Z$eedd0�d1d2�Z%dS)6r#aFile-like object mapped to a ZIP file over HTTP.

    This uses HTTP range requests to lazily fetch the file's content,
    which is supposed to be fed to ZipFile.  If such requests are not
    supported by the server, raise HTTPRangeRequestUnsupported
    during initialization.
    N)r r!�
chunk_sizer"cCs�|j|td�}t|�|jdks$J�||||_|_|_t|jd�|_	t
�|_|�|j	�g|_
g|_d|j�dd�vr�td��|��dS)N)�headers��zContent-Length�bytesz
Accept-RangesZnonezrange request is not supported)�headrrZstatus_code�_session�_url�_chunk_size�intr&�_lengthr�_file�truncate�_left�_right�getr�
_check_zip)�selfr r!r%r)rrr�__init__1szLazyZipOverHTTP.__init__)r"cCsdS)z!Opening mode, which is always rb.�rbr�r5rrr�modeAszLazyZipOverHTTP.modecCs|jjS)zPath to the underlying file.)r/rr8rrrrFszLazyZipOverHTTP.namecCsdS)z9Return whether random access is supported, which is True.Trr8rrr�seekableKszLazyZipOverHTTP.seekablecCs|j��dS)zClose the file.N)r/�closer8rrrr;OszLazyZipOverHTTP.closecCs|jjS)zWhether the file is closed.)r/�closedr8rrrr<SszLazyZipOverHTTP.closed���)�sizer"cCs`t||j�}|��|j}}|dkr(|nt|||�}td||�}|�||d�|j�|�S)z�Read up to size bytes from the object and return them.

        As a convenience, if size is unspecified or -1,
        all bytes until EOF are returned.  Fewer than
        size bytes may be returned if EOF is reached.
        r�)�maxr,�tellr.�min�	_downloadr/�read)r5r>Z
download_size�start�length�stoprrrrDXszLazyZipOverHTTP.readcCsdS)z3Return whether the file is readable, which is True.Trr8rrr�readablefszLazyZipOverHTTP.readabler)�offset�whencer"cCs|j�||�S)a-Change stream position and return the new absolute position.

        Seek to offset relative position indicated by whence:
        * 0: Start of stream (the default).  pos should be >= 0;
        * 1: Current position - pos may be negative;
        * 2: End of stream - pos usually negative.
        )r/�seek)r5rIrJrrrrKjszLazyZipOverHTTP.seekcCs
|j��S)zReturn the current position.)r/rAr8rrrrAtszLazyZipOverHTTP.tellcCs|j�|�S)z�Resize the stream to the given size in bytes.

        If size is unspecified resize to the current position.
        The current stream position isn't changed.

        Return the new file size.
        )r/r0)r5r>rrrr0xszLazyZipOverHTTP.truncatecCsdS)z
Return False.Frr8rrr�writable�szLazyZipOverHTTP.writablecCs|j��|S�N)r/�	__enter__r8rrrrN�s
zLazyZipOverHTTP.__enter__)�excr"cGs|jj|�SrM)r/�__exit__)r5rOrrrrP�szLazyZipOverHTTP.__exit__c	cs.|��}zdVW|�|�n|�|�0dS)zyReturn a context manager keeping the position.

        At the end of the block, seek back to original position.
        N)rArK)r5�posrrr�_stay�szLazyZipOverHTTP._stayc
Cs�|jd}ttd||j��D]h}|�||�|���@zt|�WntyTYn0Wd�q�Wd�q1sz0YqdS)z1Check and download until the file is a valid ZIP.r?rN)r.�reversed�ranger,rCrRrr)r5�endrErrrr4�s

zLazyZipOverHTTP._check_zip)rErU�base_headersr"cCs8|��}d|�d|��|d<d|d<|jj|j|dd�S)z:Return HTTP response to a range request from start to end.zbytes=�-ZRangezno-cachez
Cache-ControlT)r&�stream)�copyr*r3r+)r5rErUrVr&rrr�_stream_response�sz LazyZipOverHTTP._stream_response)rErU�left�rightr"c
cs�|j||�|j||�}}t|g|dd��}}t|g|dd��}t||�D]&\}}	||krv||dfV|	d}qX||kr�||fV|g|g|j||�<|j||�<dS)a/Return an iterator of intervals to be fetched.

        Args:
            start (int): Start of needed interval
            end (int): End of needed interval
            left (int): Index of first overlapping downloaded data
            right (int): Index after last overlapping downloaded data
        Nr?r=)r1r2rBr@�zip)
r5rErUr[r\ZlsliceZrslice�i�j�krrr�_merge�s

zLazyZipOverHTTP._merge)rErUr"cCs�|���~t|j|�}t|j|�}|�||||�D]D\}}|�||�}|��|�|�t	||j
�D]}|j�|�qdq2Wd�n1s�0YdS)z-Download bytes from start to end inclusively.N)
rRrr2rr1rarZrrKrr,r/�write)r5rErUr[r\Zresponse�chunkrrrrC�s

zLazyZipOverHTTP._download)r=)r)N)&rrr�__doc__r�strrr-r6�propertyr9r�boolr:r;r<r(rDrHrKrArr0rLrNrrPrr
rRr4rr	rrZr
rarCrrrrr#(sD	��

���r#N)'rd�__all__Zbisectrr�
contextlibrZtempfiler�typingrr	r
rrr
�zipfilerrZpip._vendor.packaging.utilsrZpip._vendor.requests.modelsrrZpip._internal.metadatarrrZpip._internal.network.sessionrZpip._internal.network.utilsrrr�	Exceptionrrerr#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