a
    oÝEbP>  ã                	   @  sp  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d	d
ddœdd„Zd=dd	dd
dœdd„Zd>dd	dddœdd„Zd?dd	dddœdd„Zd@dd	dddddd œd!d"„ZdAddd%d&œd'd(„Zdd)d*œd+d,„ZdBdddd-œd.d/„ZdCd1dd2dddd3œd4d5„Zd6d6d7d8œd9d:„ZG d;d<„ d<eeef ƒZdS )Dz
Printing tools.
é    )ÚannotationsN)ÚAnyÚCallableÚDictÚIterableÚMappingÚSequenceÚTypeVarÚUnion)Ú
get_option)Úis_sequenceÚ_KTÚ_VTÚintú	list[str]Ústr)ÚspaceÚlistsÚreturnc                   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�}
|
 d	||  g|t|	ƒ  ¡ | |
¡ qjt|Ž }|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   úZ/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/io/formats/printing.pyÚ
<listcomp>0   ó    zadjoin.<locals>.<listcomp>NéÿÿÿÿÚleft)Úmodeú Ú Ú
)
ÚpopÚlenÚjustifyÚappendr   r   Ú	enumerateÚextendÚzipÚjoin)r   r   Úkwargsr   Z	out_linesZnewListsÚlengthsÚmaxLenÚiÚlstÚnlZtoJoinÚlinesr   r   r   Úadjoin   s     r6   ÚrightzIterable[str])ÚtextsÚmax_lenr#   r   c                   sJ   |dkr‡ fdd„| D ƒS |dkr4‡ fdd„| D ƒS ‡ fdd„| D ƒS dS )zB
    Perform ljust, center, rjust against string or list-like
    r"   c                   s   g | ]}|  ˆ ¡‘qS r   )Úljustr   ©r9   r   r   r   C   r    zjustify.<locals>.<listcomp>Úcenterc                   s   g | ]}|  ˆ ¡‘qS r   )r<   r   r;   r   r   r   E   r    c                   s   g | ]}|  ˆ ¡‘qS r   ©Úrjustr   r;   r   r   r   G   r    Nr   )r8   r9   r#   r   r;   r   r)   >   s
    r)   r   z
int | None)ÚseqÚ	_nest_lvlÚmax_seq_itemsr   c                   sÀ   t | tƒrd}nt| dƒrdnd}ˆdu r4t| ƒ}nˆpFtdƒpFt| ƒ}t| ƒ‰‡ ‡‡‡fdd„tt|t| ƒƒƒD ƒ}d	 |¡}|t| ƒk r–|d
7 }nt | t	ƒr´t| ƒdkr´|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})FrA   c                   s*   g | ]"}t tˆƒˆ d  fdˆiˆ¤Ž‘qS )é   rA   )Úpprint_thingÚnext)r   r2   ©r@   ÚkwdsrA   Úsr   r   r   w   s   ÿz_pprint_seq.<locals>.<listcomp>ú, ú, ...rC   ú,)Úbody)Ú
isinstanceÚsetÚhasattrr(   r   ÚiterÚrangeÚminr.   ÚtupleÚformat)r?   r@   rA   rG   ÚfmtÚnitemsÚrrL   r   rF   r   Ú_pprint_seqb   s     	

þ

rX   r   c           
   	   K  sÈ   d}g }d}|du rt | ƒ}n|p0tdƒp0t | ƒ}t|  ¡ ƒd|… D ]H\}}	| |jt||d fd|i|¤Žt|	|d fd|i|¤Žd�¡ qF|t | ƒk r²|jd |¡d	 d
�S |jd |¡d
�S dS )zy
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.
    z{{{things}}}z{key}: {val}FrA   NrC   )ÚkeyÚvalrI   rJ   )Zthings)r(   r   ÚlistÚitemsr*   rT   rD   r.   )
r?   r@   rA   rG   rU   ÚpairsZpfmtrV   ÚkÚvr   r   r   Ú_pprint_dict…   s     
þÿr`   Fr   úEscapeChars | NoneÚbool)Úthingr@   Úescape_charsÚdefault_escapesÚquote_stringsrA   r   c                   s¨   |fddddœ‡ fdd„}t | dƒr,t| ƒS t| tƒrT|tdƒk rTt| |d	|d
�}nPt| ƒr||tdƒk r|t| ||||d�}n(t| tƒrœ|rœd|| ƒ› d�}n|| ƒ}|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
    r   ra   r   )rc   rd   r   c                   sf   ddddœ}t |tƒr8ˆ r&| |¡ n|}t| ¡ ƒ}n|p>d}t| ƒ}|D ]}| ||| ¡}qL|S )Nz\tz\nz\r)ú	r&   úr   )rM   ÚdictÚupdater[   Úkeysr   Úreplace)rc   rd   Ú	translateÚresultÚc©re   r   r   Úas_escaped_stringÃ   s    
z'pprint_thing.<locals>.as_escaped_stringÚ__next__zdisplay.pprint_nest_depthT)rf   rA   ©rd   rf   rA   ú')rO   r   rM   ri   r   r`   r   rX   )rc   r@   rd   re   rf   rA   rq   rn   r   rp   r   rD   ¤   s,     ÿ
ÿÿûrD   úutf-8rl   Úbytes)ÚencodingÚerrorsr   c                 C  s   t | ƒ}| ||¡S ©N)rD   Úencode)Úobjectrw   rx   Úvaluer   r   r   Úpprint_thing_encodedí   s    r}   ÚNone)Úenabler   c                 C  sŒ   dt jvrd S ddlm} |ƒ }|d u r,d S |jj}d}| rv||vrjddlm} G dd„ d|ƒ}|ƒ ||< d|| _n||v rˆd	|| _d S )
NÚIPythonr   )Úget_ipythonz!application/vnd.dataresource+json)ÚBaseFormatterc                   @  s   e Zd ZdZefZdS )z<enable_data_resource_formatter.<locals>.TableSchemaFormatterZ_repr_data_resource_N)Ú__name__Ú
__module__Ú__qualname__Zprint_methodri   Ú_return_typer   r   r   r   ÚTableSchemaFormatter  s   r‡   TF)	ÚsysÚmodulesr€   r�   Údisplay_formatterÚ
formattersÚIPython.core.formattersr‚   Úenabled)r   r�   Úipr‹   Úmimetyper‚   r‡   r   r   r   Úenable_data_resource_formatterô   s     

r�   )rc   rA   r   c                 C  s   t | dd|d�S )N)rg   rh   r&   Trs   ©rD   )rc   rA   r   r   r   Údefault_pprint  s    ür’   Tr   z
str | None)Ú	formatterÚ
is_justifyÚnameÚindent_for_nameÚline_break_each_valuer   c                   s  ddl m} ddlm} |ƒ \}}	|du r6tdƒp4d}|du rHt| ƒj}|rzt|ƒ}
dd|
d	  › �}dd|
d
  › �}nd}d}t| ƒ}|r ddt|ƒ  }nd}tdƒp®|}||k}|ƒ ‰ dddddddœ‡ fdd„}dddœ‡ fdd„}d}|dk�r
d|› �}�n|d	k�r:|�s:ˆ| d ƒ}d|› d|› �}�nÜ|d
k�r||�s|ˆ| d ƒ}ˆ| d ƒ}d|› d|› d|› �}�nš|d	k�r¦g }‡fdd„| dd… D ƒ}nf||k�röt|d
 d ƒ}‡fd!d„| d|… D ƒ}‡fd"d„| | d… D ƒ}ng }‡fd#d„| D ƒ}|�rŒ|�r(t	||ƒ\}}nd|�sVtd 
|¡ƒ|k �rVtd 
|¡ƒ|k �sŒt||ƒ||ƒƒ‰‡fd$d„|D ƒ}‡fd%d„|D ƒ}|�r|t|ƒ }|d }ttd	t|ƒd	 ƒƒD ]&‰t|ˆd&�}t|ƒ|k �r¼ �qä�q¼‡fd'd„|D ƒ}‡fd(d„|D ƒ}d)}|}tt|ƒƒD ]*‰|ˆ | d }||||||ƒ\}}�q|�rf|| ¡ | d* 7 }|}tt|ƒd	 ƒD ]*‰|ˆ | d }||||||ƒ\}}�qv||||d |d
 |ƒ\}}||7 }d| d¡ }||7 }t|ƒ|k�sð|�rú||7 }n|d7 }d|t|ƒd…  }|S )+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.

        .. versionadded:: 0.25.0

    Returns
    -------
    summary string
    r   )Úget_console_size)Úget_adjustmentNzdisplay.widthéP   r&   r$   rC   é   z
 z,
 rK   zdisplay.max_seq_itemsr   r   ztuple[str, str])rH   Úliner|   Údisplay_widthÚnext_line_prefixr   c                   s@   ˆ   | ¡ ¡ˆ   | ¡ ¡ |kr0| | ¡ 7 } |}||7 }| |fS ry   )r(   Úrstrip)rH   rœ   r|   r�   rž   ©Úadjr   r   Ú_extend_linea  s
     z+format_object_summary.<locals>._extend_liner   )Úvaluesr   c                   s"   | rt ‡ fdd„| D ƒƒS dS d S )Nc                 3  s   | ]}ˆ   |¡V  qd S ry   ©r(   r   r    r   r   Ú	<genexpr>m  r    z:format_object_summary.<locals>.best_len.<locals>.<genexpr>r   ©r   )r£   r    r   r   Úbest_lenk  s    z'format_object_summary.<locals>.best_lenrI   z[]ú[ú]r!   c                   s   g | ]}ˆ |ƒ‘qS r   r   r   ©r“   r   r   r   �  r    z)format_object_summary.<locals>.<listcomp>é
   c                   s   g | ]}ˆ |ƒ‘qS r   r   r   rª   r   r   r   „  r    c                   s   g | ]}ˆ |ƒ‘qS r   r   r   rª   r   r   r   …  r    c                   s   g | ]}ˆ |ƒ‘qS r   r   r   rª   r   r   r   ˆ  r    c                   s   g | ]}|  ˆ ¡‘qS r   r=   r   ©Ú
max_lengthr   r   r   —  r    c                   s   g | ]}|  ˆ ¡‘qS r   r=   r   r¬   r   r   r   ˜  r    ©rA   c                   s   g | ]}t |ˆ d �‘qS ©r®   ©rX   r   ©Ú	max_itemsr   r   r   §  r    c                   s   g | ]}t |ˆ d �‘qS r¯   r°   r   r±   r   r   r   ¨  r    r%   z...)Zpandas.io.formats.consoler˜   Zpandas.io.formats.formatr™   r   Útyperƒ   r(   rR   Ú_justifyr.   r   ÚreversedrQ   rX   rŸ   )Úobjr“   r”   r•   r–   r—   r˜   r™   r�   Ú_Zname_lenZspace1Zspace2ÚnÚseprA   Zis_truncatedr¢   r§   ÚcloseÚsummaryÚfirstÚlastÚheadÚtailZ	max_spacer|   Zpprinted_seqrœ   Úwordr   )r¡   r“   r²   r­   r   Úformat_object_summary  s¢    #





ÿþ

rÁ   zlist[Sequence[str]]z3tuple[list[tuple[str, ...]], list[tuple[str, ...]]])r¾   r¿   r   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   ë  r    c                   s$   g | ]}t d d„ t|ˆ ƒD ƒƒ‘qS )c                 s  s   | ]\}}|  |¡V  qd S ry   r=   ©r   r   r9   r   r   r   r¥   ï  r    ú&_justify.<locals>.<listcomp>.<genexpr>©rS   r-   ©r   r?   r¬   r   r   r   î  s   c                   s$   g | ]}t d d„ t|ˆ ƒD ƒƒ‘qS )c                 s  s   | ]\}}|  |¡V  qd S ry   r=   rÄ   r   r   r   r¥   ò  r    rÅ   rÆ   rÇ   r¬   r   r   r   ñ  s   )r(   r-   )r¾   r¿   ÚcombinedZ	inner_seqÚlengthr   r¬   r   r´   Î  s    
ÿ
ÿr´   c                   @  s   e Zd ZdZddœdd„ZdS )Ú
PrettyDictz.Dict extension to support abbreviated __repr__r   )r   c                 C  s   t | ƒS ry   r‘   )Úselfr   r   r   Ú__repr__þ  s    zPrettyDict.__repr__N)rƒ   r„   r…   Ú__doc__rÌ   r   r   r   r   rÊ   û  s   rÊ   )r7   )r   N)r   N)r   NFFN)ru   rl   )N)TNTF) rÍ   Ú
__future__r   rˆ   Útypingr   r   r   r   r   r   r	   r
   Zpandas._configr   Zpandas.core.dtypes.inferencer   r   ZEscapeCharsr   r   r6   r)   rX   r`   rD   r}   r�   r’   rÁ   r´   rÊ   r   r   r   r   Ú<module>   s@   (#% ÿ$ ÿ!     úJ ÿ!    ú 1-