1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
U
H=®dcã@südZddgZddlmZmZddlmZddlmZddl    m
Z
m Z ddl m Z dd    lmZdd
lmZmZmZdd lmZdd lmZerÐdd lmZmZmZmZmZmZddlm Z ddl m!Z!ddl"m#Z#Gdd„de$ƒZ%dd„Z&Gdd„de'ƒZ(dS)zLazy ZIP over HTTPÚHTTPRangeRequestUnsupportedÚdist_from_wheel_urlé)Ú bisect_leftÚ bisect_right)Úcontextmanager)ÚNamedTemporaryFile)Ú
BadZipfileÚZipFile)ÚCONTENT_CHUNK_SIZE)Úrange)ÚHEADERSÚraise_for_statusÚresponse_chunks)ÚMYPY_CHECK_RUNNING)Ú$pkg_resources_distribution_for_wheel)ÚAnyÚDictÚIteratorÚListÚOptionalÚTuple)Ú Distribution)ÚResponse)Ú
PipSessionc@s eZdZdS)rN)Ú__name__Ú
__module__Ú __qualname__©rrúWD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/network/lazy_wheel.pyrsc
Cs8t||ƒ$}t|ƒ}t|||jƒW5QR£SQRXdS)a%Return a pkg_resources.Distribution 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)ÚLazyZipOverHTTPr    rÚname)r ÚurlÚsessionÚwheelÚzip_filerrrr"s     c@sÆeZdZdZefdd„Zedd„ƒZedd„ƒZdd    „Z    d
d „Z
ed d „ƒZ d+dd„Z dd„Z d,dd„Zdd„Zd-dd„Zdd„Zdd„Zdd „Zed!d"„ƒZd#d$„Zefd%d&„Zd'd(„Zd)d*„ZdS).raFile-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.
    cCs|j|td}t|ƒ|jdks$t‚||||_|_|_t|j    dƒ|_
t ƒ|_ |  |j
¡g|_g|_d|j     dd¡kr„tdƒ‚| ¡dS)N)ÚheaderséÈzContent-LengthÚbytesz Accept-RangesÚnonezrange request is not supported)Úheadr r Ú status_codeÚAssertionErrorÚ_sessionÚ_urlÚ _chunk_sizeÚintr%Ú_lengthrÚ_fileÚtruncateÚ_leftÚ_rightÚgetrÚ
_check_zip)Úselfr!r"Ú
chunk_sizer)rrrÚ__init__=s zLazyZipOverHTTP.__init__cCsdS)z!Opening mode, which is always rb.Úrbr©r7rrrÚmodeLszLazyZipOverHTTP.modecCs|jjS)zPath to the underlying file.)r1r r;rrrr RszLazyZipOverHTTP.namecCsdS)z9Return whether random access is supported, which is True.Trr;rrrÚseekableXszLazyZipOverHTTP.seekablecCs|j ¡dS)zClose the file.N)r1Úcloser;rrrr>]szLazyZipOverHTTP.closecCs|jjS)zWhether the file is closed.)r1Úclosedr;rrrr?bszLazyZipOverHTTP.closedéÿÿÿÿcCs`t||jƒ}| ¡|j}}|dkr(|n t|||ƒ}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.Útellr0ÚminÚ    _downloadr1Úread)r7ÚsizeZ download_sizeÚstartÚlengthÚstoprrrrFhs  zLazyZipOverHTTP.readcCsdS)z3Return whether the file is readable, which is True.Trr;rrrÚreadablewszLazyZipOverHTTP.readablercCs|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.
        )r1Úseek)r7ÚoffsetÚwhencerrrrL|s    zLazyZipOverHTTP.seekcCs
|j ¡S)zReturn the current possition.)r1rCr;rrrrC‡szLazyZipOverHTTP.tellNcCs |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.
        )r1r2)r7rGrrrr2Œs    zLazyZipOverHTTP.truncatecCsdS)z Return False.Frr;rrrÚwritable—szLazyZipOverHTTP.writablecCs|j ¡|S©N)r1Ú    __enter__r;rrrrQœs
zLazyZipOverHTTP.__enter__cGs |jj|ŽSrP)r1Ú__exit__)r7ÚexcrrrrR¡szLazyZipOverHTTP.__exit__c    cs$| ¡}z
dVW5| |¡XdS)zyReturn a context manager keeping the position.
 
        At the end of the block, seek back to original position.
        N)rCrL)r7ÚposrrrÚ_stay¥s
zLazyZipOverHTTP._stayc
Csv|jd}ttd||jƒƒD]T}| ||¡| ¡6z t|ƒWntk
rVYnXW5QR£qrW5QRXqdS)z1Check and download until the file is a valid ZIP.rArN)r0Úreversedr r.rErUr    r)r7ÚendrHrrrr6²s
 
 zLazyZipOverHTTP._check_zipcCs.dd ||¡i}| |¡|jj|j|ddS)z:Return HTTP response to a range request from start to end.ZRangez bytes={}-{}T)r%Ústream)ÚformatÚupdater,r5r-)r7rHrWZ base_headersr%rrrÚ_stream_responseÂs
z LazyZipOverHTTP._stream_responsec
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
        NrAr@)r3r4rDrBÚzip)
r7rHrWÚleftÚrightZlsliceZrsliceÚiÚjÚkrrrÚ_mergeÉs
 
 
zLazyZipOverHTTP._mergec    Cs†| ¡tt|j|ƒ}t|j|ƒ}| ||||¡D]D\}}| ||¡}| ¡| |¡t    ||j
ƒD]}|j   |¡qdq2W5QRXdS)z-Download bytes from start to end inclusively.N) rUrr4rr3rbr[r rLrr.r1Úwrite)r7rHrWr]r^ÚresponseÚchunkrrrrEÞs
 
zLazyZipOverHTTP._download)r@)r)N)rrrÚ__doc__r
r9Úpropertyr<r r=r>r?rFrKrLrCr2rOrQrRrrUr6r r[rbrErrrrr4s0 
 
 
 
 
 
 
 rN))rfÚ__all__ÚbisectrrÚ
contextlibrÚtempfilerÚzipfilerr    Zpip._vendor.requests.modelsr
Úpip._vendor.six.movesr Úpip._internal.network.utilsr r rÚpip._internal.utils.typingrÚpip._internal.utils.wheelrÚtypingrrrrrrZpip._vendor.pkg_resourcesrrÚpip._internal.network.sessionrÚ    ExceptionrrÚobjectrrrrrÚ<module>s$