
Ebc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m	 Z	 d d l m
 Z
 d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z e j d k r d Z d Z n d Z d Z d   Z d e f d     YZ e d  Z d   Z d   Z d   Z d e f d     YZ  e! e! d  Z" d   Z# e rd d l$ Z$ e j% d     Z& d!   Z' n3 d d l( Z( d d l) Z) e j% d"    Z& d#   Z' d S($   s   
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.
iNi   (   t   _default_text_stdout(   t   CYGWIN(   t   get_best_encoding(   t	   int_types(   t   isatty(   t   open_stream(   t
   range_type(   t
   strip_ansi(   t   term_len(   t   WIN(   t   ClickException(   t   echot   nts   s   
s   [?25ls   [?25h
c         C   s   y t  |   SWn t t f k
 r y t |   j } Wn t k
 rK d SXy | |   } Wn t k
 rp d SX| t k s t | t  s | d k  r d S| SXd S(   s%   Returns the length hint of an object.i    N(	   t   lent   AttributeErrort	   TypeErrort   typet   __length_hint__t   Nonet   NotImplementedt
   isinstanceR   (   t   objt   get_hintt   hint(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   _length_hint"   s    (t   ProgressBarc           B   s   e  Z d d  d d d e d e d d d d d d  Z d   Z d   Z d   Z d	   Z	 e	 Z
 d
   Z d   Z e d    Z e d    Z e d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   t   #t    s   %(bar)ss     i   c         C   s  | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ |
 |  _ | pQ d |  _ | d  k ro t
   } n  | |  _ | |  _ | |  _ | d k |  _ | d  k r t |  } n  | d  k r | d  k r t d   n  t |  } n  t |  |  _ | |  _ | d  k	 |  _ d |  _ g  |  _ t j   |  _ |  _ t |  _ t |  _ d  |  _ t |  _ d  |  _ t  |  j  |  _! d  |  _" d |  _# d  S(   Nt    i    s   iterable or length is requiredg      ?($   t	   fill_chart
   empty_chart   bar_templatet   info_sept   show_etat   show_percentt   show_post   item_show_funct   labelR   R    t   filet   colort   widtht	   autowidthR   R   R   t   itert   lengtht   length_knownt   post   avgt   timet   startt   last_etat   Falset	   eta_knownt   finishedt	   max_widtht   enteredt   current_itemR   t	   is_hiddent
   _last_linet   short_limit(   t   selft   iterableR+   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   __init__5   sF    																				c         C   s   t  |  _ |  j   |  S(   N(   t   TrueR6   t   render_progress(   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt	   __enter__k   s    	
c         C   s   |  j    d  S(   N(   t   render_finish(   R;   t   exc_typet	   exc_valuet   tb(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   __exit__p   s    c         C   s,   |  j  s t d   n  |  j   |  j   S(   Ns.   You need to use progress bars in a with block.(   R6   t   RuntimeErrorR?   t	   generator(   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   __iter__s   s    	
c         C   s   t  t |    S(   N(   t   nextR*   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   __next__y   s    c         C   s   t  j    |  j |  j k S(   N(   R/   R0   R:   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   is_fast   s    c         C   s:   |  j  s |  j   r d  S|  j j t  |  j j   d  S(   N(   R8   RK   R&   t   writet	   AFTER_BARt   flush(   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyRA      s    c         C   s0   |  j  r d St |  j t |  j  p( d d  S(   Ng      ?i   (   R4   t   minR-   t   floatR+   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   pct   s    	c         C   s-   |  j  s d St |  j   t t |  j    S(   Ng        (   R.   t   sumRP   R   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   time_per_iteration   s    	c         C   s,   |  j  r( |  j r( |  j |  j |  j Sd S(   Ng        (   R,   R4   RS   R+   R-   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   eta   s    c         C   s   |  j  r t |  j  } | d } | d } | d } | d } | d } | d } | d k rv d j | | | |  Sd j | | |  Sn  d S(   Ni<   i   i    s   {}d {:02}:{:02}:{:02}s   {:02}:{:02}:{:02}R   (   R3   t   intRT   t   format(   R;   t   tt   secondst   minutest   hours(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt
   format_eta   s    	





c         C   s5   t  |  j  } |  j r1 | d j |  j  7} n  | S(   Ns   /{}(   t   strR-   R,   RV   R+   (   R;   R-   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt
   format_pos   s    	c         C   s   d j  t |  j d   d S(   Ns   {: 4}%id   i   (   RV   RU   RQ   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt
   format_pct   s    c         C   s   |  j  rG t |  j |  j  } |  j | } | |  j |  j | 7} n |  j rc |  j |  j } nr t |  j |  j px d  } |  j d k r |  j | t t	 j
 |  j |  j  d d |  j  <n  d j |  } | S(   Ni   i    g       @g      ?R   (   R,   RU   RQ   R(   R   R   R4   t   listRS   t   matht   cosR-   t   join(   R;   t
   bar_lengtht   bar(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt
   format_bar   s    		8c         C   s  |  j  } g  } |  j r1 | d  k r1 |  j } n  |  j rP | j |  j    n  | rl | j |  j    n  |  j r |  j r |  j	 r | j |  j
    n  |  j d  k	 r |  j |  j  } | d  k	 r | j |  q n  |  j i |  j d 6|  j   d 6|  j j |  d 6j   S(   NR%   Rd   t   info(   R"   R,   R   R#   t   appendR]   R^   R!   R3   R4   R[   R$   R7   R   R%   Re   R    Rb   t   rstrip(   R;   R"   t	   info_bitst	   item_info(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   format_progress_line   s&    		
c   	      C   s  d d l  m } |  j r d  Sg  } |  j r |  j } d |  _ t |  j    } t d |   d |  } | | k  r | j t	  | j d |  j
  | |  _
 n  | |  _ n  |  j } |  j
 d  k	 r |  j
 } n  | j t	  |  j   } t |  } |  j
 d  k s|  j
 | k  r"| |  _
 n  | j |  | j d | |  d j |  } | |  j k r|  j   r| |  _ t | d |  j d |  j d t |  j j   n  d  S(	   Ni   (   t   get_terminal_sizei    R   R   R&   R'   t   nl(   t   termuiRl   R8   R)   R(   R   Rk   t   maxRg   t
   BEFORE_BARR5   R   Rb   R9   RK   R   R&   R'   R2   RN   (	   R;   Rl   t   buft	   old_widtht   clutter_lengtht	   new_widtht   clear_widtht   linet   line_len(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR?      s:    						"c         C   s   |  j  | 7_  |  j r6 |  j  |  j k r6 t |  _ n  t j   |  j d k  rS d  St j   |  _ |  j  r t j   |  j |  j  } n t j   |  j } |  j d | g |  _ |  j |  _	 d  S(   Ng      ?i(
   R-   R,   R+   R>   R4   R/   R1   R0   R.   R3   (   R;   t   n_stepst   step(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt	   make_step  s    	c         C   s   |  j  |  |  j   d  S(   N(   Rz   R?   (   R;   Rx   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   update"  s    c         C   s   d |  _  d  |  _ t |  _ d  S(   Ni    (   R3   R   R7   R>   R4   (   R;   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   finish&  s    		c         c   s   |  j  s t d   n  |  j r= x\ |  j D] } | Vq+ WnC x, |  j D]! } | |  _ | V|  j d  qG W|  j   |  j   d S(   s   Return a generator which yields the items added to the bar
        during construction, and updates the progress bar *after* the
        yielded block returns.
        s.   You need to use progress bars in a with block.i   N(   R6   RF   R8   R*   R7   R{   R|   R?   (   R;   t   rv(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyRG   +  s    			
N(   t   __name__t
   __module__R   R>   R2   R=   R@   RE   RH   RJ   RI   RK   RA   t   propertyRQ   RS   RT   R[   R]   R^   Re   Rk   R?   Rz   R{   R|   RG   (    (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR   4   sB   '													'			c         C   s  t    } t t j  s& t |  r6 t | |  |  St j j d d  pN d j	   } | r t
 rs t |  | |  St |  | |  St j j d  d k r t | |  |  St
 s t j j d  r t |  d |  St t d  rt j d	  d
 k rt |  d |  Sd d l } | j   \ } } t j |  zQ t t d  rrt j d j |   d
 k rrt |  d |  St | |  |  SWd t j |  Xd S(   s2   Decide what method to use for paging through text.t   PAGERR   t   TERMt   dumbt   emacst   os2s   more <t   systems   (less) 2>/dev/nulli    t   lessiNs	   more "{}"t   more(   R   R   (   R    R   t   syst   stdint
   _nullpagert   ost   environt   getR   t   stripR	   t   _tempfilepagert
   _pipepagert   platformt
   startswitht   hasattrR   t   tempfilet   mkstempt   closeRV   t   unlink(   RG   R'   t   stdoutt	   pager_cmdR   t   fdt   filename(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   pagerF  s,    	!$-c   
      C   s  d d l  } t t j  } | j d d  d j   } | d k r | d d k r d j t j j d d	  d
 j	 | d   } | s d | d <t
 } q d | k s d | k r t
 } q n  | j | d t
 d | j d | } t | j  } yF x? |  D]7 }	 | st |	  }	 n  | j j |	 j | d   q WWn t t f k
 rPn X| j j   x- t
 ry | j   Wn t k
 rqaXPqaWd S(   sq   Page through text by feeding it to another program.  Invoking a
    pager through this might support colors.
    iNt   /i   i    R   s   {}{}t   LESSR   R   s   -Rt   rt   Rt   shellR   t   envt   replace(   t
   subprocesst   dictR   R   t   rsplitt   splitR   RV   R   Rb   R>   t   Popent   PIPER   R   R   RL   t   encodet   IOErrort   KeyboardInterruptR   t   wait(
   RG   t   cmdR'   R   R   t
   cmd_detailt
   less_flagst   ct   encodingt   text(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR   c  s4    .
	$$
	c         C   s   d d l  } | j   } d j |   } | s< t |  } n  t t j  } t | d  d  } | j | j	 |   Wd QXz t
 j d j | |   Wd t
 j |  Xd S(   s<   Page through text by invoking a program on a temporary file.iNR   t   wbi    s   {} "{}"(   R   t   mktempRb   R   R   R   R   R   RL   R   R   R   RV   R   (   RG   R   R'   R   R   R   R   t   f(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR     s    c         C   s7   x0 | D]( } | s" t  |  } n  |  j |  q Wd S(   s>   Simply print unformatted text.  This is the ultimate fallback.N(   R   RL   (   t   streamRG   R'   R   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR     s    t   Editorc           B   s8   e  Z d d e d  d  Z d   Z d   Z d   Z RS(   s   .txtc         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   editorR   t   require_savet	   extension(   R;   R   R   R   R   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR=     s    			c         C   s   |  j  d  k	 r |  j  Sx* d
 D]" } t j j |  } | r | Sq Wt rM d Sx0 d D]( } t j d j |   d k rT | SqT Wd	 S(   Nt   VISUALt   EDITORt   notepads   sensible-editort   vimt   nanos   which {} >/dev/null 2>&1i    t   vi(   R   R   (   s   sensible-editorR   R   (   R   R   R   R   R   R	   R   RV   (   R;   t   keyR}   R   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt
   get_editor  s    c         C   s   d d  l  } |  j   } |  j rC t j j   } | j |  j  n d  } y[ | j d j	 | |  d | d t
 } | j   } | d k r t d j	 |    n  Wn+ t k
 r } t d j	 | |    n Xd  S(   Nis   {} "{}"R   R   i    s   {}: Editing failed!s   {}: Editing failed: {}(   R   R   R   R   R   t   copyR{   R   R   RV   R>   R   R
   t   OSError(   R;   R   R   R   R   R   t	   exit_codet   e(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt	   edit_file  s    	!c   	      C   s^  d d  l  } | p d } | r; | j d  r; | d 7} n  | j d d d |  j  \ } } z t r d } | j d d  } n d	 } | j |  } t j | d
  } | j	 |  | j
   t j j |  } |  j |  |  j rt j j |  | k rd  St | d  } z | j   } Wd  | j
   X| j d  j d d  SWd  t j |  Xd  S(   NiR   s   
t   prefixs   editor-t   suffixs	   utf-8-sigs   
s   utf-8R   t   rb(   R   t   endswithR   R   R	   R   R   R   t   fdopenRL   R   t   patht   getmtimeR   R   R   t   opent   readt   decodeR   (	   R;   R   R   R   t   nameR   R   t	   timestampR}   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   edit  s0    !
!N(   R~   R   R   R>   R=   R   R   R   (    (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR     s   		c   	      C   sH  d d  l  } d   } t j d k r d g } | rC | j d  n  | rY | j d  n  | j | |    t d d  } z | j | d	 | j   SWd  | j   Xn t r| r | |   }  d
 j	 | |  j
 d d    } n* d j	 | r d n d |  j
 d d   } t j |  St r| r^| |   }  d j	 t j j |   j
 d d   } n* d j	 | rpd n d |  j
 d d   } t j |  Sy` | rt j j | |    pd }  n | |   }  | j d |  g  } | r| j   Sd SWnL t k
 rC|  j d  r?| r?| r?d d  l } | j |   d Sd SXd  S(   Nic         S   sY   y d d  l  } Wn t k
 r/ d d  l  } n X|  j d  rU | j |  d  }  n  |  S(   Nis   file://i   (   t   urllibt   ImportErrorR   t   unquote(   t   urlR   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   _unquote_file  s    t   darwinR   s   -Ws   -Rs	   /dev/nullt   wt   stderrs   explorer /select,"{}"t   "R   s   start {} "" "{}"s   /WAITs   cygstart "{}"s   cygstart {} "{}"s   -wt   .s   xdg-openi    s   http://s   https://i   (   s   http://s   https://(   R   R   R   Rg   R   R   R   R   R	   RV   R   R   R   R   R   t   dirnameR   R   t
   webbrowser(	   R   R   t   locateR   R   t   argst   nullR   R   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   open_url  sP    			$$**!
c         C   sY   |  d k r t     n  |  d k r7 t r7 t    n  |  d k rU t rU t    n  d  S(   Nu   u   u   (   R   R	   t   EOFError(   t   ch(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   _translate_ch_to_exc5  s    c           c   s	   d  Vd  S(   N(    (    (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   raw_terminalA  s    c         C   sN   |  r t  j } n	 t  j } |   } | d k r@ | |   7} n  t |  | S(   Nu    u   à(   u    u   à(   t   msvcrtt   getwchet   getwchR   (   R   t   funcR}   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   getcharE  s    		
c          c   s   t  t j  s* t d  }  |  j   } n t j j   } d  }  yi t j |  } z t j	 |  | VWd  t j
 | t j |  t j j   |  d  k	 r |  j   n  XWn t j k
 r n Xd  S(   Ns   /dev/tty(   R   R   R   R   t   filenoR   t   termiost	   tcgetattrt   ttyt   setrawt	   tcsetattrt	   TCSADRAINR   RN   R   t   error(   R   R   t   old_settings(    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR   u  s     	c         C   sy   t    j } t j | d  } | j t t j  d  } |  ra t t j  ra t j j	 |  n  t
 |  | SWd  QXd  S(   Ni    R   (   R   R   R   R   R   R   R   R   R   RL   R   (   R   R   R   (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyR     s    
(*   t   __doc__t
   contextlibR`   R   R   R/   t   _compatR    R   R   R   R   R   R   R   R   R	   t
   exceptionsR
   t   utilsR   R   Rp   RM   R   t   objectR   R   R   R   R   R   R   R2   R   R   R   t   contextmanagerR   R   R   R   (    (    (    sj   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/click/_termui_impl.pyt   <module>   sP   		 	1		L;		-