U ��W�? � @ s d Z ddlZddlZddlZddlZddlmZmZmZm Z m Z mZmZm Z mZ ddlmZ ddlmZ ejdkr|dZd Znd ZdZdd � ZG dd� de�Zd"dd�Zdd� Zdd� Zdd� ZG dd� de�Zd#dd�Zdd� Zer�ddl Z dd � Z!nddl"Z"ddl#Z#d!d � Z!dS )$aY click._termui_impl ~~~~~~~~~~~~~~~~~~ This module contains implementations for the termui module. To keep the import time of Click down, some infrequently used functionality is placed in this module and only imported as needed. :copyright: (c) 2014 by Armin Ronacher. :license: BSD, see LICENSE for more details. � N� ) �_default_text_stdout� range_type�PY2�isatty�open_stream� strip_ansi�term_len�get_best_encoding�WIN)�echo)�ClickException�nt� � z [?25lz[?25h c C s� z t | �W S tk r� zt| �j}W n tk r@ Y Y dS X z|| �}W n tk rf Y Y dS X |tks�t|ttf�r�|dk r�Y dS | Y S X dS )z%Returns the length hint of an object.Nr ) �len� TypeError�type�__length_hint__�AttributeError�NotImplemented� isinstance�intZlong)�objZget_hintZhint� r �/_termui_impl.py�_length_hint s$ ��r c @ s� e Zd Zd+d d �Zdd� Zd d� Zdd� Zdd� Zedd� �Z edd� �Z edd� �Zdd� Zdd� Z dd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zes�eZ[dS ),�ProgressBarN�#� �%(bar)s� TF� c C s || _ || _|| _|| _|| _|| _| | _| | _|p6d| _|d krHt � }|| _ | | _|| _|dk| _ |d krtt|�}|d kr�|d kr�td��t|�}t|�| _|| _|d k | _d| _g | _t�� | _| _d| _d| _d | _d| _d | _t| j � | _d | _ d S )N� r ziterable or length is requiredF)!� fill_char� empty_char�bar_template�info_sep�show_eta�show_percent�show_pos�item_show_func�labelr �file�color�width� autowidthr r r �iter�length�length_known�pos�avg�time�start�last_eta� eta_known�finished� max_width�entered�current_itemr � is_hidden� _last_line)�self�iterabler2 r$ r% r&