VULN_CHECK_I913V6 jdZddgZddlmZmZddlmZddlmZddl m Z m Z m Z m Z mZmZddlmZmZdd lmZdd lmZmZdd lmZmZmZdd lmZdd lmZm Z m!Z!Gdde"Z#de$de$dedefdZ%GddZ&y)zLazy ZIP over HTTPHTTPRangeRequestUnsupporteddist_from_wheel_url) bisect_left bisect_right)contextmanager)NamedTemporaryFile)AnyDict GeneratorListOptionalTuple) BadZipFileZipFile)canonicalize_name)CONTENT_CHUNK_SIZEResponse)BaseDistribution MemoryWheelget_wheel_distribution) PipSession)HEADERSraise_for_statusresponse_chunksc eZdZy)rN)__name__ __module__ __qualname__E/usr/lib/python3.12/site-packages/pip/_internal/network/lazy_wheel.pyrrsr nameurlsessionreturnct||5}t|j|}t|t |cdddS#1swYyxYw)aReturn a distribution object from the given wheel URL. This uses HTTP range requests to only fetch the portion of the wheel containing metadata, just enough for the object to be constructed. If such requests are not supported, HTTPRangeRequestUnsupported is raised. N)LazyZipOverHTTPrr"rr)r"r#r$zfwheels r!rrs@ g &"BGGR(&e->t-DE ' & &s +AA c eZdZdZefdedededdfdZe defdZ e defd Z de fd Z d$d Ze de fd Zd%d edefdZde fdZd&dededefdZdefdZd'd eedefdZde fdZd(dZdeddfdZededfdZd$dZefdedede eefde!fdZ"deded ed!edee#eefddff d"Z$dededdfd#Z%y))r'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. r#r$ chunk_sizer%Nc|j|t}t||||c|_|_|_t |jd|_t|_ |j|jg|_ g|_ d|jjddvr td|j!y)N)headerszContent-Lengthbytesz Accept-Rangesnonezrange request is not supported)headrr_session_url _chunk_sizeintr-_lengthr_filetruncate_left_rightgetr _check_zip)selfr#r$r+r0s r!__init__zLazyZipOverHTTP.__init__1s||C|15= 0; * 1: Current position - pos may be negative; * 2: End of stream - pos usually negative. )r6seek)r<rXrYs r!r[zLazyZipOverHTTP.seekjszzvv..r c6|jjS)zReturn the current position.)r6rNr@s r!rNzLazyZipOverHTTP.telltszz  r c8|jj|S)zResize 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. )r6r7)r<rJs r!r7zLazyZipOverHTTP.truncatexszz""4((r cy)z Return False.Frr@s r!writablezLazyZipOverHTTP.writablesr c:|jj|SN)r6 __enter__r@s r!rbzLazyZipOverHTTP.__enter__s  r excc6|jj|yra)r6__exit__)r<rcs r!rezLazyZipOverHTTP.__exit__s S!r )NNNc#K|j} d|j|y#|j|wxYww)zyReturn a context manager keeping the position. At the end of the block, seek back to original position. N)rNr[)r<poss r!_stayzLazyZipOverHTTP._stays1 iik   IIcNDIIcNsA*A=Ac(|jdz }ttd||jD];}|j |||j 5 t | dddyy#t$rYnwxYw dddX#1swYaxYw)z1Check and download until the file is a valid ZIP.rLrN)r5reversedranger3rPrhrr)r<endrSs r!r;zLazyZipOverHTTP._check_zipsllQeAsD,<,<=>E NN5# &DM?" s0B A/"B/ A;8B:A;;BB rSrl base_headersc|j}d|d||d<d|d<|jj|j|dS)z:Return HTTP response to a range request from start to end.zbytes=-Rangezno-cachez Cache-ControlT)r-stream)copyr1r:r2)r<rSrlrmr-s r!_stream_responsez LazyZipOverHTTP._stream_responsesS##%#E7!C51#- }}  GD IIr leftrightc#:K|j|||j||}}t|g|ddzx}}t|g|ddz}t ||D]\}} ||kDr ||dz f| dz}||kr||f|g|gc|j|||j||yw)a/Return a generator 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 NrL)r8r9rOrMzip) r<rSrlrtrulslicersliceijks r!_mergezLazyZipOverHTTP._mergesD/T%1H&!*,--E3%&+%&'DAq1uQhAA( 8S&L;@'C57 4 D 7sBBc|j5t|j|}t|j|}|j ||||D]n\}}|j ||}|j|j|t||jD]}|jj|p dddy#1swYyxYw)z-Download bytes from start to end inclusively.N) rhrr9rr8r~rsrr[rr3r6write)r<rSrlrtruresponsechunks r!rPzLazyZipOverHTTP._downloads ZZ\t{{E2D S1E"kk%dEB s00<))+ % ,Xt7G7GHEJJ$$U+I C\\s B2C  C)r%N)rw)rra)r%r')&rrr__doc__rstrrr4r=propertyrAr"boolrDrGrIr.rQrWr[rNr r7r_rbr rerr rhr;rr rrsrr~rPrr r!r'r'(s@R!+9<  cc$!!! % %e %$/3//C/!c!)Xc])c)$"S"T" y!12    DKJJ"J26sCx.J JII"I*-I69I 5c?D$. /I, ,s , , ,r r'N)'r__all__bisectrr contextlibrtempfilertypingr r r r r rzipfilerrpip._vendor.packaging.utilsrpip._vendor.requests.modelsrrpip._internal.metadatarrrpip._internal.network.sessionrpip._internal.network.utilsrrr Exceptionrrrr'rr r!rsy (*? @,%'>>'9DXX4RR ) FcFFjFEUF"j,j,r