o
    dp=                     @  s&  d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZmZ ddlmZ ddlmZ ee	eef ee f ZedZedZdKddZdLdMddZ	dNdOddZ	dNdPd d!Z			"	"	dQdRd*d+Z	-dSdTd1d2ZdUd5d6ZdVdWd7d8Z	9		9	"dXdYdAdBZdZdGdHZG dIdJ dJeeef ZdS )[z
Printing tools.
    )annotationsN)AnyCallableDictIterableMappingSequenceTypeVarUnion)
get_option)is_sequence_KT_VTspaceintlists	list[str]returnstrc                   s   | dt| dt}g }g } fdd|dd D }|ttt|d  ttt|}t|D ]!\}}	||	|| dd}
d	||  g|t|	  |
 }
||
 q5t| }|D ]
}|d
| q]d|S )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justfuncc                   s   g | ]}t t|  qS  )maxmap.0xr   r   r   _/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/io/formats/printing.py
<listcomp>0   s    zadjoin.<locals>.<listcomp>Nleft)mode  
)	poplenjustifyappendr   r   	enumeratezipjoin)r   r   kwargsr   	out_linesnewListslengthsmaxLenilstnltoJoinlinesr   r   r   adjoin   s   
r7   righttextsIterable[str]max_lenr"   c                   sF   |dkr fdd| D S |dkr fdd| D S  fdd| D S )zB
    Perform ljust, center, rjust against string or list-like
    r!   c                      g | ]}|  qS r   )ljustr   r;   r   r   r   C       zjustify.<locals>.<listcomp>centerc                   r<   r   )r@   r   r>   r   r   r   E   r?   c                   r<   r   rjustr   r>   r   r   r   G   r?   r   )r9   r;   r"   r   r>   r   r(   >   s
   r(   seqr   	_nest_lvlmax_seq_items
int | Nonec                   s   t | trd}n	t| drdnd}du rt| }n
p#tdp#t| }t|  fddtt|t| D }d	|}|t| k rK|d
7 }nt | t	rZt| dkrZ|d7 }|j
|d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}}}__setitem__z[{body}]z({body})FrE   c                   s*   g | ]}t t d  fdiqS )   rE   )pprint_thingnext)r   r2   rD   kwdsrE   sr   r   r   w   s    z_pprint_seq.<locals>.<listcomp>, , ...rH   ,)body)
isinstancesethasattrr'   r   iterrangeminr,   tupleformat)rC   rD   rE   rL   fmtnitemsrrQ   r   rK   r   _pprint_seqb   s    
	


r]   r   c           
   	   K  s   d}g }d}|du rt | }n
|ptdpt | }t|  d| D ]$\}}	||jt||d fd|i|t|	|d fd|i|d q#|t | k rY|jd|d	 d
S |jd|d
S )zy
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.
    z{{{things}}}z{key}: {val}FrE   NrH   )keyvalrN   rO   )things)r'   r   listitemsr)   rY   rI   r,   )
rC   rD   rE   rL   rZ   pairspfmtr[   kvr   r   r   _pprint_dict   s    
rg   Fthingr   escape_charsEscapeChars | Nonedefault_escapesboolquote_stringsc                   s   |fd fdd}t | d	rt| S t| tr'|td
k r't| |d|d}|S t| r<|td
k r<t| ||||d}|S t| trM|rMd||  d}|S || }|S )a  
    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 or dict, optional
        Characters to escape. If a dict 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
    rh   r   ri   rj   r   r   c                   sf   dddd}t |tr r|| n|}t| }n|pd}t| }|D ]
}|||| }q&|S )Nz\tz\nz\r)	r%   r   )rR   dictupdatera   keysr   replace)rh   ri   	translateresultcrk   r   r   as_escaped_string   s   
z'pprint_thing.<locals>.as_escaped_string__next__zdisplay.pprint_nest_depthT)rm   rE   ri   rm   rE   'N)rh   r   ri   rj   r   r   )rT   r   rR   rp   r   rg   r   r]   )rh   rD   ri   rk   rm   rE   rx   ru   r   rw   r   rI      s2    
rI   utf-8rs   encodingerrorsbytesc                 C  s   t | }|||S N)rI   encode)objectr}   r~   valuer   r   r   pprint_thing_encoded   s   r   enableNonec                   s   dt jvrd S ddlm} | }|d u rd S |jj}d}| rD||vr=ddlm} ddlm	  G  fddd|}| ||< d	|| _
d S ||v rOd
|| _
d S d S )NIPythonr   )get_ipythonz!application/vnd.dataresource+json)BaseFormatter
ObjectNamec                      s   e Zd Z dZefZdS )z<enable_data_resource_formatter.<locals>.TableSchemaFormatter_repr_data_resource_N)__name__
__module____qualname__print_methodrp   _return_typer   r   r   r   TableSchemaFormatter  s    
r   TF)sysmodulesr   r   display_formatter
formattersIPython.core.formattersr   	traitletsr   enabled)r   r   ipr   mimetyper   r   r   r   r   enable_data_resource_formatter   s$   

r   c                 C  s   t | dd|dS )N)rn   ro   r%   Trz   rI   )rh   rE   r   r   r   default_pprint  s   r   T	formatterr   
is_justifyname
str | Noneindent_for_nameline_break_each_valuec                    s  ddl m} ddlm} | \}}	|du rtdpd}|du r$t| j}|r=t|}
dd|
d	   }dd|
d
   }nd}d}t| }|rPddt|  }nd}tdpW|}||k}|  d0 fdd}d1 fdd}d}|dkrzd| }|S |d	kr|s| d }d | d!| }|S |d
kr|s| d }| d" }d | d| d!| }|S |d	krg }fd#d$| d"d D }n2||krt|d
 d%}fd&d$| d| D }fd'd$| | d D }ng }fd(d$| D }|r5|rt	||\}}n2|std
||k rtd
||k s5t||||fd)d$|D }fd*d$|D }|rr|t| }|d }ttd	t|d	 D ]$t|d+}t||k rpfd,d$|D }fd-d$|D } nqMd.}|}|D ]}|| d }||||||\}}qx|r|| | d/ 7 }|}|dd" D ]}|| d }||||||\}}q||||d" |d
 |\}}||7 }d!|d }||7 }t||ks|r||7 }n|d7 }d |t|d  }|S )2a  
    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
    r   )get_console_size)get_adjustmentNzdisplay.widthP   r%   r#   rH      z
 z,
 rP   zdisplay.max_seq_itemsrM   r   liner   display_widthr   next_line_prefixr   tuple[str, str]c                   s@     |   |  |kr| | 7 } |}||7 }| |fS r   )r'   rstrip)rM   r   r   r   r   adjr   r   _extend_line`  s
    z+format_object_summary.<locals>._extend_linevaluesr   c                   s   | rt  fdd| D S dS )Nc                 3  s    | ]}  |V  qd S r   r'   r   r   r   r   	<genexpr>k  s    z:format_object_summary.<locals>.best_len.<locals>.<genexpr>r   r   )r   r   r   r   best_leni  s   z'format_object_summary.<locals>.best_lenrN   z[][]r    c                      g | ]} |qS r   r   r   r   r   r   r   ~      z)format_object_summary.<locals>.<listcomp>
   c                   r   r   r   r   r   r   r   r     r   c                   r   r   r   r   r   r   r   r     r   c                   r   r   r   r   r   r   r   r     r   c                   r<   r   rA   r   
max_lengthr   r   r     r?   c                   r<   r   rA   r   r   r   r   r     r?   rE   c                      g | ]}t | d qS r   r]   r   	max_itemsr   r   r         c                   r   r   r   r   r   r   r   r     r   r$   z...)rM   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )pandas.io.formats.consoler   pandas.io.formats.formatr   r   typer   r'   rW   _justifyr,   r   reversedrV   r]   r   ) objr   r   r   r   r   r   r   r   _name_lenspace1space2nseprE   is_truncatedr   r   closesummaryfirstlastheadtail	max_spacer   pprinted_seqr   
head_valueword	tail_itemr   )r   r   r   r   r   format_object_summary  s   !

	
VSO
r   r   list[Sequence[str]]r   3tuple[list[tuple[str, ...]], list[tuple[str, ...]]]c                   sr   | | }dgt |d   |D ]}dd |D }dd t |D  q fdd| D } fdd|D }||fS )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   c                 S  s   g | ]}t |qS r   r   )r   itemr   r   r   r     r   z_justify.<locals>.<listcomp>c                 S  s   g | ]	\}}t ||qS r   r   )r   r   yr   r   r   r     s    c                   $   g | ]}t d d t| D qS )c                 s      | ]
\}}| |V  qd S r   rA   r   r   r;   r   r   r   r         &_justify.<locals>.<listcomp>.<genexpr>rX   r+   r   rC   r   r   r   r         c                   r   )c                 s  r   r   rA   r   r   r   r   r     r   r   r   r   r   r   r   r     r   )r'   r+   )r   r   combined	inner_seqlengthhead_tuplestail_tuplesr   r   r   r     s   

r   c                   @  s   e Zd ZdZdddZdS )
PrettyDictz.Dict extension to support abbreviated __repr__r   r   c                 C  s   t | S r   r   )selfr   r   r   __repr__  s   zPrettyDict.__repr__N)r   r   )r   r   r   __doc__r   r   r   r   r   r     s    r   )r   r   r   r   r   r   )r8   )r9   r:   r;   r   r"   r   r   r   )r   N)rC   r   rD   r   rE   rF   r   r   )rC   r   rD   r   rE   rF   r   r   )r   NFFN)rh   r   rD   r   ri   rj   rk   rl   rm   rl   rE   rF   r   r   )r|   rs   )r}   r   r~   r   r   r   )r   rl   r   r   r   )rh   r   rE   rF   r   r   )TNTF)r   r   r   rl   r   r   r   rl   r   rl   r   r   )r   r   r   r   r   r   ) r   
__future__r   r   typingr   r   r   r   r   r   r	   r
   pandas._configr   pandas.core.dtypes.inferencer   r   EscapeCharsr   r   r7   r(   r]   rg   rI   r   r   r   r   r   r   r   r   r   r   <module>   sB    (
#%$!J
" 
-)