\hdZddgZddlmZmZddlmZddlmZddl 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__c/root/niggaflix-v3/playground/venv/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!rrsM g &F"BGGR(&e->t-DE FFFs +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||jdk(sJ|||c|_|_|_t|jd|_ t|_ |j|jg|_ g|_d|jjddvr t!d|j#y)N)headerszContent-Lengthbytesz Accept-Rangesnonezrange request is not supported)headrr status_code_session_url _chunk_sizeintr-_lengthr_filetruncate_left_rightgetr _check_zip)selfr#r$r+r1s r!__init__zLazyZipOverHTTP.__init__1s||C|13&&&5s r!modezLazyZipOverHTTP.modeAsr c.|jjS)zPath to the underlying file.)r8r"rBs r!r"zLazyZipOverHTTP.nameFszzr cy)z9Return whether random access is supported, which is True.TrrBs r!seekablezLazyZipOverHTTP.seekableKr c8|jjy)zClose the file.N)r8closerBs r!rIzLazyZipOverHTTP.closeOs r c.|jjS)zWhether the file is closed.)r8closedrBs r!rKzLazyZipOverHTTP.closedSszz   r sizect||j}|j|j}}|dkr|nt ||z|}td||z }|j ||dz |j j|S)zRead 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)maxr5tellr7min _downloadr8read)r>rL download_sizestartlengthstops r!rSzLazyZipOverHTTP.readXsxD$"2"23  T\\vvs5=+@&'IAtm+, udQh'zzt$$r cy)z3Return whether the file is readable, which is True.TrrBs r!readablezLazyZipOverHTTP.readablefrGr offsetwhencec:|jj||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. )r8seek)r>rZr[s r!r]zLazyZipOverHTTP.seekjszzvv..r c6|jjS)zReturn the current position.)r8rPrBs r!rPzLazyZipOverHTTP.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. )r8r9)r>rLs r!r9zLazyZipOverHTTP.truncatexszz""4((r cy)z Return False.FrrBs r!writablezLazyZipOverHTTP.writablesr c:|jj|SN)r8 __enter__rBs r!rdzLazyZipOverHTTP.__enter__s  r excc6|jj|yrc)r8__exit__)r>res r!rgzLazyZipOverHTTP.__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)rPr])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.rNrN)r7reversedranger5rRrjrr)r>endrUs r!r=zLazyZipOverHTTP._check_zipsllQeAsD,<,<=> E NN5# & DM   "    s0B A/"B/ A;8B:A;;BB rUrn 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)copyr3r<r4)r>rUrnror-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 NrN)r:r;rQrOzip) r>rUrnrvrwlslicersliceijks 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) rjrr;rr:rrurr]rr5r8write)r>rUrnrvrwresponsechunks r!rRzLazyZipOverHTTP._downloads ZZ\ ,t{{E2D S1E"kk%dEB , s00<))+ % ,Xt7G7GH,EJJ$$U+,  , , , ,s B2C  C)r%N)ry)rrc)r%r')&rrr__doc__rstrrr6r?propertyrCr"boolrFrIrKr/rSrYr]rPr r9rardr rgrr rjr=rr rrurrrRrr 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