
    0Rj&                     b   d Z ddlZddlZddlZddlmZmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ eeeef\  ZZZZej.                  Z ed d	D              Z ed
 dD              Z ej8                  d      Z	 erddlZne	 	  ej@                  d       d&dZ"	 ddl"m"Z"  G d d      Z$ G d d      Z% G d d      Z& G d de&      Z' G d de&      Z( G d de&      Z)d Z*d Z+d Z,d  Z-d! Z.d" Z/d# Z0d$ Z1d% Z2y# e!$ r  ej@                          Y ~w xY w# e$ r dZY w xY w# e#$ r Y w xY w)'z*
General helpers required for `tqdm.std`.
    N)partialpartialmethodwraps)	signatureeast_asian_width)warnproxyc              #   F   K   | ]  }t         j                  |        y wNCUR_OS
startswith.0is     R/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/tqdm/utils.py	<genexpr>r      s     ?aVq!?   !)win32cygwinc              #   F   K   | ]  }t         j                  |        y wr   r   r   s     r   r   r      s     QaVq!Qr   )aixlinuxdarwinfreebsdz\x1b\[[;\d]*[A-Za-z]F)stripc                 X  	 i | d   dk(  r| dd } t        dt        d       |r	| |  d| fn| f}i |D ]W  		j                         dz   	t        	      j	                  	fdt
        j                  j                         D               Y |rt        nt        fd}|S )	z
    Basic (env-only) version of [envwrap](https://github.com/tqdm/envwrap).
    Install `envwrap` for config file support.
    N_z*Trailing underscore in `name` is automatic   
stacklevelc              3   r   K   | ].  \  }}|j                        s|d  j                         |f 0 y wr   )r   lower)r   kvr   prefixs      r   r   zenvwrap.<locals>.<genexpr>1   s8      W#'1afAUQqrU[[]AWs   77c                    t        |       j                  }j                         D ci c]  \  }}||v s|| }}}|D ]  }||   }|j                  |j                  ur8t        |j                  d|j                  f      D ]  }	  |||         ||<    V X|j                  " t        |j                        ||         ||<   	  	|   ||         ||<     | fi |S c c}}w # t        $ r Y rw xY w# t        $ r Y w xY w)N__args__)
r   
parametersitems
annotationemptygetattr	ExceptiondefaulttypeKeyError)
funcparamsr'   r(   	overridesparamtypenv_overridesparttypess
          r   wrapzenvwrap.<locals>.wrap5   s.   4++&3&9&9&;KdaqF{QTK	K 	A1IEu{{2"5#3#3Z%BRBRATU C'*9Q<'8	!  *2tEMM29Q<@	!#+58IaL#9IaL	" D&I&&' L %    s.   C$C$C*C9*	C65C69	DD)
r	   DeprecationWarningupperlenupdateosenvironr-   r   r   )
nameappr<   	is_methodprefixesr=   r:   r   r;   r)   s
     `   @@@@r   envwraprH   "   s    
 }Bx3CRy9;MZ[\*-auo&D7HM W#%K W+-::+;+;+=W 	WW
 &=7D'. K    )rH   c                       e Zd ZdZddZd Zy)FormatReplacezN
    >>> a = FormatReplace('something')
    >>> f"{a:5d}"
    'something'
    c                      || _         d| _        y Nr   )replaceformat_called)selfrN   s     r   __init__zFormatReplace.__init__[   s    rI   c                 D    | xj                   dz  c_         | j                  S )N   )rO   rN   )rP   r!   s     r   
__format__zFormatReplace.__format___   s    a||rI   N) )__name__
__module____qualname____doc__rQ   rT    rI   r   rK   rK   U   s    
rI   rK   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	
Comparablez1Assumes child has self._comparable attr/@propertyc                 4    | j                   |j                   k  S r   _comparablerP   others     r   __lt__zComparable.__lt__f   s    %"3"333rI   c                     | |k  xs | |k(  S r   rZ   r`   s     r   __le__zComparable.__le__i   s    u0$%-0rI   c                 4    | j                   |j                   k(  S r   r^   r`   s     r   __eq__zComparable.__eq__l   s    5#4#444rI   c                     | |k(   S r   rZ   r`   s     r   __ne__zComparable.__ne__o       5=  rI   c                     | |k   S r   rZ   r`   s     r   __gt__zComparable.__gt__r   ri   rI   c                     | |k   S r   rZ   r`   s     r   __ge__zComparable.__ge__u   s    %<rI   N)
rV   rW   rX   rY   rb   rd   rf   rh   rk   rm   rZ   rI   r   r\   r\   d   s#    ;415!! rI   r\   c                   *    e Zd Zd Zd Zd Zd Zd Zy)ObjectWrapperc                 .    t        | j                  |      S r   )r0   _wrappedrP   rD   s     r   __getattr__zObjectWrapper.__getattr__z   s    t}}d++rI   c                 0    t        | j                  ||      S r   )setattrrq   rP   rD   values      r   __setattr__zObjectWrapper.__setattr__}   s    t}}dE22rI   c                 f    	 t         j                  | |      S # t        $ r t        | |      cY S w xY w)z7Actual `self.getattr` rather than self._wrapped.getattr)objectrs   AttributeErrorr0   rr   s     r   wrapper_getattrzObjectWrapper.wrapper_getattr   s6    	'%%dD11 	'4&&	's    00c                 0    t         j                  | ||      S )z7Actual `self.setattr` rather than self._wrapped.setattr)rz   rx   rv   s      r   wrapper_setattrzObjectWrapper.wrapper_setattr   s    !!$e44rI   c                 (    | j                  d|       y)z4
        Thin wrapper around a given object
        rq   N)r~   )rP   wrappeds     r   rQ   zObjectWrapper.__init__   s     	Z1rI   N)rV   rW   rX   rs   rx   r|   r~   rQ   rZ   rI   r   ro   ro   y   s    ,3'52rI   ro   c                   .     e Zd ZdZ fdZd Zd Z xZS )SimpleTextIOWrapperz
    Change only `.write()` of the wrapped object by encoding the passed
    value and passing the result to the wrapped object's `.write()` method.
    c                 H    t         |   |       | j                  d|       y )Nencoding)superrQ   r~   )rP   r   r   	__class__s      r   rQ   zSimpleTextIOWrapper.__init__   s     !Z2rI   c                 t    | j                   j                  |j                  | j                  d                  S )zP
        Encode `s` and pass to the wrapped object's `.write()` method.
        r   )rq   writeencoder|   )rP   ss     r   r   zSimpleTextIOWrapper.write   s-     }}""188D,@,@,L#MNNrI   c                 6    | j                   t        |d|      k(  S Nrq   rq   r0   r`   s     r   rf   zSimpleTextIOWrapper.__eq__       }}z5 AAArI   )rV   rW   rX   rY   rQ   r   rf   __classcell__r   s   @r   r   r      s    
3OBrI   r   c                   8     e Zd ZdZed        Z fdZd Z xZS )DisableOnWriteErrorzO
    Disable the given `tqdm_instance` upon `write()` or `flush()` errors.
    c                 ,     t                 fd}|S )zV
        Quietly set `tqdm_instance.miniters=inf` if `func` raises `errno=5`.
        c                  8   	  | i |S # t         $ r@}|j                  dk7  r 	 t        d      _        n# t        $ r Y nw xY wY d }~y Y d }~y d }~wt
        $ r>}dt        |      vr 	 t        d      _        n# t        $ r Y nw xY wY d }~y Y d }~y d }~ww xY w)N   infclosed)OSErrorerrnofloatminitersReferenceError
ValueErrorstr)argskwargser5   tqdm_instances      r   innerz7DisableOnWriteError.disable_on_exception.<locals>.inner   s    T,V,, 77a<-25\M*%  +  3q6)-25\M*%  +	sc    	BA6A	AAAABB*A;:B;	BBBBBr
   )r   r5   r   s   `` r   disable_on_exceptionz(DisableOnWriteError.disable_on_exception   s    
 m,	" rI   c                    t         |   |       t        |d      r,| j                  d| j	                  ||j
                               t        |d      r-| j                  d| j	                  ||j                               y y )Nr   flush)r   rQ   hasattrr~   r   r   r   )rP   r   r   r   s      r   rQ   zDisableOnWriteError.__init__   ss    !7G$  22='--PR7G$  22='--PR %rI   c                 6    | j                   t        |d|      k(  S r   r   r`   s     r   rf   zDisableOnWriteError.__eq__   r   rI   )	rV   rW   rX   rY   staticmethodr   rQ   rf   r   r   s   @r   r   r      s(      2RBrI   r   c                         e Zd Zd fd	Z xZS )CallbackIOWrapperc                    t         |   |       t        ||      |dk(  r't              fd       }| j	                  d|       y|dk(  r't              fd       }| j	                  d|       yt        d      )z{
        Wrap a given `file`-like object's `read()` or `write()` to report
        lengths to the given `callback`
        r   c                 B     | g|i |} t        |              |S r   r@   )datar   r   rescallbackr5   s       r   r   z)CallbackIOWrapper.__init__.<locals>.write   s(    41$1&1T#
rI   readc                  :     | i |} t        |             |S r   r   )r   r   r   r   r5   s      r   r   z(CallbackIOWrapper.__init__.<locals>.read   s#    T,V,T#rI   z Can only wrap read/write methodsN)r   rQ   r0   r   r~   r4   )rP   r   streammethodr   r   r5   r   s    `    @r   rQ   zCallbackIOWrapper.__init__   s    
 	 vv&W4[    %0v4[    .=>>rI   )r   )rV   rW   rX   rQ   r   r   s   @r   r   r      s    ? ?rI   r   c                     	 dj                  |        y# t        $ r Y yt        $ r: 	 | j                         j	                  d      xs d| k(  cY S # t        $ r Y Y yw xY ww xY w)Nu   █▉TFzutf-U8)r   UnicodeEncodeErrorr1   r&   r   )r   s    r   _is_utfr      so    
h'    	>>#..v6L48;KL 		s1    	A!A!%AA!	AA!AA!c                 L    	 t        | j                        S # t        $ r Y yw xY w)NF)r   r   r{   )fps    r   _supports_unicoder      s(    r{{## s    	##c                 h    t        | t              r| D ]  }t        |      dkD  s y yt        |       S )N   FT)
isinstancer   ordr   )r   cs     r   	_is_asciir      s9    !S 	A1v|	 QrI   c                      d } | S )zy
    Return a function which returns console dimensions (width, height).
    Supported: linux, osx, windows, cygwin.
    c                 z    	 ddl m}  | t        | dd                    \  }}|dz
  |dz
  fS # t        $ r Y yw xY w)Nr   )get_terminal_sizefilenoc                       y r   rZ   rZ   rI   r   <lambda>z6_screen_shape_wrapper.<locals>.inner.<locals>.<lambda>  s    rI   rS   )NN)rB   r   r0   r1   )r   r   colsliness       r   r   z$_screen_shape_wrapper.<locals>.inner  sL    	,+,OGB,,O,QRKD%!8UQY&& 		s   +. 	::rZ   )r   s    r   _screen_shape_wrapperr   	  s    
 LrI   c                  l    t        dt        d       t               syt              fd       } | S )zd
    Return a function which returns console width.
    Supported: linux, osx, windows, cygwin.
    zQUse `_screen_shape_wrapper()(file)[0]` instead of `_environ_cols_wrapper()(file)`r"   r#   Nc                      |       d   S rM   rZ   )r   shapes    r   r   z$_environ_cols_wrapper.<locals>.inner$  s    Ry|rI   )r	   r>   r   r   )r   r   s    @r   _environ_cols_wrapperr     sC    
 	 
,-?AO!#E
5\  LrI   c                  <    t         j                  dk(  rt        dS dS )NntrU   z[A)rB   rD   coloramarZ   rI   r   _term_move_upr   +  s    ''T/(82GxGrI   c                 8    t        d t        |       D              S )Nc              3   >   K   | ]  }t        |      d v rdnd  yw)FWr"   rS   Nr   )r   chs     r   r   z_text_width.<locals>.<genexpr>0  s"     IB$R(D0qa7Is   )sumr   )r   s    r   _text_widthr   /  s    I#a&IIIrI   c                 @    t        t        j                  d|             S )zp
    Returns the real on-screen length of a string which may contain
    ANSI control codes and wide chars.
    rU   )r   RE_ANSIsub)r   s    r   disp_lenr   3  s    
 w{{2t,--rI   c                 .   t        |       t        |       k(  r| d| S t        t        j	                  |             }t        |       |kD  r| dd } t        |       |kD  r|r6t        t        j	                  |             r| j                  d      r| S | dz   S | S )zB
    Trim a string which may contain ANSI control characters.
    Nr    z[0m)r@   r   boolr   searchendswith)r   lengthansi_presents      r   	disp_trimr   ;  s     4yHTN"GV}t,-L
4.6
!CRy 4.6
!W^^D12}}Y/tETI5EEKrI   )rU   NF)3rY   rB   resys	functoolsr   r   r   inspectr   unicodedatar   warningsr	   weakrefr   rangechrr   _range_unich_unicode_basestringplatformr   anyIS_WINIS_NIXcompiler   r   ImportErrorinit	TypeErrorrH   ModuleNotFoundErrorrK   r\   ro   r   r   r   r   r   r   r   r   r   r   r   r   rZ   rI   r   <module>r      sm   
 	 
 3 3  (  (-sC(< %+		?+>?	?	Q+PQ	Q
"**,
- 	E"
*Z	
    *2 22B- B((B- (BV? ?4  $HJ.{    Hp  		s6   9	D C= D& =DDD#"D#&D.-D.