Hacked By AnonymousFox
3
�PfM- � @ s� d dl mZ d dl mZ d dlZd dlZd dlmZmZmZ d dlZd dl Z d dl
Z
d dlmZ d dl
mZ d dlmZ d dlmZ d d lmZmZ d d
lmZmZmZ d dlmZ yd dlmZ W n ek
r� dZY nX e
je�Z d
d� Z!e!ee�Z"G dd� de#�Z$G dd� de#�Z%G dd� de#�Z&G dd� de&e$e%e"�Z'G dd� de&e$e%ee�Z(e j)dd� �Z*G dd� de#�Z+G dd� de#�Z,G dd � 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)�coloramac C s� t | jdd �}|s|S t | dtj� �t | dtj� �g}|tt | dg ��7 }ytj� j|�j|� W n tk
rv |S X | S d S )N�encodingZ
empty_fillZfill�phases)�getattr�filer
Z text_type�list�join�encode�UnicodeEncodeError)Z preferredZfallbackr Z
characters� r �/usr/lib/python3.6/ui.py�_select_progress_class s r c s4 e Zd ZdZ� 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.
c s4 t t| �j||� tt| j�| _| jdkr0t| _dS )z=
Save the original SIGINT handler for later.
N)�superr �__init__r r �
handle_sigint�original_handlerr )�self�args�kwargs)� __class__r r r N s
zInterruptibleMixin.__init__c s t t| �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)r r �finishr r r! )r"