ok

Mini Shell

Direktori : /lib/python3.6/site-packages/pip/utils/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/pip/utils/__pycache__/ui.cpython-36.pyc

3

�PfM-�@s�ddlmZddlmZddlZddlZddlmZmZmZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZdd	lmZmZdd
lmZmZmZddlmZyddlmZWnek
r�dZYnXe
je�Z d
d�Z!e!ee�Z"Gdd�de#�Z$Gdd�de#�Z%Gdd�de#�Z&Gdd�de&e$e%e"�Z'Gdd�de&e$e%ee�Z(e	j)dd��Z*Gdd�de#�Z+Gdd�de#�Z,Gdd �d e#�Z-e	j)d!d"��Z.dS)#�)�absolute_import)�divisionN)�signal�SIGINT�default_int_handler)�WINDOWS)�format_size)�get_indentation)�six)�Bar�IncrementalBar)�WritelnMixin�HIDE_CURSOR�SHOW_CURSOR)�Spinner)�coloramacCs�t|jdd�}|s|St|dtj��t|dtj��g}|tt|dg��7}ytj�j|�j|�Wntk
rv|SX|SdS)N�encodingZ
empty_fillZfill�phases)�getattr�filer
Z	text_type�list�join�encode�UnicodeEncodeError)Z	preferredZfallbackrZ
characters�r�/usr/lib/python3.6/ui.py�_select_progress_classsrcs4eZdZdZ�fdd�Z�fdd�Zdd�Z�ZS)�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_sigint�original_handlerr)�self�args�kwargs)�	__class__rrrNs
zInterruptibleMixin.__init__cstt|�j�tt|j�dS)z�
        Restore the original SIGINT handler after finishing.

        This should happen regardless of whether the progress display finishes
        normally, or gets interrupted.
        N)rr�finishrrr!)r")r%rrr&^szInterruptibleMixin.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"Zsignum�framerrrr hsz InterruptibleMixin.handle_sigint)�__name__�
__module__�__qualname__�__doc__rr&r �
__classcell__rr)r%rr<s
rcsJeZdZ�fdd�Zedd��Zedd��Zedd��Zdd
d�Z�Z	S)
�DownloadProgressMixincs,tt|�j||�dt�d|j|_dS)N� �)rr-rr	�message)r"r#r$)r%rrruszDownloadProgressMixin.__init__cCs
t|j�S)N)r�index)r"rrr�
downloadedysz DownloadProgressMixin.downloadedcCs |jdkrdStd|j�dS)Ngz...�z/s)Zavgr)r"rrr�download_speed}s
z$DownloadProgressMixin.download_speedcCs|jrd|jSdS)Nzeta %s�)ZetaZeta_td)r"rrr�
pretty_eta�s
z DownloadProgressMixin.pretty_etar3ccs*x|D]}|V|j|�qW|j�dS)N)�nextr&)r"�it�n�xrrr�iter�s
zDownloadProgressMixin.iter)r3)
r(r)r*r�propertyr2r4r6r;r,rr)r%rr-ss
r-cseZdZ�fdd�Z�ZS)�WindowsMixincs\tr�jrd�_tt��j||�trXtrXtj�j��_�fdd��j_�fdd��j_	dS)NFcs�jjj�S)N)r�wrapped�isattyr)r"rr�<lambda>�sz'WindowsMixin.__init__.<locals>.<lambda>cs�jjj�S)N)rr>�flushr)r"rrr@�s)
rZhide_cursorrr=rrZAnsiToWin32rr?rA)r"r#r$)r%)r"rr�s
zWindowsMixin.__init__)r(r)r*rr,rr)r%rr=�sr=c@seZdZejZdZdZdS)�DownloadProgressBarz
%(percent)d%%z0%(downloaded)s %(download_speed)s %(pretty_eta)sN)r(r)r*�sys�stdoutrr0�suffixrrrrrB�srBc@s&eZdZejZdZdd�Zdd�ZdS)�DownloadProgressSpinnerz!%(downloaded)s %(download_speed)scCs"t|d�stj|j�|_t|j�S)N�_phaser)�hasattr�	itertools�cyclerrGr7)r"rrr�
next_phase�s
z"DownloadProgressSpinner.next_phasecCsN|j|}|j�}|j|}dj||r*dnd||r6dnd|g�}|j|�dS)Nr5r.)r0rKrErZwriteln)r"r0ZphaserE�linerrr�update�s



zDownloadProgressSpinner.updateN)	r(r)r*rCrDrrErKrMrrrrrF�srFccsRtrdVnB|j�s$tj�tjkr,dVn"|jt�z
dVWd|jt�XdS)N)	rr?�logger�getEffectiveLevel�logging�INFO�writerr)rrrr�
hidden_cursor�s

rSc@s$eZdZdd�Zdd�Zdd�ZdS)�RateLimitercCs||_d|_dS)Nr)�_min_update_interval_seconds�_last_update)r"�min_update_interval_secondsrrrr�szRateLimiter.__init__cCstj�}||j}||jkS)N)�timerVrU)r"ZnowZdeltarrr�ready�s
zRateLimiter.readycCstj�|_dS)N)rXrV)r"rrr�reset�szRateLimiter.resetN)r(r)r*rrYrZrrrrrT�srTc@s.eZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�InteractiveSpinnerN�-\|/��?cCs\||_|dkrtj}||_t|�|_d|_tj|�|_	|jj
dt�|jd�d|_dS)NFr.z ... r)
�_messagerCrD�_filerT�
_rate_limiter�	_finishedrIrJ�_spin_cyclerRr	�_width)r"r0rZ
spin_charsrWrrrr�s
zInteractiveSpinner.__init__cCs^|jst�d|j}|jj|d|j|�|jj|�t|�|_|jj�|jj�dS)N�r.)	ra�AssertionErrorrcr_rR�lenrAr`rZ)r"�statusZbackuprrr�_write	s


zInteractiveSpinner._writecCs,|jr
dS|jj�sdS|jt|j��dS)N)rar`rYrhr7rb)r"rrr�spins

zInteractiveSpinner.spincCs4|jr
dS|j|�|jjd�|jj�d|_dS)N�
T)rarhr_rRrA)r"�final_statusrrrr&s

zInteractiveSpinner.finish)Nr\r])r(r)r*rrhrir&rrrrr[�s


r[c@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�NonInteractiveSpinner�<cCs$||_d|_t|�|_|jd�dS)NFZstarted)r^rarTr`�_update)r"r0rWrrrr*s
zNonInteractiveSpinner.__init__cCs*|jst�|jj�tjd|j|�dS)Nz%s: %s)rarer`rZrN�infor^)r"rgrrrrn0s
zNonInteractiveSpinner._updatecCs&|jr
dS|jj�sdS|jd�dS)Nzstill running...)rar`rYrn)r"rrrri5s

zNonInteractiveSpinner.spincCs$|jr
dS|jd|f�d|_dS)Nzfinished with status '%s'T)rarn)r"rkrrrr&<szNonInteractiveSpinner.finishN)rm)r(r)r*rrnrir&rrrrrl)s
rlccs�tjj�r"tj�tjkr"t|�}nt|�}y t	tj��|VWdQRXWn>t
k
rj|jd��Yn*tk
r�|jd��YnX|jd�dS)NZcanceled�error�done)
rCrDr?rNrOrPrQr[rlrS�KeyboardInterruptr&�	Exception)r0Zspinnerrrr�open_spinnerCs


rt)/Z
__future__rrrIrCrrrrX�
contextlibrPZ
pip.compatrZ	pip.utilsrZpip.utils.loggingr	Zpip._vendorr
Zpip._vendor.progress.barrrZpip._vendor.progress.helpersr
rrZpip._vendor.progress.spinnerrrrsZ	getLoggerr(rNrZ_BaseBar�objectrr-r=rBrF�contextmanagerrSrTr[rlrtrrrr�<module>sB


7
!0

Zerion Mini Shell 1.0