
    Fg+                     
   d 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
mZmZ ddlmZ dgZ ej                   e      Zd	 Zd
dd dfdZ ej*                  d      Z ej*                  d      ZdZdZej4                  dfdZy)zI
Module version for monitoring CLI pipes (`... | python -m tqdm | ...`).
    N)literal_eval)indent   )TqdmKeyErrorTqdmTypeErrortqdm)__version__mainc                    t         j                  | |f       d|v r4|j                  d      D ]  }	 t        | |      c S  t	        |  d|       |dk(  r"| dk(  s| dk(  ry| dk(  ryt	        | dz   |z         |d	k(  rat        |       d
k(  r| j                         S t        j                  d|       rt        d|  d      j                         S t	        |  d|       |dk(  r| S |dk(  r	 t        |       S |dk(  r	 t        |       S t	        |  d|       # t        $ r Y w xY w# t        $ r}t	        |  d|       |d }~ww xY w# t        $ r}t	        |  d|       |d }~ww xY w)Nz or z : boolTrue TFalseFchrr   z^\\\w+$"strintfloat)logdebugsplitcastr   lenencoderematchevalr   
ValueErrorr   )valtyptexcs       =/var/www/openai/venv/lib/python3.12/site-packages/tqdm/cli.pyr   r      s   IIsCj}6"AC|# #
 se3se,-- f}6Msby'>C%K#-..
e|s8q=::<88J$!C5
#**,,se3se,--
e|

e|	;s8O g~	;: 3%s3%(
)); ! ,  	;3%s3% 01s:	;
  	;3%s3% 01s:	;sA   D*
D% ;
E 	D"!D"%	E.D??E	E&E!!E&   \n   c                      y N )r   s    r#   <lambda>r)   8   s    d    Tc           	      @   |j                   }|sB	 | j                  |      }|s t        |dd               y ||        |t        |             Ad}t        |      }		 | j                  |      }|sY|rC ||       |r |d|j	                  |      z          n|j                  |      D ]
  }
 ||
         t        |dd               y	 |j                  |      }
|
dk  r||z  }n7 |||d|
t        |      z    z           ||rdn||d|
 z          d}||
|	z   d }S)aZ  
    Params
    ------
    fin  : binary file with `read(buf_size : int)` method
    fout  : binary file with `write` (and optionally `flush`) methods.
    callback  : function(float), e.g.: `tqdm.update`
    callback_len  : If (default: True) do `callback(len(buffer))`.
      Otherwise, do `callback(data) for data in buffer.split(delim)`.
    flushc                       y r'   r(   r(   r*   r#   r)   zposix_pipe.<locals>.<lambda>J   s    tr*   Nr*   r   c                       y r'   r(   r(   r*   r#   r)   zposix_pipe.<locals>.<lambda>a   s    4r*   r   )writereadgetattrr   countr   find)finfoutdelimbuf_sizecallbackcallback_lenfp_writetmpbuf	len_delimis              r#   
posix_piper?   7   s=    zzH((8$C 4g|46SMSX  CE
I
hhx  Q5!112 YYu-  .0GD'<02A1us
S3CJ//0,QS3r7]<Ca)mn%C ! r*   z\n {4}(\S+)\s{2,}:\s*([^,]+)z\s*(?<!\S)--?([^\s=]+)(\s+|=|$))iterableguioutfilea  
    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'.
    tee  : bool, optional
        If true, passes `stdin` to both `stderr` and `stdout`.
    update  : bool, optional
        If true, will treat input as newly elapsed iterations,
        i.e. numbers to pass to `update()`. Note that this is slow
        (~2e5 it/s) since every input must be decoded as a number.
    update_to  : bool, optional
        If true, will treat input as total elapsed iterations,
        i.e. numbers to assign to `self.n`. Note that this is slow
        (~2e5 it/s) since every input must be decoded as a number.
    null  : bool, optional
        If true, will discard input (no stdout).
    manpath  : str, optional
        Directory in which to install tqdm man pages.
    comppath  : str, optional
        Directory in which to place tqdm completion.
    log  : str, optional
        CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET.
c           	          ! t         j                  dd 	 j                  d      }|dz      }t        j                  t        t        |      d       t         j                  dk  rt        j                  nt        t        j                  d	      t        z   }t        t        j!                  |            }t"        D ]  }|j%                  |        t&        j)                  t+        |j-                                      t        j/                  |      }t1        |ddd
   |ddd
   |d
dd
         }	dj3                  d |	D              }d}
|
dz   |j5                  d      z   dz   }t7        fddD              r<t         j8                  j;                  t<        dz          t        j>                  d       nt7        fddD              r8t         j8                  j;                  |dz          t        j>                  d       n5r3d   dd dk7  r(t         j@                  j;                  dd    d|
        tB        j/                  dj3                  dgz               t        t1        ddd
   d
dd
               }t&        j)                  |       |j%                  dd       d i}	 |j-                         D ]*  \  }}|jE                  dd      }	 tG        |||         ||<   , t&        j)                  dtM        |      z          |j%                  d d!      }|j%                  d"d!      }|j%                  d#d!      }tO        |||f      dkD  rtK        d$      	 |j%                  d%d&      }|j%                  d'd(      }|j%                  d)d!      }|j%                  d*d      }|j%                  d+d      }|j%                  d,d!      r G d- d.tP              }nt         j8                  }t        |d/|      }t        t         jR                  d/t         jR                        }|s|rM	 ddl*dd1l.m/} fd2}| |d3 ||      d3z         | |d4 ||      d5z         t        j>                  d       |r6|j:                   t         d/       j:                   G   fd6d.tP              }|ry|ja                  d7d8       |ja                  d9d       |ja                  d:d;       t&        j)                  |       t        dAi |5 !tc        ||d|!jd                         ddd       y|d(k(  ryt&        j)                  |       |j:                  }|s|r:t        dAi |5 !|r!fd<}n!fd=}|D ]  } ||        ||        	 ddd       yt        |fi |D ]
  } ||        yt&        j)                  |       t        dAi |5 !d!}|r!fd>}n|r!fd?}n!jd                  }d}tc        ||||||       ddd       y# t        $ r. D ]#  }|j	                  d      s|t        d      d } n d}Y w xY w# tH        $ r}tK        tM        |            d}~ww xY w# tV        $ r
 dd0l,m- Y Dw xY w# 1 sw Y   yxY w# 1 sw Y   yxY w# 1 sw Y   yxY w# tf        $ rP  j;                  d@|
z          t         jR                  t         j8                  j:                  c} |D ]
  }  |         w xY w)Bz
    Parameters (internal use only)
    ---------
    fp  : file-like object for tqdm
    argv  : list (default: sys.argv[1:])
    Nr   z--logz--log=INFOz/%(levelname)s:%(module)s:%(lineno)d:%(message)s)levelformat)      z    rH      r   c              3      K   | ]F  }|d    t         vr9 |d   dk(  rdndj                  |d    j                  dd      |d    g|dd   H yw)r   r   r   z
  --{0}  : {2}{3}z
  --{0}=<{1}>  : {2}{3}_-N)UNSUPPORTED_OPTSrG   replace).0otds     r#   	<genexpr>zmain.<locals>.<genexpr>   sk      M *CSV;K-K5#a&F*:&,ffV^^C-s1vA8;ABA *s   AAz!Usage:
  tqdm [--help | options]
z^
Options:
  -h, --help     Print this help and exit.
  -v, --version  Print version and exit.

c              3   &   K   | ]  }|v  
 y wr'   r(   rP   vargvs     r#   rR   zmain.<locals>.<genexpr>   s     
21191   )z-vz	--versionr   c              3   &   K   | ]  }|v  
 y wr'   r(   rU   s     r#   rR   zmain.<locals>.<genexpr>   s     1 01Q$Y 0rX   )z-hz--helpz--zError:Unknown argument: r   r   TrC   rM   rL   zargs:bytesFupdate	update_toz1Can only have one of --bytes --update --update_tor7   r%   r6   r$   teemanpathcomppathnullc                       e Zd Zed        Zy)main.<locals>.stdoutc                      y r'   r(   )rL   s    r#   r/   zmain.<locals>.stdout.write   s    r*   N__name__
__module____qualname__staticmethodr/   r(   r*   r#   stdoutrc      s     r*   rj   buffer)	resources)Pathc                     j                  d      | z  }|j                  |j                                t        j	                  d|       y)zcopy resource `name` to `dst`r   z
written:%sN)fileswrite_bytes
read_bytesr   info)namedstfirl   s      r#   cpzmain.<locals>.cp  s6    __V,t30s+r*   ztqdm.1zcompletion.shztqdm_completion.shc                   &    e Zd Ze fd       Zy)rc   c                 |    t        j                        5   |        d d d         |        y # 1 sw Y   xY w)N)rC   )r   external_write_mode)xfpr:   stdout_writes    r#   r/   zmain.<locals>.stdout.write  s-    11r:  ; O ;:s   	2;Nre   )r{   r:   r|   s   r#   rj   zmain.<locals>.stdout  s    $ $r*   unitB
unit_scaleunit_divisori   c                 V    j                  t        | j                                      y r'   r\   numericdecoder>   r!   s    r#   r8   zmain.<locals>.callback,  s    HHWQXXZ%89r*   c                 p    j                  t        | j                               j                  z
         y r'   r\   r   r   nr   s    r#   r8   zmain.<locals>.callback/  s#    HHWQXXZ%8133%>?r*   c                 V    j                  t        | j                                      y r'   r   r   s    r#   r8   zmain.<locals>.callback<  s    !45r*   c                 p    j                  t        | j                               j                  z
         y r'   r   r   s    r#   r8   zmain.<locals>.callback?  s#    !4qss!:;r*   z
Error:
r(   )4sysrW   indexr   
startswithr   loggingbasicConfigr1   version_infor   __doc__r   CLI_EXTRA_DOCdictRE_OPTSfindallrN   popr   r   sorteditemsr   zipjoinstripanyrj   r/   r	   exitstderrRE_SHLEXrO   r   KeyErrorr   r   sumobjectstdinimportlib_resourcesImportError	importlibrl   pathlibrm   
setdefaultr?   r\   	Exception)"r{   rW   log_idxlogLevelr>   d	opt_typesor   opt_types_desc
help_shortopts	tqdm_argsrV   edelim_per_charr\   r]   r7   r6   r^   r_   r`   rj   r   rm   rv   r/   r8   r9   r:   rl   r|   r!   s"   ``                            @@@@r#   r
   r
      sN    |xx|%**W% !$ggx8PR ))G3T\\6*m	<A W__Q'(I a  IIfY__&'( MM!Eqt!teADqDk5A;?N
 M *M 	MA
 7J  	 ggdm		 		A 
21
22

t+,	1 01	1

T"	$q'"1+%

247)2j\JK>>#((F8d?34DDAJQTT
+,DIIdOHHUDIcSjjlFQ		#s#A+#Ay|4	! # 			'C	N*+"w6x/MM+u5		23a7RSS 8 ==S1gv.mmE5)--	40==T2==' 
 ZZFVXv6F		8SYY7h07 %,
 "8T']X56#?DN5I$IJHHQK!<<Lr8R066H$ $ $   -  t4  6IIi "	"a5&"hA #"f_IIi LLE&I&!:@"a  # '& e1y1A!H 2 IIi "	"a$6<  !xxH#'L5&%8\R #"e  A||H%S]^, 
 H~  +"3q6**+B  0//0: #" '& #"U  

*+!ii)9)9|AO s   X 3(Z X<.A5Z +Y! Y7%Z1ZX9"X98X9<	YYYZ !Y43Y47Z ZZA[4)r   r   r   r   astr   r   textwrapr   stdr   r   r   versionr	   __all__	getLoggerrf   r   r   r?   compiler   r   rN   r   r   r
   r(   r*   r#   <module>r      s     	 
 '  2 2  (g!#*L !'*6&t "**4
52::89 6  F JJT hSr*   