ó
`aŠ]c           @   s·   d  d l  m Z m Z m Z d  d l m Z d d l Z d d l Z d d l Z d g Z	 d „  Z
 d d d	 „  d
 „ Z e j d ƒ Z e j d ƒ Z d Z d Z e j d d „ Z d S(   i   (   t   tqdmt   TqdmTypeErrort   TqdmKeyError(   t   __version__iÿÿÿÿNt   mainc         C   s9  t  j t ƒ } | j |  | f ƒ d | k r„ x< | j d ƒ D]+ } y t |  | ƒ SWq> t k
 rh q> Xq> Wt |  d | ƒ ‚ n  | d k rÓ |  d k s¨ |  d k r¬ t S|  d k r¼ t St |  d | ƒ ‚ n  y t	 | d |  d ƒ SWnE | d	 k rt
 t t	 d
 |  d
 ƒ ƒ ƒ St |  d | ƒ ‚ n Xd  S(   Ns    or s    : t   boolt   Truet    t   Falses   ("s   ")t   chrt   "(   t   loggingt	   getLoggert   __name__t   debugt   splitt   castR   R   R   t   evalR	   t   ord(   t   valt   typt   logt   t(    (    s'   lib/python2.7/site-packages/tqdm/cli.pyR   	   s*    s   
i   c         C   s   d  S(   N(   t   None(   t   int(    (    s'   lib/python2.7/site-packages/tqdm/cli.pyt   <lambda>&   R   c   	      C   sW  | j  } | sh xV t rd |  j | ƒ } | sG t | d d „  ƒ ƒ  d S| | ƒ | t | ƒ ƒ q Wn  d } xâ t rR|  j | ƒ } | sÐ | r¶ | | ƒ | d | j | ƒ ƒ n  t | d d „  ƒ ƒ  d Sx| t rNy | j | ƒ } Wn t k
 r
| | 7} PqÓ X| | | | t | ƒ  ƒ | d ƒ d } | | t | ƒ } qÓ Wqq Wd S(   sÁ   
    Params
    ------
    fin  : file with `read(buf_size : int)` method
    fout  : file with `write` (and optionally `flush`) methods.
    callback  : function(int), e.g.: `tqdm.update`
    t   flushc           S   s   d  S(   N(   R   (    (    (    s'   lib/python2.7/site-packages/tqdm/cli.pyR   8   R   NR   i   c           S   s   d  S(   N(   R   (    (    (    s'   lib/python2.7/site-packages/tqdm/cli.pyR   I   R   (   t   writeR   t   readt   getattrt   lent   countt   indext
   ValueError(	   t   fint   foutt   delimt   buf_sizet   callbackt   fp_writet   tmpt   buft   i(    (    s'   lib/python2.7/site-packages/tqdm/cli.pyt
   posix_pipe%   s8    
		
	
	

s   \n {8}(\S+)\s{2,}:\s*([^,]+)s   \s*(?<!\S)--?([^\s=]+)(\s+|=|$)t   iterablet   guit   outt   files%  
        Extra CLI Options
        -----------------
        name  : type, optional
            TODO: find out why this is needed.
        delim  : chr, optional
            Delimiting character [default: '\n']. Use '\0' for null.
            N.B.: on Windows systems, Python converts '\n' to '\r\n'.
        buf_size  : int, optional
            String buffer size in bytes [default: 256]
            used when `delim` is specified.
        bytes  : bool, optional
            If true, will count bytes, ignore `delim`, and default
            `unit_scale` to True, `unit_divisor` to 1024, and `unit` to 'B'.
        manpath  : str, optional
            Directory in which to install tqdm man pages.
        log  : str, optional
            CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET.
c      
      sF  ˆ  d k r t j d ‰  n  y ˆ  j d ƒ } WnK t k
 r| xI ˆ  D]) } | j d ƒ rF | t d ƒ } PqF qF Wd } n Xˆ  | d } t j d t	 t | ƒ d d ƒ t j
 t ƒ } t j j t } t t j | ƒ ƒ } x t D] } | j | ƒ qå W| j t | j ƒ  ƒ ƒ t j | ƒ } t | d d d	 … | d
 d d	 … | d	 d d	 … ƒ }	 d j d „  |	 Dƒ ƒ } d | j d ƒ d } t ‡  f d †  d. Dƒ ƒ rÍt j j t d ƒ t j  d ƒ n@ t ‡  f d †  d/ Dƒ ƒ rt j j | d ƒ t j  d ƒ n  t! j d j d g ˆ  ƒ ƒ ‰  t t ˆ  d d d	 … ˆ  d	 d d	 … ƒ ƒ }
 | j |
 ƒ |
 j d t" ƒ i |  d 6} y{ x] |
 j ƒ  D]O \ } } y t# | | | ƒ | | <Wq•t$ k
 rã} t% t& | ƒ ƒ ‚ q•Xq•W| j d t& | ƒ ƒ Wn; |  j d ƒ x! t j' D] } t j j | ƒ qW‚  nX| j d d ƒ } | j d d ƒ } | j d t( ƒ } | j d  d ƒ } t	 t j' d! t j' ƒ } t	 t j d! t j ƒ } | d k	 rPd" d# l) m* } d" d$ l+ m, } d" d% l- m. } m/ } | | j0 d ƒ d& ƒ } | j | d' ƒ } | | | ƒ | j1 d( | ƒ t j  d ƒ n  | rÄ| j2 d) d* ƒ | j2 d+ t" ƒ | j2 d, d- ƒ | j | ƒ t |     } t3 | | d | | j4 ƒ Wd QXn~ | d k r| j | ƒ xb t | |  D] } | j | ƒ qíWn; | j | ƒ t |     } t3 | | | | | j4 ƒ Wd QXd S(0   sƒ   
    Parameters (internal use only)
    ---------
    fp  : file-like object for tqdm
    argv  : list (default: sys.argv[1:])
    i   s   --logs   --log=t   INFOt   levelt   formats/   %(levelname)s:%(module)s:%(lineno)d:%(message)sNi   i   R   c         s   s.   |  ]$ } | d  t  k r d j | Œ  Vq d S(   i    s   
  --{0}=<{0}>  : {1}{2}N(   t   UNSUPPORTED_OPTSR2   (   t   .0t   otd(    (    s'   lib/python2.7/site-packages/tqdm/cli.pys	   <genexpr>Ÿ   s   s~   Usage:
  tqdm [--help | options]

Options:
  -h, --help     Print this help and exit
  -v, --version  Print version and exit

s   
c         3   s   |  ] } | ˆ  k Vq d  S(   N(    (   R4   t   v(   t   argv(    s'   lib/python2.7/site-packages/tqdm/cli.pys	   <genexpr>¬   s    s   -vs	   --versioni    c         3   s   |  ] } | ˆ  k Vq d  S(   N(    (   R4   R6   (   R7   (    s'   lib/python2.7/site-packages/tqdm/cli.pys	   <genexpr>¯   s    s   -hs   --helpt    R    R   R/   s   args:s)   
Error:
Usage:
  tqdm [--help | options]
R%   i   R$   t   bytest   manpatht   bufferiÿÿÿÿ(   t   path(   t   copyfile(   t   resource_filenamet   Requirements   tqdm/tqdm.1s   tqdm.1s   written:t   unitt   Bt
   unit_scalet   unit_divisori   (   s   -vs	   --version(   s   -hs   --help(5   R   t   sysR7   R    R!   t
   startswithR   R   t   basicConfigR   R   R   R    t   __init__t   __doc__t   CLI_EXTRA_DOCt   dictt   RE_OPTSt   findallR3   t   popR   t   sortedt   itemsR   t   zipt   joint   stript   anyt   stdoutR   R   t   exitt   RE_SHLEXR   R   t   KeyErrorR   t   strt   stdinR   t   osR<   t   shutilR=   t   pkg_resourcesR>   R?   t   parset   infot
   setdefaultR+   t   update(   t   fpR7   R   R*   t   logLevelt   dt	   opt_typest   oR   t   opt_types_desct   optst	   tqdm_argsR6   t   eR%   R$   t   delim_per_charR:   RY   RT   R<   R=   R>   R?   t   fit   foR   (    (   R7   s'   lib/python2.7/site-packages/tqdm/cli.pyR   w   sš    
	9	/"(   R,   R-   R.   R/   (   t   stdR    R   R   t   _versionR   RD   t   reR   t   __all__R   R+   t   compileRK   RV   R3   RI   t   stderrR   R   (    (    (    s'   lib/python2.7/site-packages/tqdm/cli.pyt   <module>   s   		4