U .eR6@sxddlmZmZddlZddlZddlZddlZddlZddlm Z m Z mZddl m Z ddl mZmZddlmZmZmZddlmZddlmZdd lmZdd lmZdd lmZerdd lmZm Z m!Z!zdd l m"Z"Wne#k rdZ"YnXe$e%Z&ddZ'e'eeZ(Gddde)Z*GdddeZ+GdddeZ,Gddde)Z-Gddde)Z.Gddde.e*e-Z/Gddde/e(Z0Gddde/e+Z1Gd d!d!e/eZ2Gd"d#d#e/eZ3Gd$d%d%e/e,Z4Gd&d'd'e.e*e-eZ5e1e1fe0e5fe2e5fe3e5fe4e5fd(Z6d7d)d*Z7ej8d+d,Z9Gd-d.d.e)Z:Gd/d0d0e)Z;Gd1d2d2e;ZdS)8)absolute_importdivisionN)SIGINTdefault_int_handlersignal)six) HIDE_CURSOR SHOW_CURSOR)BarFillingCirclesBarIncrementalBar)Spinner)WINDOWS)get_indentation) format_size)MYPY_CHECK_RUNNING)AnyIteratorIO)coloramacCst|jdd}|s|St|dtt|dtg}|tt|dg7}zt||Wntk rz|YSX|SdS)NencodingZ empty_fillZfillphases)getattrfilerZ text_typelistjoinencodeUnicodeEncodeError)Z preferredZfallbackrZ charactersr:/usr/lib/python3.8/site-packages/pip/_internal/utils/ui.py_select_progress_class%s r cs4eZdZdZfddZfddZddZZS)InterruptibleMixina Helper to ensure that self.finish() gets called on keyboard interrupt. This allows downloads to be interrupted without leaving temporary state (like hidden cursors) behind. This class is similar to the progress library's existing SigIntMixin helper, but as of version 1.2, that helper has the following problems: 1. It calls sys.exit(). 2. It discards the existing SIGINT handler completely. 3. It leaves its own handler in place even after an uninterrupted finish, which will have unexpected delayed effects if the user triggers an unrelated keyboard interrupt some time after a progress-displaying download has already completed, for example. cs4tt|j||tt|j|_|jdkr0t|_dS)z= Save the original SIGINT handler for later. N)superr!__init__rr handle_sigintoriginal_handlerrselfargskwargs __class__rrr#Us zInterruptibleMixin.__init__cstt|tt|jdS)z Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted. N)r"r!finishrrr%r'r*rrr,eszInterruptibleMixin.finishcCs||||dS)z Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active. N)r,r%)r'Zsignumframerrrr$osz InterruptibleMixin.handle_sigint)__name__ __module__ __qualname____doc__r#r,r$ __classcell__rrr*rr!Cs  r!c@seZdZddZdS) SilentBarcCsdSNrr-rrrupdate|szSilentBar.updateN)r/r0r1r6rrrrr4zsr4c@seZdZdZdZdZdZdS) BlueEmojiBar %(percent)d%% )u🔹u🔷u🔵N)r/r0r1suffixZ bar_prefixZ bar_suffixrrrrrr7sr7csJeZdZfddZeddZeddZeddZd d d ZZ S) DownloadProgressMixincs,tt|j||dtd|j|_dS)Nr9)r"r;r#rmessager&r*rrr#szDownloadProgressMixin.__init__cCs t|jSr5)rindexr-rrr downloadedsz DownloadProgressMixin.downloadedcCs |jdkrdStd|jdS)Ngz...z/s)Zavgrr-rrrdownload_speeds z$DownloadProgressMixin.download_speedcCs|jrd|jSdS)Nzeta %s)ZetaZeta_tdr-rrr pretty_etas z DownloadProgressMixin.pretty_etar@ccs&|D]}|V||q|dSr5)nextr,)r'itnxrrriters zDownloadProgressMixin.iter)r@) r/r0r1r#propertyr?rArCrHr3rrr*rr;s    r;cseZdZfddZZS) WindowsMixincs\trjrd_ttj||trXtrXtj_fddj_fddj_ dS)NFcs jjSr5)rwrappedisattyrr-rrz'WindowsMixin.__init__..cs jjSr5)rrKflushrr-rrrMrN) rZ hide_cursorr"rJr#rZ AnsiToWin32rrLrOr&r*r-rr#s zWindowsMixin.__init__)r/r0r1r#r3rrr*rrJsrJc@seZdZejZdZdZdS)BaseDownloadProgressBarr8z0%(downloaded)s %(download_speed)s %(pretty_eta)sN)r/r0r1sysstdoutrr=r:rrrrrPsrPc@s eZdZdS)DefaultDownloadProgressBarNr/r0r1rrrrrSsrSc@s eZdZdS)DownloadSilentBarNrTrrrrrUsrUc@s eZdZdS) DownloadBarNrTrrrrrVsrVc@s eZdZdS)DownloadFillingCirclesBarNrTrrrrrWsrWc@s eZdZdS)DownloadBlueEmojiProgressBarNrTrrrrrXsrXc@s&eZdZejZdZddZddZdS)DownloadProgressSpinnerz!%(downloaded)s %(download_speed)scCs"t|dst|j|_t|jS)N_phaser)hasattr itertoolscyclerrZrDr-rrr next_phases z"DownloadProgressSpinner.next_phasecCsN|j|}|}|j|}d||r*dnd||r6dnd|g}||dS)NrBr9)r=r^r:rZwriteln)r'r=Zphaser:linerrrr6s    zDownloadProgressSpinner.updateN) r/r0r1rQrRrr:r^r6rrrrrYsrY)ZoffZonasciiZprettyZemojicCs8|dks|dkr t|djSt|d|djSdS)Nrr@)max) BAR_TYPESrH)Z progress_barrarrrDownloadProgressProvider srcc csPtr dVn@|r"ttjkr*dVn"|tz dVW5|tXdSr5) rrLloggergetEffectiveLevelloggingINFOwriterr )rrrr hidden_cursors  ric@s$eZdZddZddZddZdS) RateLimitercCs||_d|_dS)Nr)_min_update_interval_seconds _last_update)r'min_update_interval_secondsrrrr#-szRateLimiter.__init__cCst}||j}||jkSr5)timerlrk)r'ZnowZdeltarrrready2s zRateLimiter.readycCst|_dSr5)rnrlr-rrrreset8szRateLimiter.resetN)r/r0r1r#rorprrrrrj,srjc@seZdZddZddZdS)SpinnerInterfacecCs tdSr5NotImplementedErrorr-rrrspin>szSpinnerInterface.spincCs tdSr5rrr'Z final_statusrrrr,BszSpinnerInterface.finishN)r/r0r1rtr,rrrrrq=srqc@s.eZdZd ddZddZdd Zd d ZdS) InteractiveSpinnerN-\|/?cCs\||_|dkrtj}||_t||_d|_t||_ |j dt |jdd|_ dS)NFr9z ... r) _messagerQrR_filerj _rate_limiter _finishedr\r] _spin_cyclerhr_width)r'r=rZ spin_charsrmrrrr#Hs  zInteractiveSpinner.__init__cCs\|jr td|j}|j|d|j||j|t||_|j|jdS)Nr9) r|AssertionErrorr~rzrhlenrOr{rp)r'statusZbackuprrr_writeWs     zInteractiveSpinner._writecCs,|jr dS|jsdS|t|jdSr5)r|r{rorrDr}r-rrrrtcs  zInteractiveSpinner.spincCs4|jr dS|||jd|jd|_dS)N T)r|rrzrhrOrurrrr,ks    zInteractiveSpinner.finish)Nrwrx)r/r0r1r#rrtr,rrrrrvGs   rvc@s.eZdZd ddZddZddZdd Zd S) NonInteractiveSpinner<cCs$||_d|_t||_|ddS)NFZstarted)ryr|rjr{_update)r'r=rmrrrr#zs zNonInteractiveSpinner.__init__cCs(|jr t|jtd|j|dS)Nz%s: %s)r|rr{rprdinfory)r'rrrrrs  zNonInteractiveSpinner._updatecCs&|jr dS|jsdS|ddS)Nzstill running...)r|r{rorr-rrrrts  zNonInteractiveSpinner.spincCs$|jr dS|d|fd|_dS)Nzfinished with status '%s'T)r|rrurrrr,szNonInteractiveSpinner.finishN)r)r/r0r1r#rrtr,rrrrrys rc cstjr"ttjkr"t|}nt|}z t tj |VW5QRXWn>t k rj| dYn*t k r| dYn X| ddS)NZcancelederrorZdone) rQrRrLrdrerfrgrvrriKeyboardInterruptr, Exception)r=Zspinnerrrr open_spinners    r)N)?Z __future__rr contextlibr\rfrQrnrrrZ pip._vendorrZpip._vendor.progressrr Zpip._vendor.progress.barr r r Zpip._vendor.progress.spinnerr Zpip._internal.utils.compatrZpip._internal.utils.loggingrZpip._internal.utils.miscrZpip._internal.utils.typingrtypingrrrrrZ getLoggerr/rdr Z_BaseBarobjectr!r4r7r;rJrPrSrUrVrWrXrYrbrccontextmanagerrirjrqrvrrrrrrs~         7       2