
    .iPI                       U d Z ddlmZ ddlmZmZmZmZ ddlZddl	m
Z
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
rdd
lmZ eeef   ee   z  Zded<    ed      Z ed      Zd dZd!d"dZ	 d#	 	 	 	 	 	 	 	 	 d$dZ	 d#	 	 	 	 	 	 	 	 	 d%dZ 	 	 	 	 	 d&	 	 	 	 	 	 	 	 	 	 	 	 	 d'dZ!	 d(	 	 	 	 	 	 	 d)dZ"d*dZ#d+d,dZ$	 	 	 	 d-	 	 	 	 	 	 	 	 	 	 	 	 	 d.dZ%	 	 	 	 	 	 d/dZ& G d de'eef         Z( G d d      Z) G d de)      Z*d0dZ+y)1z
Printing tools.
    )annotations)CallableIterableMappingSequenceN)TYPE_CHECKINGAny	TypeAliasTypeVar)east_asian_width)
get_option)is_sequence)get_console_size)ListLiker
   EscapeChars_KT_VTc           	         |j                  dt              }|j                  dt              }g }|dd D cg c]  }t        t	        ||            | z    }}|j                  t        t	        t        |d                      t        t	        t        |            }t        |      D ]?  \  }	}
 ||
||	   d      }d||	   z  g|t        |
      z
  z  |z   }|j                  |       A t        |dd	i}d
j                  d |D              S c c}w )a  
    Glues together two sets of strings using the amount of space requested.
    The idea is to prettify.

    ----------
    space : int
        number of spaces for padding
    lists : str
        list of str which being joined
    strlen : callable
        function used to calculate the length of each str. Needed for unicode
        handling.
    justfunc : callable
        function used to justify str. Needed for unicode handling.
    strlenjustfuncNleft)mode strictT
c              3  >   K   | ]  }d j                  |        yw) N)join).0liness     X/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/io/formats/printing.py	<genexpr>zadjoin.<locals>.<genexpr>@   s     8RWWU^8s   )	poplen_adj_justifymaxmapappend	enumeratezipr   )spacelistskwargsr   r   newListsxlengthsmaxLenilstnltoJoins                r"   adjoinr7   #   s     ZZ#&Fzz*l3HH49#2J?qs3vq>"U*?G?NN3s3b	*+,S%!FE" 3c71:F3WQZ FSX$56"< ((4(F998888 @s   Dc                    |dk(  r| D cg c]  }|j                  |       c}S |dk(  r| D cg c]  }|j                  |       c}S | D cg c]  }|j                  |       c}S c c}w c c}w c c}w )zB
    Perform ljust, center, rjust against string or list-like
    r   centerljustr9   rjust)textsmax_lenr   r0   s       r"   r&   r&   C   sl     v~*/0Q 00		+01a!11*/0Q 00	 110   A(A-A2c                   t        | t              rd}n#t        | t              rd}nt        | d      rdnd}|du rd}n|xs t	        d      xs t        |       }t        |       }g }d}t        |      D ]1  \  }	}
|	|	|k\  rd	} n#|j                  t        |
|d
z   fd|i|       3 dj                  |      }|r|dz  }n#t        | t              rt        |       d
k(  r|dz  }|j                  |      S )z
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.

    bounds length of printed sequence, depending on options
    z
{{{body}}}zfrozenset({{{body}}})__setitem__z[{body}]z({body})FNmax_seq_itemsT   , , ...,)body)
isinstanceset	frozensethasattrr   r%   iterr*   r)   pprint_thingr   tupleformat)seq	_nest_lvlrB   kwdsfmt	max_itemssrmax_items_reachedr3   itemrG   s               r"   _pprint_seqrY   g   s    #s	C	#%#C7jZ	!LZ%@LCH	S	A
AQ< Y4!Y $	dIMWWRVWX	Y
 99Q<D	C	CHM::4:      c                   d}g }d}|du rt        |       }n|xs t        d      xs t        |       }t        | j                               d| D ]G  \  }}	|j	                  |j                  t        ||dz   fd|i|t        |	|dz   fd|i|             I |t        |       k  r$|j                  dj                  |      d	z   
      S |j                  dj                  |      
      S )zy
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.
    z{{{things}}}z{key}: {val}FrB   NrC   )keyvalrD   rE   )things)r%   r   listitemsr)   rO   rM   r   )
rP   rQ   rB   rR   rS   pairspfmtnitemskvs
             r"   _pprint_dictrf      s     CEDSI*_"=ISSYY[!'6* 
1KK IMWWRVW IMWWRVW  	

 Czz5!1G!;z<<zz5!1z22rZ   c                T   |f	 	 	 	 	 dfd}t        | d      rt        |       S t        | t              r|t	        d      k  rt        | |d|      }|S t        |       r |t	        d      k  rt        | ||||      }|S t        | t              r|rd ||        d}|S  ||       }|S )	a3  
    This function is the sanctioned way of converting objects
    to a string representation and properly handles nested sequences.

    Parameters
    ----------
    thing : anything to be formatted
    _nest_lvl : internal use only. pprint_thing() is mutually-recursive
        with pprint_sequence, this argument is used to keep track of the
        current nesting level, and limit it.
    escape_chars : list[str] or Mapping[str, str], optional
        Characters to escape. If a Mapping is passed the values are the
        replacements
    default_escapes : bool, default False
        Whether the input escape characters replaces or adds to the defaults
    max_seq_items : int or None, default None
        Pass through to other pretty printers to limit sequence printing

    Returns
    -------
    str
    c                    ddddd}t        |t              r0r|j                  |       n|}t        |j	                               }n|xs d}t        |       }|D ]  }|j                  |||         } |S )Nz\tz\nz\rz\')	r   ' )rH   r   updater_   keysstrreplace)thingescape_chars	translateresultcdefault_escapess        r"   as_escaped_stringz'pprint_thing.<locals>.as_escaped_string   s     !UG	lG,  .(	 1 1 34L'-2LU 	5A^^Ay|4F	5rZ   __next__zdisplay.pprint_nest_depthT)quote_stringsrB   rr   ry   rB   rk   )rq   r	   rr   EscapeChars | Nonereturnro   )rK   ro   rH   r   r   rf   r   rY   )rq   rQ   rr   rv   ry   rB   rw   rt   s      `    r"   rM   rM      s    @ 8D"4	$ uj!5z	E7	#	J#5 ) 9D
& M! 
U		J7R,S S %''	
 M 
E3	M&u-.a0 M #5)MrZ   c                <    t        |       }|j                  ||      S N)rM   encode)objectencodingerrorsvalues       r"   pprint_thing_encodedr      s      E<<&))rZ   c                   dt         j                  vry ddlm}  |       }|y |j                  j
                  }d}| r2||vr#ddlm} ddlm	  G fdd|      } |       ||<   d	||   _
        y ||v rd
||   _
        y y )NIPythonr   )get_ipythonz!application/vnd.dataresource+json)BaseFormatter
ObjectNamec                  &    e Zd Z W  d      ZefZy)<enable_data_resource_formatter.<locals>.TableSchemaFormatter_repr_data_resource_N)__name__
__module____qualname__print_methoddict_return_typer   s   r"   TableSchemaFormatterr     s    )*@A $wrZ   r   TF)sysmodulesr   r   display_formatter
formattersIPython.core.formattersr   	traitletsr   enabled)enabler   ipr   mimetyper   r   r   s          @r"   enable_data_resource_formatterr     s    ## 
B	z%%00J2H:%=,'} '
 $8#9Jx '+
8$	Z	',
8$ 
 rZ   c                     t        | dd|      S )N)ri   rj   r   Trz   rM   )rq   rB   s     r"   default_pprintr   #  s    '#	 rZ   c                H  " t               \  }}|t        d      xs d}|t        |       j                  }|r"t	        |      }dd|dz   z   }	dd|dz   z   }
nd}	d}
t	        |       }|rd	dt	        |      z  z   }nd
}t        d      xs |}||kD  }t               "	 	 	 	 	 	 	 	 	 	 	 	 d"fd}d"fd}d}|dk(  rd| }|S |dk(  r|s || d         }d| d| }|S |dk(  r%|s# || d         } || d         }d| d| d| }|S |dk(  rg }| dd D cg c]
  } ||       }}n]||kD  rAt        |dz  d      }| d| D cg c]
  } ||       }}| | d D cg c]
  } ||       }}ng }| D cg c]
  } ||       }}|r|rt        ||      \  }}n|s:t	        dj                  |            |k  rt	        dj                  |            |k  sTt         ||       ||            }|D cg c]  }|j                  |       }}|D cg c]  }|j                  |       }}|r|t	        |
      z
  }|d   }d}t        t        dt	        |      dz               D ]!  }t        ||      }t	        |      |k  s|} n |D cg c]  }t        ||       }}|D cg c]  }t        ||       }}d}|
}|D ]  }||z   dz   }  |||| ||
      \  }} |r||j                         |
z   dz   z  }|
}|dd D ]  }!|!|z   dz   }  |||| ||
      \  }}  ||||d   |dz
  |
      \  }}||z  }d|j                  d      z   }||z  }t	        |      |kD  s|r||	z  }n|dz  }d|t	        |
      d z   }|S c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w )a  
    Return the formatted obj as a unicode string

    Parameters
    ----------
    obj : object
        must be iterable and support __getitem__
    formatter : callable
        string formatter for an element
    is_justify : bool
        should justify the display
    name : name, optional
        defaults to the class name of the obj
    indent_for_name : bool, default True
        Whether subsequent lines should be indented to
        align with the name.
    line_break_each_value : bool, default False
        If True, inserts a line break for each value of ``obj``.
        If False, only break lines when the a line of values gets wider
        than the display width.

    Returns
    -------
    summary string
    Nzdisplay.widthP   r   r   rC      z
 z,
 rF   zdisplay.max_seq_itemsc                    j                  |j                               j                  |j                               z   |k\  r| |j                         z  } |}||z  }| |fS r~   )r%   rstrip)rU   liner   display_widthnext_line_prefixadjs        r"   _extend_linez+format_object_summary.<locals>._extend_linej  sW     774;;=!CGGELLN$;;}LA#D$wrZ   c                2    | rt        fd| D              S y)Nc              3  @   K   | ]  }j                  |        y wr~   r%   )r    r0   r   s     r"   r#   z:format_object_summary.<locals>.best_len.<locals>.<genexpr>u  s     2aswwqz2s   r   )r'   )valuesr   s    r"   best_lenz'format_object_summary.<locals>.best_lens  s    26222rZ   rD   r   z[][]r   
   )rB   r   z...)rU   ro   r   ro   r   ro   r   intr   ro   r|   ztuple[str, str])r   	list[str]r|   r   )r   r   typer   r%   get_adjustmentmin_justifyr   r'   r<   reversedrangerY   r   )#obj	formatter
is_justifynameindent_for_nameline_break_each_valuer   _name_lenspace1space2nseprB   is_truncatedr   r   closesummaryfirstlastheadr0   tail
max_length	max_spacer   rT   	num_itemspprinted_seqr   
head_valueword	tail_itemr   s#                                     @r"   format_object_summaryr   ,  s   B ()M1"?39r|Cy!!t9shl+-.shl+-.CA sSY&67<1M }$L 
C"%69MP	 EAvug,p No 
a-#a&!eWAeW%j Ni 
a-#a&!R!eWBtfAeW-b N_ AD*-bc(3QIaL3D3MQ&+A*-bq'2QIaL2D2*-qbc(3QIaL3D3D*-.QIaL.D. $ &dD1
dDIIdO$}4		$(=8 !$$@
59:
+::59:
+:: !
 &F3IGEI%eAs5zA~&>? 	*5	J|$y0 )I	
 FJJK;JDJEIJK;JDJ 	UJ#c)D($mVTMGT	U t{{}v-55GDcr 	UIs?S(D($mVTMGT	U
 %WdDHma>OQWX4 ell3''5w<=)-BvGsNG F..NY 4 33 / ;:" KJs0   M<NN6N3NNN%Nc                   | |z   }dgt        |d         z  }|D ]D  }|D cg c]  }t        |       }}t        ||d      D cg c]  \  }}t        ||       }}}F | D 	cg c]   }	t        d t        |	|d      D              " }
}	|D 	cg c]   }	t        d t        |	|d      D              " }}	|
|fS c c}w c c}}w c c}	w c c}	w )a  
    Justify items in head and tail, so they are right-aligned when stacked.

    Parameters
    ----------
    head : list-like of list-likes of strings
    tail : list-like of list-likes of strings

    Returns
    -------
    tuple of list of tuples of strings
        Same as head and tail, but items are right aligned when stacked
        vertically.

    Examples
    --------
    >>> _justify([["a", "b"]], [["abc", "abcd"]])
    ([('  a', '   b')], [('abc', 'abcd')])
    r   T)r   c              3  D   K   | ]  \  }}|j                  |        y wr~   r<   r    r0   r>   s      r"   r#   z_justify.<locals>.<genexpr>       S:1gagggS    c              3  D   K   | ]  \  }}|j                  |        y wr~   r   r   s      r"   r#   z_justify.<locals>.<genexpr>  r   r   )r%   r+   r'   rN   )r   r   combinedr   	inner_seqrX   lengthr0   yrP   head_tuplestail_tupless               r"   r   r     s    , d{H s8A;''J R	(12#d)22,/
F4,PQDAqc!QiQ
QR  	SS*T1RSSK   	SS*T1RSSK  ## 3Qs   B;C %%C%Cc                      e Zd ZdZddZy)
PrettyDictz.Dict extension to support abbreviated __repr__c                    t        |       S r~   r   selfs    r"   __repr__zPrettyDict.__repr__  s    D!!rZ   N)r|   ro   )r   r   r   __doc__r   rl   rZ   r"   r   r     s
    8"rZ   r   c                  .    e Zd ZddZddZdd	dZd
dZy)_TextAdjustmentc                $    t        d      | _        y )Nzdisplay.encoding)r   r   r   s    r"   __init__z_TextAdjustment.__init__
  s    "#56rZ   c                    t        |      S r~   r   r   texts     r"   r%   z_TextAdjustment.len  s    4yrZ   c                    |dk(  r|D cg c]  }|j                  |       c}S |dk(  r|D cg c]  }|j                  |       c}S |D cg c]  }|j                  |       c}S c c}w c c}w c c}w )zJ
        Perform ljust, center, rjust against string or list-like
        r   r9   r:   )r   r=   r>   r   r0   s        r"   justifyz_TextAdjustment.justify  sl     6>.34AGGG$44X/45!AHHW%55.34AGGG$44	 554r?   c                N    t        |g|| j                  | j                  d|S )N)r   r   )r7   r%   r   )r   r,   r-   r.   s       r"   r7   z_TextAdjustment.adjoin  s&    eVeVDHHt||VvVVrZ   Nr|   Noner   ro   r|   r   right)r=   r	   r>   r   r   ro   r|   r   )r,   r   r-   r	   r.   r	   r|   ro   )r   r   r   r   r%   r   r7   rl   rZ   r"   r   r   	  s    7	5WrZ   r   c                  B     e Zd Zd fdZddZ	 d	 	 	 	 	 	 	 ddZ xZS )_EastAsianTextAdjustmentc                p    t         |           t        d      rd| _        nd| _        dddddd| _        y )Nz!display.unicode.ambiguous_as_wider   rC   )NaNWFH)superr   r   ambiguous_width_EAW_MAP)r   	__class__s    r"   r   z!_EastAsianTextAdjustment.__init__   s;    9:#$D #$D 
  !qqqqArZ   c                b     t        |t              st        |      S t         fd|D              S )zN
        Calculate display width considering unicode East Asian Width
        c              3  |   K   | ]3  }j                   j                  t        |      j                         5 y wr~   )r  getr   r  )r    ru   r   s     r"   r#   z/_EastAsianTextAdjustment.len.<locals>.<genexpr>3  s3      
MNDMM.q143G3GH
s   9<)rH   ro   r%   sumr   s   ` r"   r%   z_EastAsianTextAdjustment.len,  s3     $$t9 
RV
 
 	
rZ   c                $    d fd}|dk(  r%|D cg c]  }|j                   ||             c}S |dk(  r%|D cg c]  }|j                   ||             c}S |D cg c]  }|j                   ||             c}S c c}w c c}w c c}w )Nc                D    j                  |       z
  t        |       z   S r~   r   )tr>   r   s    r"   _get_padz2_EastAsianTextAdjustment.justify.<locals>._get_pad;  s    TXXa[(3q611rZ   r   r9   )r  ro   r|   r   r:   )r   r=   r>   r   r  r0   s   ` `   r"   r   z _EastAsianTextAdjustment.justify7  s~    	2 6>278QAGGHQK(88X389aAHHXa[)99278QAGGHQK(88	 998s   BB"Br   r   r   r=   zIterable[str]r>   r   r   ro   r|   r   )r   r   r   r   r%   r   __classcell__)r  s   @r"   r   r     s9    
B	
 ?F9"9-098;9	9rZ   r   c                 D    t        d      } | r
t               S t               S )Nz display.unicode.east_asian_width)r   r   r   )use_east_asian_widths    r"   r   r   F  s#    %&HI'))  rZ   )r,   r   r-   r   r.   r	   r|   ro   r   r  )r   N)
rP   r   rQ   r   rB   
int | NonerR   r	   r|   ro   )
rP   r   rQ   r   rB   r  rR   r	   r|   ro   )r   NFFN)rq   r   rQ   r   rr   r{   rv   boolry   r  rB   r  r|   ro   )zutf-8rp   )r   r   r   ro   r   ro   r|   bytes)r   r  r|   r   r~   )rq   r	   rB   r  r|   ro   )TNTF)r   r   r   r   r   r  r   z
str | Noner   r  r   r  r|   ro   )r   list[Sequence[str]]r   r  r|   z3tuple[list[tuple[str, ...]], list[tuple[str, ...]]])r|   r   ),r   
__future__r   collections.abcr   r   r   r   r   typingr   r	   r
   r   unicodedatar   pandas._configr   pandas.core.dtypes.inferencer   pandas.io.formats.consoler   pandas._typingr   ro   r   __annotations__r   r   r7   r&   rY   rf   rM   r   r   r   r   r   r   r   r   r   r   rl   rZ   r"   <module>r      s%   #    ) % 4 6' c*Xc]:Y :enen9@	1J DH%!	%!!%!6@%!QT%!%!R CG3	3 35?3PS33B '+! $III %I 	I
 I I 	IZ <E**!*58*
*-D  "'h	hh h 	h
 h  h 	hV($
($%8($8($V"c3h "W W,$9 $9N!rZ   