
    OwgF                       d Z ddlmZ ddl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eeef   ee   f   Z 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&d-dZ'y).z
Printing tools.
    )annotations)IterableMappingSequenceN)AnyCallableTypeVarUnion)east_asian_width)
get_option)is_sequence)get_console_size_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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 
c              3  >   K   | ]  }d j                  |        yw) N)join).0liness     Q/var/www/horilla/myenv/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   adjoinr3      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"< (^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ljustr5   rjust)textsmax_lenr   r,   s       r   r"   r"   ?   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        | d      rdnd}|du rt        |       }n|xs t	        d      xs t        |       }t        |       }t        t        |t        |                   D cg c]  }t        t        |      |dz   fd|i| }}dj                  |      }	|t        |       k  r|	d	z  }	n#t        | t              rt        |       dk(  r|	d
z  }	|j                  |	      S c c}w )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})Fmax_seq_items   , , ...,)body)
isinstancesethasattrr!   r   iterrangeminpprint_thingnextr   tupleformat)
seq	_nest_lvlr>   kwdsfmtnitemssr/   rrC   s
             r   _pprint_seqrU   c   s     #s#C7jZSI*_"=ISS	A s63s8,-	 	T!Wi!mQ=QDQ	A 	 99Q<DC	C	CHM::4:  	s   ;"C9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}Fr>   Nr?   )keyvalr@   rA   )things)r!   r   listitemsr%   rM   rJ   r   )
rN   rO   r>   rP   rQ   pairspfmtrR   kvs
             r   _pprint_dictr`      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2    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 )	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
    c                    dddd}t        |t              r0r|j                  |       n|}t        |j	                               }n|xs d}t        |       }|D ]  }|j                  |||         } |S )Nz\tz\nz\r)	r    )rD   dictupdaterZ   keysstrreplace)thingescape_chars	translateresultcdefault_escapess        r   as_escaped_stringz'pprint_thing.<locals>.as_escaped_string   s     !U;	lD)  .(	 1 1 34L'-2LU 	5A^^Ay|4F	5ra   __next__zdisplay.pprint_nest_depthT)quote_stringsr>   rm   rt   r>   ')rl   r   rm   EscapeChars | Nonereturnrj   )rF   rj   rD   rg   r   r`   r   rU   )rl   rO   rm   rq   rt   r>   rr   ro   s      `    r   rJ   rJ      s    @ 8D"4	$ uj!5z	E4	 Y#2 & 9D
  M 
U		J7R,S S%''
 M 
E3	M&u-.a0 M #5)Mra   c                <    t        |       }|j                  ||      S N)rJ   encode)objectencodingerrorsvalues       r   pprint_thing_encodedr      s      E<<&))ra   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_methodrg   _return_typer   s   r   TableSchemaFormatterr   	  s    )*@A $wra   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$ 
 ra   c                     t        | dd|      S )N)rd   re   r   Tru   rJ   )rl   r>   s     r   default_pprintr     s    '#	 ra   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   r?      z
 z,
 rB   zdisplay.max_seq_itemsc                    j                  |j                               j                  |j                               z   |k\  r| |j                         z  } |}||z  }| |fS rz   )r!   rstrip)rS   liner   display_widthnext_line_prefixadjs        r   _extend_linez+format_object_summary.<locals>._extend_line]  sW     774;;=!CGGELLN$;;}LA#D$wra   c                2    | rt        fd| D              S y)Nc              3  @   K   | ]  }j                  |        y wrz   r!   )r   r,   r   s     r   r   z:format_object_summary.<locals>.best_len.<locals>.<genexpr>h  s     2aswwqz2s   r   )r#   )valuesr   s    r   best_lenz'format_object_summary.<locals>.best_lenf  s    26222ra   r@   r   z[][]r   
   )r>   r   z...)rS   rj   r   rj   r   rj   r   intr   rj   rx   ztuple[str, str])r   	list[str]rx   r   )r   r   typer   r!   get_adjustmentrI   _justifyr   r#   r8   reversedrH   rU   r   )#obj	formatter
is_justifynameindent_for_nameline_break_each_valuer   _name_lenspace1space2nsepr>   is_truncatedr   r   closesummaryfirstlastheadr,   tail
max_length	max_spacer   	max_items	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 ]B  }|D cg c]  }t        |       }}t        ||      D cg c]  \  }}t        ||       }}}D | D 	cg c]  }	t        d t        |	|      D                }
}	|D 	cg c]  }	t        d t        |	|      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   c              3  D   K   | ]  \  }}|j                  |        y wrz   r8   r   r,   r:   s      r   r   z_justify.<locals>.<genexpr>       F:1gagggF    c              3  D   K   | ]  \  }}|j                  |        y wrz   r   r   s      r   r   z_justify.<locals>.<genexpr>  r   r   )r!   r'   r#   rL   )r   r   combinedr   	inner_seqitemlengthr,   yrN   head_tuplestail_tupless               r   r   r     s    , d{H s8A;''J E	(12#d)22,/
F,CDDAqc!QiD
DE SWKNFS*1EFFK  SWKNFS*1EFFK  ## 3Ds   B5B:##C #Cc                      e Zd ZdZddZy)
PrettyDictz.Dict extension to support abbreviated __repr__c                    t        |       S rz   r   selfs    r   __repr__zPrettyDict.__repr__  s    D!!ra   N)rx   rj   )r   r   r   __doc__r   rf   ra   r   r   r     s
    8"ra   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ra   c                    t        |      S rz   r   r   texts     r   r!   z_TextAdjustment.len  s    4yra   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   r5   r6   )r   r9   r:   r   r,   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   )r3   r!   r   )r   r(   r)   r*   s       r   r3   z_TextAdjustment.adjoin  s&    eVeVDHHt||VvVVra   Nrx   Noner   rj   rx   r   right)r9   r   r:   r   r   rj   rx   r   )r(   r   rx   rj   )r   r   r   r   r!   r   r3   rf   ra   r   r   r     s    7	5Wra   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   r?   )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ra   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rz   )r   getr   r   )r   rp   r   s     r   r   z/_EastAsianTextAdjustment.len.<locals>.<genexpr>$  s3      
MNDMM.q143G3GH
s   9<)rD   rj   r!   sumr   s   ` r   r!   z_EastAsianTextAdjustment.len  s3     $$t9 
RV
 
 	
ra   c                "     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 rz   r   )tr:   r   s    r   _get_padz2_EastAsianTextAdjustment.justify.<locals>._get_pad,  s    TXXa[(3q611ra   r   r5   r6   )r   r9   r:   r   r	  r,   s   ` `   r   r   z _EastAsianTextAdjustment.justify(  s~    	2 6>278QAGGHQK(88X389aAHHXa[)99278QAGGHQK(88	 998s   BB!Br   r   r   r9   zIterable[str]r:   r   r   rj   rx   r   )r   r   r   r   r!   r   __classcell__)r  s   @r   r   r     s9    
B	
 ?F9"9-098;9	9ra   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   7  s#    %&HI'))  ra   )r(   r   r)   r   rx   rj   r   r
  )r   N)rN   r   rO   r   r>   
int | Nonerx   rj   )rN   r   rO   r   r>   r  rx   rj   )r   NFFN)rl   r   rO   r   rm   rw   rq   boolrt   r  r>   r  rx   rj   )zutf-8rk   )r}   rj   r~   rj   rx   bytes)r   r  rx   r   rz   )rl   r   r>   r  rx   rj   )TNTF)r   r   r   r  r   z
str | Noner   r  r   r  rx   rj   )r   list[Sequence[str]]r   r  rx   z3tuple[list[tuple[str, ...]], list[tuple[str, ...]]])rx   r   )(r   
__future__r   collections.abcr   r   r   r   typingr   r   r	   r
   unicodedatar   pandas._configr   pandas.core.dtypes.inferencer   pandas.io.formats.consoler   rj   EscapeCharsr   r   r3   r"   rU   r`   rJ   r   r   r   r   r   rg   r   r   r   r   rf   ra   r   <module>r     s   # 
   ) % 4 6GCH%x}45enen9@	1J DH !	 !! !6@ ! !H CG3	3 35?33B '+! $FFF %F 	F
 F F 	FT 4=**-0*
*-B  "'hh h 	h
 h  h 	hV&$
&$%8&$8&$R"c3h "W W,$9 $9N!ra   