
    o[wej=                    `   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 eeeef         ee         f         Z ed          Z ed	          ZdBdZdCdDdZ	 dEdFdZ	 dEdGdZ	 	 	 	 	 dHdId'Z	 dJdKd-ZdLd0ZdMdNd1Z	 	 	 	 dOdPd:ZdQd?Z G d@ dAeeef                   Z dS )Rz
Printing tools.
    )annotations)IterableMappingSequenceN)AnyCallableTypeVarUnion)
get_option)is_sequence_KT_VTspaceintlists	list[str]returnstrc           	     n    |                     dt                    |                     dt                    }g } fd|dd         D             }|                    t	          t          t          |d                                        t	          t          t          |                    }t          |          D ]P\  }} ||||         d          }	d||         z  g|t          |          z
  z  |	z   }	|                    |	           Qt          | }
d	                    d
 |
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                P    g | ]"}t          t          |                    z   #S  )maxmap).0xr   r   s     :lib/python3.11/site-packages/pandas/io/formats/printing.py
<listcomp>zadjoin.<locals>.<listcomp>0   s.    ???qs3vq>>""U*???    Nleft)mode 
c              3  @   K   | ]}d                      |          V  dS ) N)join)r   liness     r   	<genexpr>zadjoin.<locals>.<genexpr>9   s,      88RWWU^^888888r    )	poplenjustifyappendr   r   	enumeratezipr(   )r   r   kwargsr   newListslengthsmaxLenilstnltoJoinr   s   `          @r   adjoinr9      s,     ZZ#&&Fzz*g..HH?????E#2#J???GNN3s3b	**++,,,S%!!FE""  3Xc71:F333WQZ FSXX$56"<(^F9988888888r    righttextsIterable[str]max_lenr#   c                p    |dk    rfd| D             S |dk    rfd| D             S fd| D             S )zB
    Perform ljust, center, rjust against string or list-like
    r"   c                :    g | ]}|                               S r   )ljustr   r   r=   s     r   r   zjustify.<locals>.<listcomp>A   %    000Q  000r    centerc                :    g | ]}|                               S r   )rC   rA   s     r   r   zjustify.<locals>.<listcomp>C   s%    111a!!111r    c                :    g | ]}|                               S r   rjustrA   s     r   r   zjustify.<locals>.<listcomp>E   rB   r    r   )r;   r=   r#   s    ` r   r-   r-   <   sg     v~~0000%0000			1111511110000%0000r    seqr   	_nest_lvlmax_seq_items
int | Nonec           	     <   t          | t                    rd}nt          | d          rdnd}du rt          |           }n pt	          d          pt          |           }t          |           fdt          t          |t          |                               D             }d                    |          }|t          |           k     r|d	z  }n-t          | t                    rt          |           d
k    r|dz  }|
                    |          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})FrJ   c                P    g | ]"}t          t                    d z   fdi#S )   rJ   )pprint_thingnext)r   r5   rI   kwdsrJ   ss     r   r   z_pprint_seq.<locals>.<listcomp>u   sJ     	 	 	 	T!WWi!mQQ=QDQQ	 	 	r    , , ...rO   ,)body)
isinstancesethasattrr,   r   iterrangeminr(   tupleformat)	rH   rI   rJ   rR   fmtnitemsrrW   rS   s	    ```    @r   _pprint_seqrc   `   s3    #s H#C77GjjZSI*_"="=ISS		A	 	 	 	 	 	 	s63s88,,--	 	 	A 99Q<<DC	C		 CHHMM::4:   r    r   c                <   d}g }d}|du rt          |           }n |pt          d          pt          |           }t          |                                           d|         D ]Q\  }}	|                    |                    t          ||dz   fd|i|t          |	|dz   fd|i|                     R|t          |           k     r,|                    d                    |          d	z   
          S |                    d                    |          
          S )zy
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.
    z{{{things}}}z{key}: {val}FrJ   NrO   )keyvalrT   rU   )things)r,   r   listitemsr.   r_   rP   r(   )
rH   rI   rJ   rR   r`   pairspfmtra   kvs
             r   _pprint_dictrn      s;    CEDSI*_"="=ISSYY[[!!'6'* 
 
1KK IMWWWRVWW IMWWWRVWW   	
 	
 	
 	
 Czz5!1!1G!;z<<<zz5!1!1z222r    Fthingr   escape_charsEscapeChars | Nonedefault_escapesboolquote_stringsc                   |fdfd}t          | d          rt          |           S t          | t                    r'|t	          d	          k     rt          | |d
|          }nit          |           r(|t	          d	          k     rt          | ||||          }n2t          | 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
    ro   r   rp   rq   r   r   c                   dddd}t          |t                    r<r|                    |           n|}t          |                                          }n|pd}t          |           }|D ]}|                    |||                   }|S )Nz\tz\nz\r)	r%   r   )rX   dictupdaterh   keysr   replace)ro   rp   	translateresultcrr   s        r   as_escaped_stringz'pprint_thing.<locals>.as_escaped_string   s     !U;;	lD)) 	. )  ....(	 1 1 3 344LL'-2LU 	5 	5A^^Ay|44FFr    __next__zdisplay.pprint_nest_depthT)rt   rJ   rp   rt   rJ   ')ro   r   rp   rq   r   r   )rZ   r   rX   ry   r   rn   r   rc   )ro   rI   rp   rr   rt   rJ   r   r~   s      `    r   rP   rP      s3   @ 8D      $ uj!! *5zz	E4	 	  *Y#2 2 & & 9D
 
 
 
U		 *	J7R,S,S S S%''
 
 
 
E3		 *M *0&&u--000""5))Mr    utf-8r|   encodingerrorsbytesc                L    t          |           }|                    ||          S N)rP   encode)objectr   r   values       r   pprint_thing_encodedr      s%       E<<&)))r    enableNonec                   dt           j        vrd S ddlm}  |            }|d S |j        j        }d}| r<||vr)ddlm} ddlm	  G fdd|          } |            ||<   d	||         _
        d S ||v rd
||         _
        d S d S )NIPythonr   )get_ipythonz!application/vnd.dataresource+json)BaseFormatter
ObjectNamec                  ,    e Zd Z  d          ZefZdS )<enable_data_resource_formatter.<locals>.TableSchemaFormatter_repr_data_resource_N)__name__
__module____qualname__print_methodry   _return_typer   s   r   TableSchemaFormatterr     s&        )z*@AA $wr    r   TF)sysmodulesr   r   display_formatter
formattersIPython.core.formattersr   	traitletsr   enabled)r   r   ipr   mimetyper   r   r   s          @r   enable_data_resource_formatterr      s   ########	B	z%0J2H -:%%======,,,,,,' ' ' ' ' ' '} ' ' '
 $8#7#9#9Jx '+
8$$$	Z		',
8$$$ 
 	r    c                (    t          | dd|          S )N)rw   rx   r%   Tr   rP   )ro   rJ   s     r   default_pprintr     s%    '#	   r    T	formatterr   
is_justifyname
str | Noneindent_for_nameline_break_each_valuec                  !"# ddl m} ddlm}  |            \  }}	|t	          d          p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          p|}||k    } |            !d-!fd}d.!fd}d}|dk    rd| }n|d	k    r|s | d                   }d| d| }n|d
k    r1|s/ | d                   } | d                    }d| d| d| }n|d	k    rg }fd!| d d         D             }nW||k    rAt          |d
z  d"          }fd#| d|         D             }fd$| | d         D             }ng }fd%| D             }|r|rt          ||          \  }}n|sLt          d
                    |                    |k     r&t          d
                    |                    |k     s>t           ||           ||                    ##fd&|D             }#fd'|D             }|r|t          |          z
  }|d         }d	"t          t          d	t          |          d	z                       D ]*}t          ||(          }t          |          |k     r|" n+"fd)|D             }"fd*|D             }d+}|}|D ]}||z   dz   } ||||||          \  }}|r||                                |z   d,z   z  }|}|dd          D ]} | |z   dz   } ||||||          \  }} ||||d          |d
z
  |          \  }}||z  }d|                    d          z   }||z  }t          |          |k    s|r||z  }n|dz  }d|t          |          d         z   }|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.

    Returns
    -------
    summary string
    r   )get_console_size)get_adjustmentNzdisplay.widthP   r%   r$   rO      z
 z,
 rV   zdisplay.max_seq_itemsrS   r   liner   display_widthr   next_line_prefixr   tuple[str, str]c                                         |                                                               |                                          z   |k    r| |                                z  } |}||z  }| |fS r   )r,   rstrip)rS   r   r   r   r   adjs        r   _extend_linez+format_object_summary.<locals>._extend_line]  sf     774;;==!!CGGELLNN$;$;;}LLA#D$wr    valuesr   c                B    | rt          fd| D                       S dS )Nc              3  B   K   | ]}                     |          V  d S r   r,   )r   r   r   s     r   r*   z:format_object_summary.<locals>.best_len.<locals>.<genexpr>h  s-      22aswwqzz222222r    r   r   )r   r   s    r   best_lenz'format_object_summary.<locals>.best_lenf  s3     	222262222221r    rT   z[][]r!   c                &    g | ]} |          S r   r   r   r   r   s     r   r   z)format_object_summary.<locals>.<listcomp>{  !    333QIIaLL333r    
   c                &    g | ]} |          S r   r   r   s     r   r   z)format_object_summary.<locals>.<listcomp>~  s!    222QIIaLL222r    c                &    g | ]} |          S r   r   r   s     r   r   z)format_object_summary.<locals>.<listcomp>  r   r    c                &    g | ]} |          S r   r   r   s     r   r   z)format_object_summary.<locals>.<listcomp>  s!    ...QIIaLL...r    c                :    g | ]}|                               S r   rF   r   r   
max_lengths     r   r   z)format_object_summary.<locals>.<listcomp>  %    :::
++:::r    c                :    g | ]}|                               S r   rF   r   s     r   r   z)format_object_summary.<locals>.<listcomp>  r   r    rJ   c                2    g | ]}t          |           S r   rc   r   r   	max_itemss     r   r   z)format_object_summary.<locals>.<listcomp>  &    JJJK;;;JJJr    c                2    g | ]}t          |           S r   r   r   s     r   r   z)format_object_summary.<locals>.<listcomp>  r   r    r'   z...)rS   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,   r]   _justifyr(   r   reversedr\   rc   r   )$objr   r   r   r   r   r   r   r   _name_lenspace1space2nseprJ   is_truncatedr   r   closesummaryfirstlastheadtail	max_spacer   	num_itemspprinted_seqr   
head_valueword	tail_itemr   r   r   s$    `                               @@@r   format_object_summaryr     s}   B ;:::::777777''))M1"?339r|Cyy! t99.shl+...shl+..CA  sSYY&677<1M }$L .

C           EAvvu,,	
a-	#a&!!%e%%e%%	
a-	#a&!!yR!!-e--t--e--AD3333#bcc(333DDMQ&++A2222#bqb'222D3333#qbcc(333DDD....#...D  	;$ ; &dD11
dd ;DIIdOO$$}44		$((=88 !$$@@
::::T:::::::T::: ! 	K
 &F3IGEI%eAs5zzA~&>&>??  	*5	JJJ|$$y00 )IE 1 KJJJTJJJDJJJJTJJJD 	U 	UJ#c)D(L$mVTTMGTT 	t{{}}v-55GDcrc 	U 	UIs?S(D(L$mVTTMGTT %WdDHma>OQWXX4 ell3'''5w<<=))-B)vGGsNG F..Nr    r   list[Sequence[str]]r   3tuple[list[tuple[str, ...]], list[tuple[str, ...]]]c                    | |z   }dgt          |d                   z  |D ](}d |D             }d t          |          D             )fd| D             }f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                ,    g | ]}t          |          S r   r   )r   items     r   r   z_justify.<locals>.<listcomp>  s    222#d))222r    c                4    g | ]\  }}t          ||          S r   r   )r   r   ys      r   r   z_justify.<locals>.<listcomp>  s$    DDDDAqc!QiiDDDr    c           	     ^    g | ])}t          d  t          |          D                       *S )c              3  F   K   | ]\  }}|                     |          V  d S r   rF   rA   s      r   r*   z&_justify.<locals>.<listcomp>.<genexpr>  2      FF:1gagggFFFFFFr    r^   r0   r   rH   r   s     r   r   z_justify.<locals>.<listcomp>  G       KNFFS*1E1EFFFFF  r    c           	     ^    g | ])}t          d  t          |          D                       *S )c              3  F   K   | ]\  }}|                     |          V  d S r   rF   rA   s      r   r*   z&_justify.<locals>.<listcomp>.<genexpr>  r   r    r   r   s     r   r   z_justify.<locals>.<listcomp>  r  r    )r,   r0   )r   r   combined	inner_seqlengthhead_tuplestail_tuplesr   s          @r   r   r     s    , d{H s8A;'''J E E	22	222DDC
F,C,CDDD

   RV  K   RV  K ##r    c                      e Zd ZdZddZdS )
PrettyDictz.Dict extension to support abbreviated __repr__r   r   c                     t          |           S r   r   )selfs    r   __repr__zPrettyDict.__repr__  s    D!!!r    N)r   r   )r   r   r   __doc__r  r   r    r   r
  r
    s.        88" " " " " "r    r
  )r   r   r   r   r   r   )r:   )r;   r<   r=   r   r#   r   r   r   )r   N)rH   r   rI   r   rJ   rK   r   r   )rH   r   rI   r   rJ   rK   r   r   )r   NFFN)ro   r   rI   r   rp   rq   rr   rs   rt   rs   rJ   rK   r   r   )r   r|   )r   r   r   r   r   r   )r   rs   r   r   r   )ro   r   rJ   rK   r   r   )TNTF)r   r   r   rs   r   r   r   rs   r   rs   r   r   )r   r   r   r   r   r   )!r  
__future__r   collections.abcr   r   r   r   typingr   r   r	   r
   pandas._configr   pandas.core.dtypes.inferencer   r   EscapeCharsr   r   r9   r-   rc   rn   rP   r   r   r   r   r   ry   r
  r   r    r   <module>r     sc    # " " " " "         
 


            & % % % % % 4 4 4 4 4 4GCH%x}45genngenn9 9 9 9@	1 	1 	1 	1 	1J DH !  !  !  !  !H CG3 3 3 3 3B '+! $F F F F FT 4=* * * * *- - - -B      "'k k k k k\&$ &$ &$ &$R" " " " "c3h " " " " "r    