gL iFdZddlmZddlmZmZmZddlZddlm Z m Z m Z m Z ddl mZddlmZddlmZdd lmZe eeefeefZe d Ze d Zdd Zddd Z d d!dZ d d"dZ d# d$dZ d% d&dZd'dZd(d)dZ d* d+dZ! d,dZ"Gdde#eefZ$GddZ%Gdde%Z&d-dZ'y).z Printing tools. ) annotations)IterableMappingSequenceN)AnyCallableTypeVarUnion)east_asian_width) get_option) is_sequence)get_console_size_KT_VTc |jdt}|jdt}g}|ddDcgc]}tt |||z}}|j tt t|dtt t|}t |D]?\} } || || d} d|| zg|t| z z| z} |j | At|} djd | DScc}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. strlenjustfuncNleft)mode  c3>K|]}dj|yw)N)join).0liness `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/io/formats/printing.py zadjoin..<s8RWWU^8s) poplen _adj_justifymaxmapappend enumeratezipr) spacelistskwargsrrnewListsxlengthsmaxLenilstnltoJoins radjoinr3s ZZ# &Fzz*l3HH49#2J?qs3vq>"U*?G? NN3s3b *+, S% !FE"3 c71:F 3WQZ FSX$56" <(^F 9988 88@sDc|dk(r|Dcgc]}|j|c}S|dk(r|Dcgc]}|j|c}S|Dcgc]}|j|c}Scc}wcc}wcc}w)zB Perform ljust, center, rjust against string or list-like rcenterljustr5rjust)textsmax_lenrr,s rr"r"?sl v~*/0Q 00  +01a!11*/0Q 00 110A(A- A2c t|trd}nt|drdnd}|dur t|}n|xst dxs t|}t |}t t|t|Dcgc]}tt||dzfd|i|}}dj|} |t|kr| d z } n#t|trt|dk(r| d z } |j| Scc}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) isinstancesethasattrr!r iterrangemin pprint_thingnextrtupleformat) seq _nest_lvlr>kwdsfmtnitemssr/rrCs r _pprint_seqrUcs#s#C7jZSI*_"=IS S As63s8,-   T!Wi!mQ=QDQ A  99QNr?)keyvalr@rA)things)r!r listitemsr%rMrJr) rNrOr>rPrQpairspfmtrRkvs r _pprint_dictr`s C E DSI*_"=ISSYY[!'6* 1 KK IMWWRVW IMWWRVW    Czz5!1G!;z<<zz5!1z22cT|f dfd }t|dr t|St|tr|t dkrt ||d|}|St |r |t dkrt|||||}|St|tr|rd||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 cdddd}t|tr0r|j|n|}t|j }n|xsd}t |}|D]}|j |||}|S)Nz\tz\nz\r) r )rDdictupdaterZkeysstrreplace)thing escape_chars translateresultcdefault_escapess ras_escaped_stringz'pprint_thing..as_escaped_strings!U; lD )  .(  1 1 34L'-2LU 5A^^Ay|4F 5 ra__next__zdisplay.pprint_nest_depthT) quote_stringsr>rmrtr>')rlrrmEscapeChars | Nonereturnrj)rFrjrDrgr r`r rU)rlrOrmrqrtr>rrros ` rrJrJs@8D"4 $uj!5z E4 Y#2& 9D   M U  J7R,S S  %''   M E3 M&u-.a0 M#5) Mrac<t|}|j||SN)rJencode)objectencodingerrorsvalues rpprint_thing_encodedrs  E <<& ))racdtjvryddlm}|}|y|jj }d}|r2||vr#ddlm}ddlm Gfdd|}|||<d ||_ y||vr d ||_ yy) NIPythonr) get_ipythonz!application/vnd.dataresource+json) BaseFormatter ObjectNamec&eZdZWdZefZy).TableSchemaFormatter_repr_data_resource_N)__name__ __module__ __qualname__ print_methodrg _return_typersrTableSchemaFormatterr s)*@A $w rarTF) sysmodulesrrdisplay_formatter formattersIPython.core.formattersr traitletsrenabled)enableriprmimetyperrrs @renable_data_resource_formatterrs ## B z%%00J2H : % = , '} ' $8#9Jx '+ 8$ Z ', 8$ rac t|dd|S)N)rdrerTrurJ)rlr>s rdefault_pprintrs  '#  racH"t\}}|tdxsd}|t|j}|r"t |}dd|dzz} dd|dzz} nd} d} t |} |rd dt |zz} nd } td xs| } | | kD}t " d"fd }d"fd }d}| dk(rd|}|S| dk(r|s||d}d|d|}|S| dk(r%|s#||d}||d}d|d|d|}|S| dk(rg}|ddDcgc] }|| }}n]| | kDrAt | dzd} |d| Dcgc] }|| }}|| dDcgc] }|| }}ng}|Dcgc] }|| }}|r|rt||\}}n|s:t dj||krt dj||ksTt||||}|Dcgc]}|j|}}|Dcgc]}|j|}}|r|t | z }|d}d}ttdt |dzD]!}t||}t ||ks|}n|Dcgc]}t||}}|Dcgc]}t||}}d}| }|D]}|| zdz} |||| || \}}|r||j| zdzz }| }|ddD]}!|!| zdz} |||| || \}}||||d|dz | \}}||z }d|jdz}||z }t ||kDs|r|| z }n|dz }d|t | dz}|Scc}wcc}wcc}wcc}wcc}wcc}wcc}wcc}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.widthPrrr?z z, rBzdisplay.max_seq_itemscj|jj|jz|k\r||jz }|}||z }||fSrz)r!rstrip)rSliner display_widthnext_line_prefixadjs r _extend_linez+format_object_summary.._extend_line]sW 774;;= !CGGELLN$; ;} L  A#D  $wrac2|rtfd|DSy)Nc3@K|]}j|ywrzr!)rr,rs rrz:format_object_summary..best_len..hs2aswwqz2sr)r#)valuesrs rbest_lenz'format_object_summary..best_lenfs 2622 2rar@rz[][]r )r>rz...) rSrjrrjrrjrintrrjrxztuple[str, str])r list[str]rxr)rr typerr!get_adjustmentrI_justifyrr#r8reversedrHrUr)#obj formatter is_justifynameindent_for_nameline_break_each_valuer_name_lenspace1space2nsepr> is_truncatedrrclosesummaryfirstlastheadr,tail max_length max_spacer max_items num_items pprinted_seqr head_valueword tail_itemrs# @rformat_object_summaryrsB()M1"?39r  |Cy!!t9shl+-.shl+-. CAsSY&67<1M}$L  C "%69MP  EAvug,p No a-#a&!eWAeW%j Ni a-#a&!R!eWBtfAeW-b N_ A D*-bc(3QIaL3D3  MQ&+A*-bq'2QIaL2D2*-qbc(3QIaL3D3D*-.QIaL.D. $&dD1 dDIIdO$}4 $(=8!$$@ 59: +::59: +:: ! &F 3IGEI%eAs5zA~&>?  *5 J |$y0 )I   FJJK;JDJEIJK;JDJ UJ#c)D($mVTMGT U  t{{}v-5 5GDcr UIs?S(D($mVTMGT U %WdDHma>OQWX 4ell3''5 w<= )-B v G sNGF .. NY433/;:"KJs0M<NN6N 3NN N%Nc ||z}dgt|dz}|D]B}|Dcgc] }t|}}t||Dcgc]\}}t||}}}D|D cgc]} tdt| |D } } |D cgc]} tdt| |D } } | | fScc}wcc}}wcc} wcc} 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')]) rc3DK|]\}}|j|ywrzr8rr,r:s rrz_justify.. F:1gaggg F c3DK|]\}}|j|ywrzrrs rrz_justify..rr)r!r'r#rL) rrcombinedr inner_seqitemlengthr,yrN head_tuples tail_tupless rrrs,d{Hs8A;''JE (12#d)22,/ F,CDDAqc!QiD DE SWKN FS*1E FFKSWKN FS*1E FFK  ##3DsB5B:##C #CceZdZdZddZy) PrettyDictz.Dict extension to support abbreviated __repr__ct|Srzrselfs r__repr__zPrettyDict.__repr__s D!!raN)rxrj)rrr__doc__rrfrarrrs 8"rarc.eZdZddZddZdd dZd dZy) _TextAdjustmentc$td|_y)Nzdisplay.encoding)r r}rs r__init__z_TextAdjustment.__init__s"#56 ract|Srzrrtexts rr!z_TextAdjustment.lens 4yrac|dk(r|Dcgc]}|j|c}S|dk(r|Dcgc]}|j|c}S|Dcgc]}|j|c}Scc}wcc}wcc}w)zJ Perform ljust, center, rjust against string or list-like rr5r6)rr9r:rr,s rjustifyz_TextAdjustment.justifysl 6>.34AGGG$4 4 X /45!AHHW%5 5.34AGGG$4 4 554r;cNt|g||j|jd|S)N)rr)r3r!r)rr(r)r*s rr3z_TextAdjustment.adjoin s&eVeVDHHt||VvVVraNrxNonerrjrxrright)r9rr:rrrjrxr)r(rrxrj)rrrrr!rr3rfrarrrs7 5WrarcBeZdZdfd ZddZ d ddZxZS)_EastAsianTextAdjustmentcpt|tdrd|_nd|_dddddd|_y)Nz!display.unicode.ambiguous_as_widerr?)NaNWFH)superrr ambiguous_width_EAW_MAP)r __class__s rrz!_EastAsianTextAdjustment.__init__s;  9 :#$D #$D !qqqqA racbt|ts t|Stfd|DS)zN Calculate display width considering unicode East Asian Width c3|K|]3}jjt|j5ywrz)rgetr r)rrprs rrz/_EastAsianTextAdjustment.len..$s3 MNDMM  .q143G3G H s9<)rDrjr!sumrs` rr!z_EastAsianTextAdjustment.lens3$$t9  RV   rac"fd}|dk(r%|Dcgc]}|j||c}S|dk(r%|Dcgc]}|j||c}S|Dcgc]}|j||c}Scc}wcc}wcc}w)NcDj|z t|zSrzr)tr:rs r_get_padz2_EastAsianTextAdjustment.justify.._get_pad,sTXXa[(3q61 1rarr5r6)rr9r:rr r,s` ` rrz _EastAsianTextAdjustment.justify(s~ 2 6>278QAGGHQK(8 8 X 389aAHHXa[)9 9278QAGGHQK(8 8 998sBB!B rrrr9z Iterable[str]r:rrrjrxr)rrrrr!r __classcell__)rs@rrrs9 B  ?F 9" 9-0 98; 9  9rarcDtd}|r tStS)Nz display.unicode.east_asian_width)r rr)use_east_asian_widths rrr7s#%&HI'))  ra)r(rr)rrxrjrr )rN)rNrrOrr> int | Nonerxrj)rNrrOrr>rrxrj)rNFFN)rlrrOrrmrwrqboolrtrr>rrxrj)zutf-8rk)r}rjr~rjrxbytes)rrrxrrz)rlrr>rrxrj)TNTF) rrrrrz str | Nonerrrrrxrj)rlist[Sequence[str]]rrrxz3tuple[list[tuple[str, ...]], list[tuple[str, ...]]])rxr)(r __future__rcollections.abcrrrrtypingrrr r unicodedatar pandas._configr pandas.core.dtypes.inferencer pandas.io.formats.consolerrj EscapeCharsrrr3r"rUr`rJrrrrrrgrrrrrfrarrs#   )%46GCH%x}45  en en9@ 1JDH !  !! !6@ ! !HCG3 3 35?33B'+! $ F FF%F F  F  F FT4=**-0* *-B "' hhh  h  h  h hV&$ &$%8&$8&$R"c3h"WW,$9$9N!ra