๓ •abc@`s<ddlmZddlmZddlZddlZddlmZmZmZddlZddl Z ddl Z ddl m Z ddl mZddlmZddlmZdd lmZmZdd lmZmZmZdd lmZydd lmZWnek r'dZnXe je ƒZ!d „Z"e"eeƒZ#de$fd„ƒYZ%de$fd„ƒYZ&de$fd„ƒYZ'de'e%e&e#fd„ƒYZ(de'e%e&eefd„ƒYZ)e j*d„ƒZ+de$fd„ƒYZ,de$fd„ƒYZ-de$fd„ƒYZ.e j*d„ƒZ/dS( i(tabsolute_import(tdivisionN(tsignaltSIGINTtdefault_int_handler(tWINDOWS(t format_size(tget_indentation(tsix(tBartIncrementalBar(t WritelnMixint HIDE_CURSORt SHOW_CURSOR(tSpinner(tcoloramacC`sจt|jddƒ}|s|St|dtjƒƒt|dtjƒƒg}|tt|dgƒƒ7}y tjƒj|ƒj|ƒWntk rŸ|SX|SdS(Ntencodingt empty_filltfilltphases( tgetattrtfiletNoneRt text_typetlisttjointencodetUnicodeEncodeError(t preferredtfallbackRt characters((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt_select_progress_classs  tInterruptibleMixincB`s)eZdZd„Zd„Zd„ZRS(sย 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. cO`sMtt|ƒj||Žtt|jƒ|_|jdkrIt|_ndS(s= Save the original SIGINT handler for later. N( tsuperR t__init__RRt handle_siginttoriginal_handlerRR(tselftargstkwargs((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR"NscC`s'tt|ƒjƒtt|jƒdS(sฝ Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted. N(R!R tfinishRRR$(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR(^scC`s|jƒ|j||ƒdS(sฒ 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%tsignumtframe((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR#hs (t__name__t __module__t__doc__R"R(R#(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR <s  tDownloadProgressMixincB`sJeZd„Zed„ƒZed„ƒZed„ƒZdd„ZRS(cO`s8tt|ƒj||Ždtƒd|j|_dS(Nt i(R!R.R"Rtmessage(R%R&R'((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR"uscC`s t|jƒS(N(Rtindex(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt downloadedyscC`s(|jdkrdStd|jƒdS(Ngs...is/s(tavgR(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytdownload_speed}scC`s|jrd|jSdS(Nseta %st(tetateta_td(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt pretty_eta„s  icc`s1x |D]}|V|j|ƒqW|jƒdS(N(tnextR((R%tittntx((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytiterŠs (R+R,R"tpropertyR2R4R8R=(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR.ss  t WindowsMixincB`seZd„ZRS(c`s†trˆjrtˆ_nttˆƒj||Žtr‚tr‚tjˆjƒˆ_‡fd†ˆj_ ‡fd†ˆj_ ndS(Nc`sˆjjjƒS(N(Rtwrappedtisatty((R%(s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytงR5c`sˆjjjƒS(N(RR@tflush((R%(s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRBซR5( Rt hide_cursortFalseR!R?R"Rt AnsiToWin32RRARC(R%R&R'((R%s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR"“s  (R+R,R"(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR?‘stDownloadProgressBarcB`seZejZdZdZRS(s %(percent)d%%s0%(downloaded)s %(download_speed)s %(pretty_eta)s(R+R,tsyststdoutRR0tsuffix(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRGฎs tDownloadProgressSpinnercB`s)eZejZdZd„Zd„ZRS(s!%(downloaded)s %(download_speed)scC`s4t|dƒs'tj|jƒ|_nt|jƒS(Nt_phaser(thasattrt itertoolstcycleRRLR9(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt next_phaseผscC`sm|j|}|jƒ}|j|}dj||r;dnd||rMdnd|gƒ}|j|ƒdS(NR5R/(R0RPRJRtwriteln(R%R0tphaseRJtline((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytupdateมs    (R+R,RHRIRRJRPRT(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRKถs  cc`sctrdVnQ|jƒ s0tjƒtjkr8dVn'|jtƒz dVWd|jtƒXdS(N( RRAtloggertgetEffectiveLeveltloggingtINFOtwriteR R (R((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt hidden_cursorุs"  t RateLimitercB`s#eZd„Zd„Zd„ZRS(cC`s||_d|_dS(Ni(t_min_update_interval_secondst _last_update(R%tmin_update_interval_seconds((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR"์s cC`s&tjƒ}||j}||jkS(N(ttimeR]R\(R%tnowtdelta((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytready๐s  cC`stjƒ|_dS(N(R_R](R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytreset๕s(R+R,R"RbRc(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR[๋s  tInteractiveSpinnercB`s5eZdddd„Zd„Zd„Zd„ZRS(s-\|/gภ?cC`sƒ||_|dkr!tj}n||_t|ƒ|_t|_t j |ƒ|_ |jj dt ƒ|jdƒd|_dS(NR/s ... i(t_messageRRHRIt_fileR[t _rate_limiterREt _finishedRNROt _spin_cycleRYRt_width(R%R0Rt spin_charsR^((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR"๚s     "cC`sid|j}|jj|d|j|ƒ|jj|ƒt|ƒ|_|jjƒ|jjƒdS(NsR/(RjRfRYtlenRCRgRc(R%tstatustbackup((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt_write s   cC`s:|jr dS|jjƒs dS|jt|jƒƒdS(N(RhRgRbRoR9Ri(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytspins  cC`sD|jr dS|j|ƒ|jjdƒ|jjƒt|_dS(Ns (RhRoRfRYRCtTrue(R%t final_status((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR(s    N(R+R,RR"RoRpR((((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRd๙s  tNonInteractiveSpinnercB`s/eZdd„Zd„Zd„Zd„ZRS(i<cC`s2||_t|_t|ƒ|_|jdƒdS(Ntstarted(ReRERhR[Rgt_update(R%R0R^((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR"*s  cC`s'|jjƒtjd|j|ƒdS(Ns%s: %s(RgRcRUtinfoRe(R%Rm((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRu0s cC`s1|jr dS|jjƒs dS|jdƒdS(Nsstill running...(RhRgRbRu(R%((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRp5s  cC`s.|jr dS|jd|fƒt|_dS(Nsfinished with status '%s'(RhRuRq(R%Rr((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyR(<s (R+R,R"RuRpR((((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyRs)s   cc`sณtjjƒr3tjƒtjkr3t|ƒ}n t|ƒ}yt tjƒ |VWdQXWnAt k r|j dƒ‚n.t k rก|j dƒ‚nX|j dƒdS(Ntcanceledterrortdone( RHRIRARURVRWRXRdRsRZtKeyboardInterruptR(t Exception(R0tspinner((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pyt open_spinnerCs$     (0t __future__RRRNRHRRRR_t contextlibRWt pip.compatRt pip.utilsRtpip.utils.loggingRt pip._vendorRtpip._vendor.progress.barR R tpip._vendor.progress.helpersR R R tpip._vendor.progress.spinnerRRR{Rt getLoggerR+RURt_BaseBartobjectR R.R?RGRKtcontextmanagerRZR[RdRsR}(((s0/usr/lib/python2.7/site-packages/pip/utils/ui.pytsB        7  !0