Files
952-11/env/python/dll/Python312/Lib/__pycache__/pprint.cpython-312.pyc
T

209 lines
29 KiB
Plaintext
Raw Normal View History

2024-08-19 17:05:14 +08:00
Ë
*åfð`ã óê—dZddlZddlZddlZddlZddlZ ddl
m Z gd¢Z
dddddœd„Zdddddœd „Zdd
œd „Zd „Zd
„Zd„ZGd„d«Zd„ZGd„d«Zeeeeeeeed«h«Zd„Z d„Z!y)a/Support to pretty-print lists, tuples, & dictionaries recursively.
Very simple, but useful, especially in debugging data structures.
Classes
-------
PrettyPrinter()
Handle pretty-printing operations onto a stream using a configured
set of formatting parameters.
Functions
---------
pformat()
Format a Python object into a pretty-printed representation.
pprint()
Pretty-print a Python object to a stream [default is sys.stdout].
saferepr()
Generate a 'standard' repr()-like value, but protect against recursive
data structures.
éN)ÚStringIO)ÚpprintÚpformatÚ
isreadableÚ isrecursiveÚsafereprÚ
PrettyPrinterÚppFT©ÚcompactÚ
sort_dictsÚunderscore_numbersc óJ—t|||||||¬«}|j|«y)zAPretty-print a Python object to a stream [default is sys.stdout].)ÚstreamÚindentÚwidthÚdepthr r
rN)r r) Úobjectrrrrr r
rÚprinters úBC:\Users\RCi\AppData\Local\Programs\Python\Python312\Lib\pprint.pyrr0s-€ôؘf¨E¸Ø JØ-ô/€Gð ‡N�N�6ÕócóB—t||||||¬«j|«S)z<Format a Python object into a pretty-printed representation.)rrrr r
r)r r)rrrrr r
rs rrr9s*€ô  ¨e¸5Ø!(°ZØ,>ô @ç@GÁÈÃðPr)r
có&—t|g|¢­d|i|¤Žy)zPretty-print a Python objectr
N)r)rr
ÚargsÚkwargss rr
r
@sۊ
ˆ6Ð:�DÒ: ZÐ:°6Ó:rcó@—t«j|idd«dS)z=Version of repr() which can handle recursive data structures.Nr©r Ú
_safe_repr©rs rrrDó €ä ‹?× %Ñ % f¨b°$¸Ó :¸1Ñ =Ð=rcó@—t«j|idd«dS)z4Determine if saferepr(object) is readable by eval().Nrérrs rrrHr rcó@—t«j|idd«dS)z8Determine if object requires a recursive representation.Nrérrs rrrLr rcó"—eZdZdZdgZd„Zd„Zy)Ú _safe_keyaUHelper function for key functions when sorting unorderable objects.
The wrapped-object will fallback to a Py2.x style comparison for
unorderable types (sorting first comparing the type name and then by
the obj ids). Does not work recursively, so dict.items() must have
_safe_key applied to both the key and the value.
Úobjcó—||_y©N)r')Úselfr's rÚ__init__z_safe_key.__init__\s €Øˆ�rcó"— |j|jkS#t$rjtt|j««t |j«ftt|j««t |j«fkcYSwxYwr))r'Ú TypeErrorÚstrÚtypeÚid)r*Úothers rÚ__lt__z_safe_key.__lt___sm€ð ;Ø—8‘8˜eŸi™iÑ'Ð 'øÜò ;Üœ˜dŸh™h›Ó(¬"¨T¯X©X«,Ð7Üœ˜eŸi™i›Ó)¬2¨e¯i©i«=Ð9ñ:ò
;ð ;ús‚›A0BÂ
BN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú __slots__r+r2©rrr&r&Ps„ñð�€Iòó;rr&có:—t|d«t|d«fS)z&Helper function for comparing 2-tuplesrr")r&)Úts rÚ _safe_tupler;fs€ä �Q�q‘T‹?œI a¨¡d›OÐ +Ð+rcó´—eZdZd#ddddœd„Zd„Zd„Zd„Zd „Zd
„Zd „Z iZ
d „Z e e
e j<d
„Zee
ej j<d„Zee
ej<d„Zee
ej<d„Zee
ej<ee
ej<d„Zee
ej<d„Zee
ej<d„Zee
ej<d„Zee
ej@j<d„Z!e!e
ejDj<d„Z#d„Z$d„Z%d„Z&d„Z'd„Z(e(e
ejRj<d„Z*e*e
ejVj<d„Z,e,e
ejZj<d„Z.e.e
ej^j<d„Z0e0e
ejbj<d „Z2e2e
ejfj<d!„Z4e4e
ejjj<d"„Z6y)$r NFTr có2—t|«}t|«}|dkr td«‚|�|dkr td«‚|s td«‚||_||_||_|�||_nt j|_t|«|_ ||_
||_ y)aáHandle pretty printing operations onto a stream using a set of
configured parameters.
indent
Number of spaces to indent for each level of nesting.
width
Attempted maximum number of columns in the output.
depth
The maximum depth to print out nested structures.
stream
The desired output stream. If omitted (or false), the standard
output stream available at construction will be used.
compact
If true, several items will be combined in one line.
sort_dicts
If true, dict keys are sorted.
underscore_numbers
If true, digit groups are separated with underscores.
rzindent must be >= 0Nzdepth must be > 0zwidth must be != 0) ÚintÚ
ValueErrorÚ_depthÚ_indent_per_levelÚ_widthÚ_streamÚ_sysÚstdoutÚboolÚ_compactÚ _sort_dictsÚ_underscore_numbers)r*rrrrr r
rs rr+zPrettyPrinter.__init__ks™€ô8�V“ˆÜ�E“
ˆØ �AŠ:ÜÐ2Ó3Ð 3Ø Ð  ¨!¢ÜÐ0Ó1Ð 1ÙÜÐ1Ó2Ð 2؈Œ Ø!'ˆÔ؈Œ Ø Ð Ø!ˆD�LäŸ;™;ˆDŒLܘW›
ˆŒ
Ø%ˆÔØ#5ˆÕ rcó”—|j�<|j||jddid«|jjd«yy)Nrú
)rCÚ_formatÚwrite©r*rs rrzPrettyPrinter.pprintšs=€Ø �<‰<Ð #Ø �L‰L˜ §¡¨q°!°R¸Ô ;Ø �L‰L× Ñ ˜tÕ $ð $rcób—t«}|j||ddid«|j«S©Nr)Ú _StringIOrLÚgetvalue)r*rÚsios rrzPrettyPrinter.pformatŸs+€Ü‹kˆØ � ‰ �V˜S ! Q¨¨AÔ.Ø�|‰|‹~Ðrcó0—|j|idd«dS)Nrr$©ÚformatrNs rrzPrettyPrinter.isrecursive¤s€Ø�{‰{˜6 2 q¨!Ó,¨QÑ/Ð/rcó@—|j|idd«\}}}|xr| SrPrU)r*rÚsÚreadableÚ recursives rrzPrettyPrinter.isreadable§s*€Ø!%§¡¨V°R¸¸AÓ!>шˆ8�YØÒ)  ˜MÐ)rc
ó¼—t|«}||vr)|jt|««d|_d|_y|j |||«}|j |z
|z
} t|«| kDrà|jjt|«jd«}
|
�d||<|
|||||||dz«||=ytj|«r€t|t«sp|jj rZt#|jd«rDd|jj$j&vr"d||<|j)||||||dz«||=y|j|«y)NTFr"Ú __wrapped__Ú
__create_fn__)r0rMÚ
_recursionÚ
_recursiveÚ _readableÚ_reprrBÚlenÚ _dispatchÚgetr/Ú__repr__Ú _dataclassesÚ is_dataclassÚ
isinstanceÚ__dataclass_params__ÚreprÚhasattrr\r5Ú_pprint_dataclass) r*rrrÚ allowanceÚcontextÚlevelÚobjidÚrepÚ max_widthÚps rrLzPrettyPrinter._format«sA€Ü�6“
ˆØ �GÑ Ø �L‰Lœ FÓ+Ô ,Ø"ˆDŒOØ"ˆDŒNØ Ø�j‰j˜ ¨%Ó0ˆØ—K‘K &Ñ(¨9Ñ4ˆ Ü ˆs‹8�iÒ Ø—‘×"Ñ"¤4¨£<×#8Ñ#8¸$Ó?ˆA؈}Ø!"�˜‘Ù�$˜ ¨° ¸7ÀEÈAÁIÔNؘE�NØÜ×+Ñ+¨FÔ3Ü  ¬Ô.Ø×-Ñ-×2Ò2ä˜&Ÿ/™/¨=Ô9Ø! V§_¡_×%@Ñ%@×%MÑ%MÑMØ!"�˜‘Ø×&Ñ& v¨v°v¸yÈ'ÐSXÐ[\ÑS\Ô]ؘE�NØØ� ‰ �SÕrcóp—|jj}|t|«dzz
}tj|«D�cgc]1}|j
sŒ|j t||j «f‘Œ3} }|j|dz«|j| |||||«|jd«ycc}w)Nr"ú(ú))
Ú __class__r3rbrfÚfieldsrjÚnameÚgetattrrMÚ_format_namespace_items)
r*rrrrmrnroÚcls_nameÚfÚitemss
rrlzPrettyPrinter._pprint_dataclassÇs�€Ø×#Ñ#×,Ñ,ˆØ”#�h“- !Ñ#Ñ#ˆÜ<H×<OÑ<OÐPVÓ<WÖb°qÐ[\×[aÓ[a�!—&‘&œ' &¨!¯&©&Ó1Ò2ÐbˆÐbØ� ‰ �X ‘^Ô$Ø ×$Ñ$ U¨F°F¸IÀwÐPUÔVØ� ‰ �SÕùòcs ¿B3Á$B3cóN—|j}|d«|jdkDr||jdz
dz«t|«}|rU|jr t |j «t ¬«} n|j «} |j| |||dz||«|d«y)Nú{r"ú ©Úkeyú})rMrArbrHÚsortedr~r;Ú_format_dict_items)
r*rrrrmrnrorMÚlengthr~s
rÚ _pprint_dictzPrettyPrinter._pprint_dictÑs�€Ø— ‘ ˆÙ
ˆcŒ
Ø × !Ñ ! AÒ %Ù �4×)Ñ)¨AÑ-°Ñ4Ô 5Ü�V“ˆÙ Ø×ÒܘvŸ|™|›~´;Ô?‘àŸ ™ ›�Ø × #Ñ # E¨6°6¸9Àq¹=Ø$+¨Uô
4á
ˆc�
rcóX—t|«s|jt|««y|j}|j|jdz«|j t
|j««||t|j«zdz|dz||«|jd«y)Nrur"rv)rbrMrjrwr3rLÚlistr~)r*rrrrmrnroÚclss rÚ_pprint_ordered_dictz"PrettyPrinter._pprint_ordered_dictâs†€Ü�6Œ{Ø �L‰Lœ˜f›Ô &Ø Ø×шØ� ‰ �S—\‘\ CÑ'Ô(Ø � ‰ ”T˜&Ÿ,™,›.Ó)¨6Øœc #§,¡,Ó/Ñ/°!Ñ3°YÀ±]ؘeô %ð � ‰ �SÕrcóz—|jd«|j||||dz||«|jd«y)Nú[r"ú])rMÚ
_format_items©r*rrrrmrnros rÚ _pprint_listzPrettyPrinter._pprint_listïs9€Ø� ‰ �SÔØ ×ј6 6¨6°9¸q±=Ø" Eô +à� ‰ �SÕrc ó°—|jd«t|«dk(rdnd}|j||||t|«z||«|j|«y)Nrur"z,)rv)rMrbr�)r*rrrrmrnroÚendchars rÚ
_pprint_tuplezPrettyPrinter._pprint_tuple÷sP€Ø� ‰ �SÔܘf›+¨Ò*‘$°ˆØ ×ј6 6¨6°9¼sÀ7»|Ñ3KØ" Eô +à� ‰ �WÕrc óž—t|«s|jt|««y|j}|tur|jd«d}n;|j|j
dz«d}|t|j
«dzz
}t
|t¬«}|j||||t|«z||«|j|«y)Nr€r„ú({ú})r"r‚) rbrMrjrwÚsetr3r…r&r�) r*rrrrmrnroÚtypr”s rÚ _pprint_setzPrettyPrinter._pprint_sets­€Ü�6Œ{Ø �L‰Lœ˜f›Ô &Ø Ø×ÑˆØ ”#‰:Ø �L‰L˜Ô ؉Gà �L‰L˜Ÿ™¨Ñ,Ô -؈GØ ”c˜#Ÿ,™,Ó'¨!Ñ+Ñ +ˆFܘ¤IÔ.ˆØ ×ј6 6¨6°9¼sÀ7»|Ñ3KØ" Eô +à� ‰ �WÕrcóº—|j}t|«s|t|««yg}|jd«} |dk(r
|dz
}|dz
}|j|z
x}
} t | «D�]\} }
t|
«}| t| «dz
k(r|
|z}
t|«|
kr|j
|«ŒHtjd|
«}|sJ‚|drJ‚|j«| }d}t |«D]i\}}||z}|t|«dz
k(r| t| «dz
k(r||z}tt|««|kDr|r|j
t|««|}Œh|}Œk|sŒ÷|j
t|««�Œt|«dk(r |«y|dk(r|d«t |«D] \} }| dkDr|dd |zz«||«Œ"|dk(r |d
«yy) NTr"z\S*\s*éÿÿÿÿÚrurrKr�rv)
rMrbrjÚ
splitlinesrBÚ enumerateÚappendÚreÚfindallÚpop)r*rrrrmrnrorMÚchunksÚlinesÚ
max_width1rrÚiÚlinerqÚpartsÚ
max_width2ÚcurrentÚjÚpartÚ candidates rÚ _pprint_strzPrettyPrinter._pprint_strsì€Ø— ‘ ˆÜ�6Œ{Ù ”$�v“,Ô Ø ØˆØ×!Ñ! $Ó'ˆØ �AŠ:Ø �a‰KˆFØ ˜‰NˆIØ!%§¡¨vÑ!5Ð5ˆ
�YÜ  Ó'ó 1‰GˆAˆtÜ�t“*ˆCØ”C˜“J ‘NÒ"ؘiÑ'�
Ü�3‹x˜:Ò%Ø—
‘
˜cÕ"ôŸ
™
 9¨dÓ3�Ù� �uØ  š9Ð$�}Ø— ‘ ” Ø&�
Ø�Ü(¨Ó/ò ,‘G�A�tØ '¨$¡�IØœC ›J¨™NÒ*¨q´C¸³JÀ±NÒ/BØ" iÑ/˜
Üœ4  ›?Ó+¨jÒ8Ù"Ø"ŸM™M¬$¨w«-Ô8Ø"&™à"+™ð ,òØ—M‘M¤$ w£-Ö0ð3 1ô4 ˆv‹;˜!Ò Ù �#ŒJØ Ø �AŠ:Ù �#ŒJÜ Ó'ò ‰FˆAˆsØ�1ŠuÙ�d˜S ™ZÑ'Ô(Ù �#�Jð ð �AŠ:Ù �#�Jð rcó—|j}t|«dkr|t|««y|dk(}|r|dz
}|dz
}|d«d} t||j|z
|«D]}
|| «||
«| rŒdd|zz} Œ|r |d«yy)Nér"ruržrKr�rv)rMrbrjÚ_wrap_bytes_reprrB) r*rrrrmrnrorMÚparensÚdelimrqs rÚ
_pprint_byteszPrettyPrinter._pprint_bytesGs¡€Ø— ‘ ˆÜ ˆv‹;˜!Ò Ù ”$�v“,Ô Ø Ø˜!‘ˆÙ Ø �a‰KˆFØ ˜‰NˆIÙ �#ŒJ؈Ü# F¨D¯K©K¸&Ñ,@À)ÓLò *ˆCÙ �%ŒLÙ �#ŒJÚØ˜s 6™zÑ)‘ð  *ñ
Ù �#�Jð rc óŒ—|j}|d«|jt|«||dz|dz||dz«|d«y)Nz
bytearray(é
r"rv)rMr¶Úbytes)r*rrrrmrnrorMs rÚ_pprint_bytearrayzPrettyPrinter._pprint_bytearray\sE€Ø— ‘ ˆÙ
ˆlÔØ ×Ñœ5 ›=¨&°&¸2±+Ø$ q™=¨'°5¸1±9ô >á
ˆc�
rcóœ—|jd«|j|j«||dz|dz||«|jd«y)Nz
mappingproxy(é
r"rv)rMrLÚcopyr‘s rÚ_pprint_mappingproxyz"PrettyPrinter._pprint_mappingproxyesA€Ø� ‰ �_Ô%Ø � ‰ �V—[‘[“] F¨F°R©K¸ÀQ¹Ø˜eô %à� ‰ �SÕrcó8—t|«tjurd}n|jj}|t |«dzz
}|j j«}|j|dz«|j||||||«|jd«y)NÚ namespacer"rurv)
r/Ú_typesÚSimpleNamespacerwr3rbÚ__dict__r~rMr{) r*rrrrmrnror|r~s rÚ_pprint_simplenamespacez%PrettyPrinter._pprint_simplenamespacems†€Ü �‹<œ6×1Ñ1Ñ 1ð#‰Hà×'Ñ'×0Ñ0ˆHØ”#�h“- !Ñ#Ñ#ˆØ—‘×%Ñ%Ó'ˆØ� ‰ �X ‘^Ô$Ø ×$Ñ$ U¨F°F¸IÀwÐPUÔVØ� ‰ �SÕrc óJ—|j}||jz
}dd|zz}t|«dz
} t|«D]d\}
\} } |
| k(}
|j | ||«}||«|d«|j | ||t|«zdz|
r|nd||«|
rŒ]||«Œfy)Nú,
r�r"ú: r$)rMrArbr rarL)r*r~rrrmrnrorMÚdelimnlÚ
last_indexr¨rƒÚentÚlastrqs rr†z PrettyPrinter._format_dict_items|s³€à— ‘ ˆØ�$×(Ñ(Ñ(ˆØ˜# ™,Ñ&ˆÜ˜“Z !‘^ˆ
Ü& uÓ-ò ‰MˆA‰z��Sؘ
‘?ˆDØ—*‘*˜S '¨5Ó1ˆCÙ �#ŒJÙ �$ŒKØ �L‰L˜˜f f¬s°3«xÑ&7¸!Ñ&;Ù&*™°Ø  %ô
)òÙ�g•ñ rc ó2—|j}dd|zz}t|«dz
} t|«D]g\}
\} } |
| k(}
|| «|d«t| «|vr |d«n)|j | ||t| «zdz|
r|nd||«|
rŒ`||«Œiy)NrÆr�r"ú=ú...)rMrbr r0rL)r*r~rrrmrnrorMrÈrÉr¨rƒrÊrËs rr{z%PrettyPrinter._format_namespace_items�s¦€Ø— ‘ ˆØ˜# ™,Ñ&ˆÜ˜“Z !‘^ˆ
Ü& uÓ-ò
‰MˆA‰z��Sؘ
‘?ˆDÙ �#ŒJÙ �#ŒJÜ�#‹w˜'Ñ!ñ�e• à— ‘ ˜S &¨&´3°s³8Ñ*;¸aÑ*?Ù*.™Y°AØ$ eô-òÙ�g•ñ
rcód—|j}||jz
}|jdkDr||jdz
dz«dd|zz}d} |j|z
dzx}