a [fl @sUddlZddlZddlmZmZmZddlmZddlmZm Z m Z ddl m Z ddl mZddlmZddlmZzdd lmZWneydZYn0eeed d d Zee eZeed <GdddZGdddeZGddde ZGdddZGdddZGdddeeeZGdddeeZGdddeeZ GdddeeZ!Gd d!d!ee Z"Gd"d#d#eeZ#Gd$d%d%eeee Z$e e fee$fe!e$fe"e$fe#e$fd&Z%d)d'd(Z&dS)*N)SIGINTdefault_int_handlersignal)Any)BarFillingCirclesBarIncrementalBar)Spinner)WINDOWS)get_indentation) format_size)colorama) preferredfallbackreturncCsvt|jdd}|s|St|ddt|ddg}|tt|dg7}zd||Wntyl|YS0|SdS)NencodingZ empty_fillfillphases)getattrfilelistjoinencodeUnicodeEncodeError)rrrZ charactersrC/usr/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py_select_progress_classs    r_BaseBarcsDeZdZdZeeddfdd Zddfdd Zd d ZZS) 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. Nargskwargsrcs4tj|i|tt|j|_|jdur0t|_dS)z= Save the original SIGINT handler for later. N)super__init__rr handle_sigintoriginal_handlerrselfr!r" __class__rrr$Es zInterruptibleMixin.__init__rcsttt|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#finishrrr&r(r)rrr,Vs zInterruptibleMixin.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%`sz InterruptibleMixin.handle_sigint) __name__ __module__ __qualname____doc__rr$r,r% __classcell__rrr)rr3s rc@seZdZddddZdS) SilentBarNr+cCsdSNrr-rrrupdatelszSilentBar.update)r/r0r1r6rrrrr4ksr4c@seZdZdZdZdZdZdS) BlueEmojiBar %(percent)d%% )u🔹u🔷u🔵N)r/r0r1suffixZ bar_prefixZ bar_suffixrrrrrr7psr7csdeZdZeeddfdd ZeedddZeeddd Zeedd d Z d d Z Z S)DownloadProgressMixinNr cs,tj|i|dtd|j|_dS)Nr9)r#r$r messager'r)rrr$yszDownloadProgressMixin.__init__r+cCs t|jSr5)r indexr-rrr downloaded~sz DownloadProgressMixin.downloadedcCs |jdkrdStd|jdS)Ngz...z/s)Zavgr r-rrrdownload_speeds z$DownloadProgressMixin.download_speedcCs|jrd|jSdS)Nzeta r)ZetaZeta_tdr-rrr pretty_etas z DownloadProgressMixin.pretty_etaccs*|D]}|V|t|q|dSr5)nextlenr,)r(itxrrriterszDownloadProgressMixin.iter) r/r0r1rr$propertystrr?rArBrGr3rrr)rr;xsr;cs&eZdZeeddfdd ZZS) WindowsMixinNr cs\trjrd_tj|i|trXtrXtj_fddj_fddj_dS)NFcs jjSr5)rwrappedisattyrr-rrz'WindowsMixin.__init__..cs jjSr5)rrKflushrr-rrrMrN) r Z hide_cursorr#r$r Z AnsiToWin32rrLrOr'r)r-rr$s zWindowsMixin.__init__)r/r0r1rr$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@s2eZdZejZdZedddZddddZ dS)DownloadProgressSpinnerz!%(downloaded)s %(download_speed)sr+cCs"t|dst|j|_t|jS)N_phaser)hasattr itertoolscyclerrZrCr-rrr next_phases z"DownloadProgressSpinner.next_phaseNcCsN|j|}|}|j|}d||r*dnd||r6dnd|g}||dS)Nrr9)r=r^r:rZwriteln)r(r=Zphaser:linerrrr6s     zDownloadProgressSpinner.update) r/r0r1rQrRrr:rIr^r6rrrrrYsrY)ZoffZonasciiZprettyZemojicCs8|dus|dkr t|djSt|d|djSdS)Nrr@)max) BAR_TYPESrG)Z progress_barrarrrDownloadProgressProvidersrc)N)'r\rQrrrtypingrZpip._vendor.progress.barrrrZpip._vendor.progress.spinnerr Zpip._internal.utils.compatr Zpip._internal.utils.loggingr Zpip._internal.utils.miscr Z pip._vendorr Exceptionrr__annotations__rr4r7r;rJrPrSrUrVrWrXrYrbrcrrrrsF        8