
    nd)                         d Z ddlZddlZddl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j        dfdZdS )zI
Module version for monitoring CLI pipes (`... | python -m tqdm | ...`).
    N)literal_eval   )TqdmKeyErrorTqdmTypeErrortqdm)__version__mainc           	      L   t                               | |f           d|v rO|                    d          D ]$}	 t          | |          c S # t          $ r Y !w xY wt	          | dz   |z             |dk    r+| dk    s| dk    rdS | dk    rdS t	          | dz   |z             	 t          |d	z   | z   d
z             S # t          $ r_ |dk    rCt          t          t          d| z   dz                                 	                                cY S t	          | dz   |z             w xY w)Nz or z : boolTrue TFalseFz("z")chr")
logdebugsplitcastr   eval	Exceptionr   ordencode)valtypts      (lib/python3.11/site-packages/tqdm/cli.pyr   r      sx   IIsCj} /6"" 	 	AC||###    C%K#-... f} 36M 	3sby 	34G^ 	35ec 12223C$J$t+,,, 3 3 3%< 	3s4c	C00112299;;;;;ec 1222	3s$   A
AA"B: :AD#D#   \n   c                     d S N )floats    r   <lambda>r#   ,   s    d     Tc           	         |j         }|sX	 |                     |          }|s t          |dd                        dS  ||            |t          |                     Wd}t          |          }		 |                     |          }|sp|rR ||           |r" |d|                    |          z              n#|                    |          D ]}
 ||
            t          |dd                        dS 	 |                    |          }
|
dk     r||z  }nP |||d|
t          |          z            z               ||rdn||d|
         z              d}||
|	z   d         }q)	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)`.
    Tflushc                      d S r    r!   r!   r$   r   r#   zposix_pipe.<locals>.<lambda>>   s    t r$   Nr$   r   c                      d S r    r!   r!   r$   r   r#   zposix_pipe.<locals>.<lambda>U   s    4 r$   r   )writereadgetattrlencountr   find)finfoutdelimbuf_sizecallbackcallback_lenfp_writetmpbuf	len_delimis              r   
posix_piper:   +   s    zH 
		((8$$C  4g||44666HSMMMHSXX		 CE

I&hhx    
	 $ $HQ5!1!112222 YYu-- $ $ 0GD'<<00222F		&A1u s
HS3CJJ//000H,;QQS3rr7]<<<Ca)mnn%C		&!&r$   z\n {8}(\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         	                     d          }|dz            }nE# t          $ r8 D ]0}|                    d          r|t          d          d         } n1d}Y nw xY wt          j        t          t          |          d           t          j
        j        t          z   }t          t                              |                    }t           D ]}|                    |           t$                              t)          |                                                     t                              |          }t/          |ddd         |d	dd         |ddd                   }	d
                    d |	D                       }d}
|
dz   |                    d          z   dz   }t5          fddD                       r<t           j                            t:          dz              t          j        d           nt5          fddD                       r7t           j                            |dz              t          j        d           nAr?d         dd	         dk    r+t           j                            dd          d|
            t@                              d                    dgz                       t          t/          ddd         ddd                             }t$                              |           |                    dd           d i}	 |                                D ]c\  }}|!                    dd          }	 tE          |||                   ||<   6# tF          $ r!}tI          tK          |                    d}~ww xY wt$                              dtK          |          z              |                    dd          }|                    d d          }|                    d!d          }tM          |||f          dk    rtI          d"          	 |                    d#d$          }|                    d%d&          }|                    d'd          }|                    d(d          }|                    d)d          }|                    d*d          r G d+ d,tN                    }nt           j        }t          |d-|          }t          t           j(        d-t           j(                  }|s|rpdd.l)m*  dd/l+m,} dd0l-m.  fd1}|  |d2|                    |d2                     |  |d3|                    |d4                     t          j        d           |r4|j        !t           d-           j         G  !fd5d,tN                    }|r|/                    d6d7           |/                    d8d           |/                    d9d:           t$                              |           t          d@i |5 "ta          ||d
|"j1                   ddd           dS # 1 swxY w Y   dS |d&k    rt$                              |           |j        }|s|rQt          d@i |5 "|r"fd;}n"fd<}|D ]} ||            ||           	 ddd           n# 1 swxY w Y   dS dS t          |fi |D ]} ||           dS t$                              |           t          d@i |5 "d}|r"fd=}n|r"fd>}n	"j1        }d}ta          ||||||           ddd           dS # 1 swxY w Y   dS # td          $ rH                      d?|
z              t           j(        t           j        j        c}!|D ]} !|            w xY w)Az
    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      r   c              3      K   | ]X}|d          t           v |d         dk    rdndj        |d                              dd          |d          g|dd         R  V  YdS )r   r   r   z
  --{0}  : {2}{3}z
  --{0}=<{1}>  : {2}{3}_-N)UNSUPPORTED_OPTSrB   replace).0otds     r   	<genexpr>zmain.<locals>.<genexpr>   s       M M SV;K-KM 5#a&F*: -&&,fV^^C--s1vA8;ABBA A A M M M M M Mr$   z!Usage:
  tqdm [--help | options]
z^
Options:
  -h, --help     Print this help and exit.
  -v, --version  Print version and exit.

c              3       K   | ]}|v V  	d S r    r!   rJ   vargvs     r   rL   zmain.<locals>.<genexpr>   s'      
2
219
2
2
2
2
2
2r$   )z-vz	--versionr   c              3       K   | ]}|v V  	d S r    r!   rO   s     r   rL   zmain.<locals>.<genexpr>   s'      111Q$Y111111r$   )z-hz--helpz--zError:Unknown argument: r   r   Tr>   rG   rF   zargs:bytesFupdate	update_toz1Can only have one of --bytes --update --update_tor2   r   r1   r   teemanpathcomppathnullc                   $    e Zd Zed             ZdS )main.<locals>.stdoutc                     d S r    r!   )rF   s    r   r)   zmain.<locals>.stdout.write   s    Dr$   N__name__
__module____qualname__staticmethodr)   r!   r$   r   stdoutr\      s-            r$   rc   buffer)	resources)path)copyfilec                 L   t          d          r0 t                              d          | z            |           nG                    d|           5 } t          |          |           ddd           n# 1 swxY w Y   t                              d|           dS )zcopy resource `name` to `dst`filesr   Nz
written:%s)hasattrstrri   rf   r   info)namedstsrcrg   re   s      r   cpzmain.<locals>.cp   s    9g.. 0HS!8!84!?@@#FFFF"55 0 S3///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s+++++s   A>>BBztqdm.1zcompletion.shztqdm_completion.shc                   .    e Zd Ze fd            ZdS )r\   c                     t          j                  5   |            d d d            n# 1 swxY w Y    |            d S )N)r>   )r   external_write_mode)xfpr5   stdout_writes    r   r)   zmain.<locals>.stdout.write  s    1r::: $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ LOOOOOs   /33Nr^   )ru   r5   rv   s   r   rc   zmain.<locals>.stdout  sB        $ $ $ $ $ $ $ $ $r$   unitB
unit_scaleunit_divisori   c                 p                         t          |                                                      d S r    rU   numericdecoder9   r   s    r   r3   zmain.<locals>.callback  s+    HHWQXXZZ%8%899999r$   c                                          t          |                                           j        z
             d S r    rU   r}   r~   nr   s    r   r3   zmain.<locals>.callback"  s2    HHWQXXZZ%8%813%>?????r$   c                 p                         t          |                                                      d S r    r|   r   s    r   r3   zmain.<locals>.callback/  s+    !4!455555r$   c                                          t          |                                           j        z
             d S r    r   r   s    r   r3   zmain.<locals>.callback2  s2    !4!4qs!:;;;;;r$   z
Error:
r!   )3sysrQ   index
ValueError
startswithr,   loggingbasicConfigr+   r   __init____doc__CLI_EXTRA_DOCdictRE_OPTSfindallrH   popr   r   sorteditemsr   zipjoinstripanyrc   r)   r   exitstderrRE_SHLEXrI   r   KeyErrorr   rk   sumobjectstdin	importlibre   osrf   shutilrg   
setdefaultr:   rU   r   )#ru   rQ   log_idxlogLevelr9   d	opt_typesor   opt_types_desc
help_shortopts	tqdm_argsrP   edelim_per_charrU   rV   r2   r1   rW   rX   rY   rc   r   rf   rp   r)   r3   r4   rg   r5   re   rv   r   s#   ``                            @@@@@r   r	   r	      sM
     x|%**W%% !$     	 	A||H%% S]]^^, H ggx88PR R R R 	-AW__Q''((I   aIIfY__&&''((( MM!Eqt!teADqDk5A;??N
 M M *M M M 	M 	MA
 7J  	 ggdmm		 		A 
2
2
2
21
2
2
222 L
t+,,,	1111 0111	1	1 L
T"""	 L$q'"1"+% L
J47JJjJJKKK>>#((F8d?3344DDAJQTT
++,,DIIdOOOHHUDIdSjjll 	+ 	+FQ		#s##A+#Ay|44	! + + +"3q66***+		'C	NN*+++"w66x//MM+u55		233a7 	TRSSS	T ==S11gv..mmE5))--	400==T22=='' 	7        
 ZFVXv66F	8SY77 	h 	++++++'''''', , , , , ,  ;8TYYw99::: O?DIIh8L$M$MNNNHQKKK 		$!<Lr8R006H$ $ $ $ $ $ $ $ $ $ $ $  %	S  ---  t444  666IIi   ""	"" Ba5&"hAAAB B B B B B B B B B B B B B B B B Bf_ 	SIIi   LE  &&I&& 	$! @: : : : : :@ @ @ @ @" $ $a $	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ e11y11  AE!HHHH  IIi   ""	"" Sa$ (6 6 6 6 6 6 (< < < < < <  !xH#'L5&%8\RRRS S S S S S S S S S S S S S S S S SW    

*+++!i)9| 	 	ALOOOOsy   A   ?BB
/]> :N]> 
N?N::N??B]> Y((Y,/Y,,)[""[&)[&40]11]58]5>A_)r   r   rer   astr   r}   stdr   r   r   versionr   __all__	getLoggerr_   r   r   r:   compiler   r   rH   r   r   r	   r!   r$   r   <module>r      s#     				 



 ' ' ' ' ' ' 2 2 2 2 2 2 2 2 2 2            (g!!3 3 36 !'**6& 6& 6& 6&t "*4
5
52:899 6  F JT gS gS gS gS gS gSr$   