1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
U
¬ý°dh?ã    @spdZddlmZddlZddlmZmZmZmZm    Z    m
Z
m Z m Z ddl mZddlmZe e    eefeefZe dƒZe dƒZd    d
d d œd d„Zd=dd    d d
dœdd„Zd>dd    dd dœdd„Zd?dd    dd dœdd„Zd@dd    ddddd d œd!d"„ZdAd d d%d&œd'd(„Zdd)d*œd+d,„ZdBddd d-œd.d/„ZdCd1dd2ddd d3œd4d5„Zd6d6d7d8œd9d:„ZGd;d<„d<eeefƒZdS)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Ú| dt¡‰| dt¡}g}g}‡‡fdd„|dd…Dƒ}| ttt|dƒƒ¡ttt|ƒƒ}t|ƒD]B\}}    ||    ||dd}
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Újustfunccsg|]}ttˆ|ƒƒˆ‘qS©)ÚmaxÚmap©Ú.0Úx©rrrúQd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/io/formats/printing.pyÚ
<listcomp>0szadjoin.<locals>.<listcomp>NéÿÿÿÿÚleft)Úmodeú ÚÚ
)    ÚpopÚlenÚjustifyÚappendrrÚ    enumerateÚzipÚjoin) rrÚkwargsrZ    out_linesZnewListsÚlengthsÚmaxLenÚiÚlstÚnlZtoJoinÚlinesrrrÚadjoins   r4Úrightz Iterable[str])ÚtextsÚmax_lenr"rcsJ|dkr‡fdd„|DƒS|dkr4‡fdd„|DƒS‡fdd„|DƒSdS)zB
    Perform ljust, center, rjust against string or list-like
    r!csg|]}| ˆ¡‘qSr)Úljustr©r7rrrCszjustify.<locals>.<listcomp>Úcentercsg|]}| ˆ¡‘qSr)r:rr9rrrEscsg|]}| ˆ¡‘qSr©Úrjustrr9rrrGsNr)r6r7r"rr9rr(>s
r(rz
int | None)ÚseqÚ    _nest_lvlÚ max_seq_itemsrc sÀt|tƒrd}nt|dƒrdnd}ˆdkr4t|ƒ}nˆpFtdƒpFt|ƒ}t|ƒ‰‡‡‡‡fdd„tt|t|ƒƒƒDƒ}d     |¡}|t|ƒkr–|d
7}nt|t    ƒr´t|ƒd kr´|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})Fr?cs*g|]"}ttˆƒˆdfdˆiˆ—Ž‘qS)ér?)Ú pprint_thingÚnext)rr0©r>Úkwdsr?Úsrrrwsÿz_pprint_seq.<locals>.<listcomp>ú, ú, ...rAú,)Úbody) Ú
isinstanceÚsetÚhasattrr'r ÚiterÚrangeÚminr,ÚtupleÚformat)r=r>r?rEÚfmtÚnitemsÚrrJrrDrÚ _pprint_seqbs     
 
þ
 
rVrc
    KsÈd}g}d}|dkrt|ƒ}n|p0tdƒp0t|ƒ}t| ¡ƒd|…D]H\}}    | |jt||dfd|i|—Žt|    |dfd|i|—Žd¡qF|t|ƒkr²|jd |¡d    d
S|jd |¡d
SdS) zy
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.
    z {{{things}}}z {key}: {val}Fr?NrA)ÚkeyÚvalrGrH)Zthings)r'r ÚlistÚitemsr)rRrBr,)
r=r>r?rErSÚpairsZpfmtrTÚkÚvrrrÚ _pprint_dict…s 
þÿ r^FrúEscapeChars | NoneÚbool)Úthingr>Ú escape_charsÚdefault_escapesÚ quote_stringsr?rcs¨|fddddœ‡fdd„ }t|dƒr,t|ƒSt|tƒrT|tdƒkrTt||d    |d
}nPt|ƒr||tdƒkr|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
    rr_r)rarbrcsfddddœ}t|tƒr8ˆr&| |¡n|}t| ¡ƒ}n|p>d}t|ƒ}|D]}| |||¡}qL|S)Nz\tz\nz\r)ú    r%ú r)rKÚdictÚupdaterYÚkeysrÚreplace)rarbÚ    translateÚresultÚc©rcrrÚas_escaped_stringÃs 
 z'pprint_thing.<locals>.as_escaped_stringÚ__next__zdisplay.pprint_nest_depthT)rdr?©rbrdr?ú')rMrrKrgr r^r rV)rar>rbrcrdr?rorlrrnrrB¤s2 ÿ
ÿÿûrBúutf-8rjÚbytes)ÚencodingÚerrorsrcCst|ƒ}| ||¡S©N)rBÚencode)ÚobjectrurvÚvaluerrrÚpprint_thing_encodedísr{ÚNone)ÚenablercsœdtjkrdSddlm}|ƒ}|dkr,dS|jj}d}|r†||krzddlm}ddlm    ‰G‡fdd„d|ƒ}|ƒ||<d    ||_
n||kr˜d
||_
dS) NÚIPythonr)Ú get_ipythonz!application/vnd.dataresource+json)Ú BaseFormatter©Ú
ObjectNamecseZdZ”dƒZefZdS)z<enable_data_resource_formatter.<locals>.TableSchemaFormatterZ_repr_data_resource_N)Ú__name__Ú
__module__Ú __qualname__Z print_methodrgZ _return_typerrrrÚTableSchemaFormattersr†TF) ÚsysÚmodulesr~rZdisplay_formatterÚ
formattersZIPython.core.formattersr€Z    traitletsr‚Zenabled)r}rÚipr‰Úmimetyper€r†rrrÚenable_data_resource_formatterôs"
 
 rŒ)rar?rcCst|dd|dS)N)rerfr%Trq©rB)rar?rrrÚdefault_pprints ürŽTrz
str | None)Ú    formatterÚ
is_justifyÚnameÚindent_for_nameÚline_break_each_valuerc sddlm}ddlm}|ƒ\}}    |dkr6tdƒp4d}|dkrHt|ƒj}|rzt|ƒ}
dd|
d    ›} dd|
d
›} nd} d } t|ƒ} |r d dt|ƒ}nd }tdƒp®| }| |k}|ƒ‰dddddddœ‡fdd„ }dddœ‡fdd„ }d}| dk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}‡fdd„|dd…Dƒ}nf| |kröt|d
d ƒ} ‡fd!d„|d| …Dƒ}‡fd"d„|| d…Dƒ}ng}‡fd#d„|Dƒ}|rŒ|r(t    ||ƒ\}}nd|sVtd 
|¡ƒ|krVtd 
|¡ƒ|ksŒt ||ƒ||ƒƒ‰‡fd$d„|Dƒ}‡fd%d„|Dƒ}|r|t| ƒ}|d}t t d    t|ƒd    ƒƒD]J‰t|ˆd&}t|ƒ|kr¼‡fd'd„|Dƒ}‡fd(d„|Dƒ}qq¼d)}| }|D]&}||d}|||||| ƒ\}}q|rZ|| ¡| d*7}| }|dd…D]&}||d}|||||| ƒ\}}qf||||d|d
| ƒ\}}||7}d| d¡}||7}t|ƒ|ksÜ|ræ|| 7}n|d7}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.
 
    Returns
    -------
    summary string
    r)Úget_console_size)Úget_adjustmentNz display.widthéPr%r#rAéz
 z,
 rIzdisplay.max_seq_itemsrrztuple[str, str])rFÚlinerzÚ display_widthÚnext_line_prefixrcs@ˆ | ¡¡ˆ | ¡¡|kr0|| ¡7}|}||7}||fSrw)r'Úrstrip)rFr˜rzr™rš©ÚadjrrÚ _extend_line`s
  z+format_object_summary.<locals>._extend_liner)Úvaluesrcs"|rt‡fdd„|DƒƒSdSdS)Nc3s|]}ˆ |¡VqdSrw©r'rrœrrÚ    <genexpr>ksz:format_object_summary.<locals>.best_len.<locals>.<genexpr>r©r)rŸrœrrÚbest_lenisz'format_object_summary.<locals>.best_lenrGz[]ú[ú]r csg|] }ˆ|ƒ‘qSrrr©rrrr~sz)format_object_summary.<locals>.<listcomp>é
csg|] }ˆ|ƒ‘qSrrrr¦rrrscsg|] }ˆ|ƒ‘qSrrrr¦rrr‚scsg|] }ˆ|ƒ‘qSrrrr¦rrr…scsg|]}| ˆ¡‘qSrr;r©Ú
max_lengthrrr”scsg|]}| ˆ¡‘qSrr;rr¨rrr•s©r?csg|]}t|ˆd‘qS©rª©rVr©Ú    max_itemsrrr£scsg|]}t|ˆd‘qSr«r¬rr­rrr¤sr$z...)Zpandas.io.formats.consoler”Zpandas.io.formats.formatr•r Útyperƒr'rPÚ_justifyr,rÚreversedrOrVr›) Úobjrrr‘r’r“r”r•r™Ú_Zname_lenZspace1Zspace2ÚnÚsepr?Z is_truncatedržr£ÚcloseÚsummaryÚfirstÚlastÚheadÚtailZ    max_spacerzZ pprinted_seqr˜Z
head_valueÚwordZ    tail_itemr)rrr®r©rÚformat_object_summarys¢!  
 
     
 
 
ÿþ  
 
r½zlist[Sequence[str]]z3tuple[list[tuple[str, ...]], list[tuple[str, ...]]])rºr»rcsr||}dgt|dƒ‰|D]&}dd„|Dƒ}dd„tˆ|ƒDƒ‰q‡fdd„|Dƒ}‡fdd„|Dƒ}||fS)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')])
    rcSsg|] }t|ƒ‘qSrr )rÚitemrrrrçsz_justify.<locals>.<listcomp>cSsg|]\}}t||ƒ‘qSrr¢)rrÚyrrrrèscs$g|]}tdd„t|ˆƒDƒƒ‘qS)css|]\}}| |¡VqdSrwr;©rrr7rrrr¡ìsú&_justify.<locals>.<listcomp>.<genexpr>©rQr+©rr=r¨rrrëscs$g|]}tdd„t|ˆƒDƒƒ‘qS)css|]\}}| |¡VqdSrwr;rÀrrrr¡ïsrÁrÂrÃr¨rrrîs)r'r+)rºr»ZcombinedZ    inner_seqÚlengthZ head_tuplesZ tail_tuplesrr¨rr°Ës
ÿ
ÿr°c@seZdZdZddœdd„ZdS)Ú
PrettyDictz.Dict extension to support abbreviated __repr__r)rcCst|ƒSrwr)ÚselfrrrÚ__repr__÷szPrettyDict.__repr__N)rƒr„r…Ú__doc__rÇrrrrrÅôsrÅ)r5)rN)rN)rNFFN)rsrj)N)TNTF) rÈÚ
__future__rr‡Útypingrrrrrrr    r
Zpandas._configr Zpandas.core.dtypes.inferencer rZ EscapeCharsr rr4r(rVr^rBr{rŒrŽr½r°rÅrrrrÚ<module>sF (  #%ÿ$ÿ!úJÿ" ú-)