7f dZddlZddlZddlZddlZddlmZmZm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZdd lmZmZmZdd lmZmZmZej e!Z"d e dee#fdZ$d e dede%dee&fdZ'de%de%fdZ(de%de%de%fdZ)d e dede%fdZ*dedede fdZ+GddZ,GddZ-dS)z)Download files with progress indicators. N)IterableOptionalTuple)Response)get_download_progress_renderer)NetworkConnectionError)PyPI)Link) is_from_cache) PipSession)HEADERSraise_for_statusresponse_chunks) format_sizeredact_auth_from_urlsplitextrespreturnct t|jdS#tttf$rYdSwxYw)Nzcontent-length)intheaders ValueErrorKeyError TypeError)rs ~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/network/download.py_get_http_response_sizersF4< 01222 ) ,tts 77link progress_barc6t|}|jtjkr|j}n|j}t |}|r|dt|d}t|rt d|nt d|t tj krd}n"t|rd}n|sd}n |dkrd}nd}t|}|s|St||}||S) Nz ()zUsing cached %szDownloading %sFTi)bar_typesize)rnetlocr file_storage_domainshow_urlurl_without_fragmentrrr loggerinfogetEffectiveLevelloggingINFOrr) rrr total_lengthurl logged_url show_progresschunksrenderers r_prepare_downloadr2s< +400L {d...m'%c**JC"BBk,&?&?BBB T2 %z2222 $j111 !!GL00 t     $ $  T " "F  -|,WWWH 8F  filenamec@tj|S)zJ Sanitize the "filename" value from a Content-Disposition header. )ospathbasename)r4s rsanitize_content_filenamer9Is 7  H % %%r3content_dispositiondefault_filenamectj}||d<|d}|rt t |}|p|S)z Parse the "filename" value from a Content-Disposition header, and return the default filename if the result is empty. content-typer4)emailmessageMessage get_paramr9str)r:r;mr4s rparse_content_dispositionrDPs[  A+An{{:&&H<-S]];;  '''r3c|j}|jd}|rt||}t |d}|s4t j|jdd}|r||z }|sA|j|jkr1tj |jd}|r||z }|S)zoGet an ideal filename from the given HTTP response, falling back to the link filename if not provided. zcontent-dispositionr=) r4rgetrDr mimetypesguess_extensionr-r6r7)rrr4r:exts r_get_http_response_filenamerL_s}H,**+@AAL,-@(KK!(++A.C ' (8(8(L(LMM   OH 48tx''gtx((+   OH Or3sessionc|jddd}||td}t ||S)N#rFrT)rstream)r-splitrHr r)rMr target_urlrs r_http_get_downloadrStsFQ''*J ;;z74; @ @DT Kr3cFeZdZdededdfdZdededeeeffdZdS) DownloaderrMrrNc"||_||_dSN_session _progress_barselfrMrs r__init__zDownloader.__init__|   )r3rlocationc t|j|}nB#t$r5}|jJtd|jj|d}~wwxYwt||}tj ||}t|||j }t|d5}|D]} ||  dddn #1swxYwY|jdd} || fS)z.Download the file given by link into location.NHTTP error %s while getting %swb Content-TyperGrSrYrresponser'critical status_coderLr6r7joinr2rZopenwriterrH) r\rr_rer4filepathr0 content_filechunk content_types r__call__zDownloader.__call__sY %dmT::DD%   :))) OO0!*2H$      /tT::7<<(33"4t/ABB (D ! ! *\ * *""5)))) * * * * * * * * * * * * * * * *|'';; %%s& A0AA0CCC) __name__ __module__ __qualname__r rBr]r rrpr3rrUrU{su***  ****&T&S&U38_&&&&&&r3rUc neZdZdededdfdZdeededeeeeeefffdZ dS) BatchDownloaderrMrrNc"||_||_dSrWrXr[s rr]zBatchDownloader.__init__r^r3linksr_c#"K|D]} t|j|}nB#t$r5}|jJtd|jj|d}~wwxYwt||}tj ||}t|||j }t|d5} |D]} | |  dddn #1swxYwY|jdd} ||| ffV dS)z0Download the files given by links into location.NrarbrcrGrd) r\rxr_rrrkr4rlr0rmrnros rrpzBatchDownloader.__call__s 1 1D )$->>)   z---4J*  34>>Hw||Hh77H&tT43EFFFh%% .#..E &&u----. . . . . . . . . . . . . . . . <++NB??L<00 0 0 0 0) 1 1s& A0AA7CC# &C# ) rqrrrsr rBr]rr rrprtr3rrvrvs***  ****1d^1/21 %eCHo-. /111111r3rv).__doc__ email.messager>r*rIr6typingrrrpip._vendor.requests.modelsrpip._internal.cli.progress_barsrpip._internal.exceptionsrpip._internal.models.indexr pip._internal.models.linkr pip._internal.network.cacher pip._internal.network.sessionr pip._internal.network.utilsr rrpip._internal.utils.miscrrr getLoggerrqr'rrrBbytesr2r9rDrLrSrUrvrtr3rrs ,,,,,,,,,,000000JJJJJJ;;;;;;++++++******555555444444RRRRRRRRRRPPPPPPPPPP  8 $ $(x}' ' ''e_ ''''T&&&&&& (3 (# (RU ( ( ( (hds* $8&&&&&&&&>!1!1!1!1!1!1!1!1!1!1r3