3 igl @sUddlZddlZddlmZmZmZddlmZddlmZm Z m Z ddl m Z ddl mZddlmZddlmZydd lmZWnek rdZYnXeeed d d Zee eZeGd ddZGdddeZGddde ZGdddZGdddZGdddeeeZGdddeeZGdddeeZGdddeeZ Gdd d ee Z!Gd!d"d"eeZ"Gd#d$d$eeee Z#eefee#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) preferredfallbackreturnc Cstt|jdd}|s|St|ddt|ddg}|tt|dg7}ydj|j|Wntk rj|SX|SdS)Nencoding empty_fillfillphases)getattrfilelistjoinencodeUnicodeEncodeError)rrr charactersr>/tmp/pip-build-88gy_88q/pip/pip/_internal/cli/progress_bars.py_select_progress_classs rcsDeZdZdZeeddfdd 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. N)argskwargsrcs0tj||tt|j|_|jdkr,t|_dS)z= Save the original SIGINT handler for later. N)super__init__rr handle_sigintoriginal_handlerr)selfr!r") __class__rrr$Es zInterruptibleMixin.__init__)rcstjtt|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|j|j||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'signumframerrrr%`sz InterruptibleMixin.handle_sigint) __name__ __module__ __qualname____doc__rr$r)r% __classcell__rr)r(rr 3s r c@seZdZddddZdS) SilentBarN)rcCsdS)Nr)r'rrrupdatelszSilentBar.update)r,r-r.r2rrrrr1ksr1c@seZdZdZdZdZdZdS) BlueEmojiBarz %(percent)d%% 🔹🔷🔵N)r5r6r7)r,r-r.suffix bar_prefix bar_suffixrrrrrr3psr3csdeZdZeeddfdd ZeedddZeeddd Zeedd d Z d d Z Z S)DownloadProgressMixinN)r!r"rcs(tj||dtd|j|_dS)Nr4)r#r$r message)r'r!r")r(rrr$yszDownloadProgressMixin.__init__)rcCs t|jS)N)r index)r'rrr downloaded~sz DownloadProgressMixin.downloadedcCs |jdkrdStd|jdS)Ngz...z/s)avgr )r'rrrdownload_speeds z$DownloadProgressMixin.download_speedcCs|jrd|jSdS)Nzeta r)etaeta_td)r'rrr pretty_etas z DownloadProgressMixin.pretty_etaccs.x |D]}|V|jt|qW|jdS)N)nextlenr))r'itxrrriters zDownloadProgressMixin.iter) r,r-r.rr$propertystrr?rBrErJr0rr)r(rr;xsr;cs&eZdZeeddfdd ZZS) WindowsMixinN)r!r"rcsXtrjrd_tj||trTtrTtjj_fddj_fddj_dS)NFcs jjjS)N)rwrappedisattyr)r'rrsz'WindowsMixin.__init__..cs jjjS)N)rrNflushr)r'rrrPs) r hide_cursorr#r$r AnsiToWin32rrOrQ)r'r!r")r()r'rr$s zWindowsMixin.__init__)r,r-r.rr$r0rr)r(rrMsrMc@seZdZejZdZdZdS)BaseDownloadProgressBarz %(percent)d%%z0%(downloaded)s %(download_speed)s %(pretty_eta)sN)r,r-r.sysstdoutrr=r8rrrrrTsrTc@s eZdZdS)DefaultDownloadProgressBarN)r,r-r.rrrrrWsrWc@s eZdZdS)DownloadSilentBarN)r,r-r.rrrrrXsrXc@s eZdZdS) DownloadBarN)r,r-r.rrrrrYsrYc@s eZdZdS)DownloadFillingCirclesBarN)r,r-r.rrrrrZsrZc@s eZdZdS)DownloadBlueEmojiProgressBarN)r,r-r.rrrrr[sr[c@s2eZdZejZdZedddZddddZ dS)DownloadProgressSpinnerz!%(downloaded)s %(download_speed)s)rcCs"t|dstj|j|_t|jS)N_phaser)hasattr itertoolscyclerr]rF)r'rrr next_phases z"DownloadProgressSpinner.next_phaseNcCsN|j|}|j}|j|}dj||r*dnd||r6dnd|g}|j|dS)Nrr4)r=rar8rwriteln)r'r=phaser8linerrrr2s    zDownloadProgressSpinner.update) r,r-r.rUrVrr8rLrar2rrrrr\sr\)offonasciiprettyZemojicCs8|dks|dkr t|djSt|d|djSdS)Nrr@)max) BAR_TYPESrJ)Z progress_barrirrrDownloadProgressProvidersrk)N)&r_rUrrrZtypingrpip._vendor.progress.barrrrpip._vendor.progress.spinnerr Zpip._internal.utils.compatr Zpip._internal.utils.loggingr Zpip._internal.utils.miscr pip._vendorr Exceptionr_BaseBarr r1r3r;rMrTrWrXrYrZr[r\rjrkrrrrsD      8