Ë
c‡½jf; ã ó¸ — d Z ddlmZ ddlmZmZ ddlmZ ddl m
Z
d„ Zd„ Zd„ Z
d „ Zd-d„Zd„ Zd
„ Zd„ Z e« e
« fd„Zd.d„Zd„ Zd„ Zd-d„Zd„ Zd-d„Zd-d„Zd„ Zd„ Zd„ Zd„ Zd„ Zh d£Z d„ Z!da"da#d a$d!a%d"„ Z&d#„ Z'd$„ Z(d%„ Z)d&„ Z*d'„ Z+d(„ Z,d)„ Z-ej\ ej^ hZ0d-d*„Z1ej^ ej\ ejd hZ3d+„ Z4d-d,„Z5y
)/z1Utility functions, node construction macros, etc.é )Útoken)ÚLeafÚNode)Úpython_symbols)Úpatcompc ól — t t j | t t j
d« |g« S )NÚ=)r ÚsymsÚargumentr r ÚEQUAL)ÚkeywordÚvalues ú+/usr/lib64/python3.12/lib2to3/fixer_util.pyÚ
KeywordArgr s* € Ü”—
‘
Øœ$œuŸ{™{¨CÓ0°%Ð8ó:ð :ó c ó6 — t t j d« S )NÚ()r r ÚLPAR© r r ÚLParenr ó € Ü”—
‘
˜CÓ Ð r c ó6 — t t j d« S )NÚ))r r ÚRPARr r r ÚRParenr r r c óÒ — t | t « s| g} t |t « s
d|_ |g}t t j
| t
t j dd¬« gz |z « S )zBuild an assignment statementÚ r ©Úprefix) Ú
isinstanceÚlistr r r
Úatomr r r )ÚtargetÚsources r ÚAssignr% s] € ä�fœdÔ#Ø�ˆÜ�fœdÔ#؈Œ
Ø�ˆä”— ‘ Øœ$œuŸ{™{¨C¸Ô<Ð=Ñ=ÀÑFóHð Hr Nc ó: — t t j | |¬« S )zReturn a NAME leafr )r r ÚNAME)Únamer s r ÚNamer) $ s € ä”—
‘
˜D¨Ô0Ð0r c óN — | t t j t « |g« gS )zA node tuple for obj.attr)r r
ÚtrailerÚDot)ÚobjÚattrs r ÚAttrr/ ( s € à””d—l‘l¤S£U¨D MÓ2Ð3Ð3r c ó6 — t t j d« S )zA comma leafÚ,)r r ÚCOMMAr r r ÚCommar3 , s € ä”—‘˜SÓ!Ð!r c ó6 — t t j d« S )zA period (.) leafÚ.)r r ÚDOTr r r r, r, 0 s € ä”— ‘ ˜3ÓÐr c óÎ — t t j |j « |j « g« }| r*|j dt t j
| « « |S )z-A parenthesised argument list, used by Call()r )r r
r+ ÚcloneÚinsert_childÚarglist)ÚargsÚlparenÚrparenÚnodes r ÚArgListr? 4 sF € ä”—‘˜vŸ|™|›~¨v¯|©|«~Ð>Ó?€DÙØ×ј!œT¤$§,¡,°Ó5Ô6Ø€Kr c ób — t t j | t |« g« }|�||_ |S )zA function call)r r
Úpowerr? r )Ú func_namer; r r> s r ÚCallrC ; s- € ä”—
‘
˜Y¬°«
Ð6Ó7€DØ
ÐØˆŒØ€Kr c ó6 — t t j d« S )zA newline literalÚ
©r r ÚNEWLINEr r r ÚNewlinerH B s € ä”—
‘
˜tÓ$Ð$r c ó6 — t t j d« S )zA blank lineÚ rF r r r Ú BlankLinerK F s € ä”—
‘
˜rÓ"Ð"r c ó: — t t j | |¬« S )Nr )r r ÚNUMBER)Únr s r ÚNumberrO J s € Ü”—‘˜a¨Ô/Ð/r c óœ — t t j t t j
d« | t t j d« g« S )zA numeric or string subscriptÚ[Ú])r r
r+ r r ÚLBRACEÚRBRACE)Ú
index_nodes r Ú SubscriptrV M s8 € ä”—‘œt¤E§L¡L°#Ó6Ø)Ü#¤E§L¡L°#Ó6ð8ó 9ð 9r c ó: — t t j | |¬« S )z
A string leafr )r r ÚSTRING)Ústringr s r ÚStringrZ S s € ä”—‘˜f¨VÔ4Ð4r c óh — d| _ d|_ d|_ t t j d« }d|_ t t j d« }d|_ ||||g}|rSd|_ t t j d« }d|_ |j t t j ||g« « t t j | t t j |« g« }t t j t t j d« |t t j d« g« S )zuA list comprehension of the form [xp for fp in it if test].
If test is None, the "if test" part is omitted.
rJ r ÚforÚinÚifrQ rR )
r r r r' Úappendr r
Úcomp_ifÚ listmakerÚcomp_forr" rS rT ) ÚxpÚfpÚitÚtestÚfor_leafÚin_leafÚ
inner_argsÚif_leafÚinners r ÚListComprl W sê € ð
€B„IØ€B„IØ€B„IÜ”E—J‘J Ó&€HØ€H„OÜ”5—:‘:˜tÓ$€GØ€G„NؘB ¨Ð,€JÙØˆŒÜ”u—z‘z 4Ó(ˆØˆŒØ×Ñœ$œtŸ|™|¨g°t¨_Ó=Ô>Ü”—‘ "¤d¬4¯=©=¸*Ó&EÐ!FÓG€EÜ”— ‘ ÜœUŸ\™\¨3Ó/ØÜœUŸ\™\¨3Ó/ð1ó2ð 2r c ó< — |D ] }|j « Œ t t j d« t t j | d¬« t t j dd¬« t t
j |« g}t t
j |« }|S )zO Return an import statement in the form:
from package import name_leafsÚfromr r Úimport)Úremover r r' r r
Úimport_as_namesÚimport_from)Úpackage_nameÚ
name_leafsÚleafÚchildrenÚimps r Ú
FromImportrx o sw € ó ˆà�‰�
ð ô ”U—Z‘Z Ó(Ü”U—Z‘Z °cÔ:Ü”U—Z‘Z °#Ô6Ü”T×)Ñ)¨:Ó6ð8€Hô Œt×Ñ Ó
*€CØ€Jr c óN — |d j « }|j t j k( r|j « }n)t t j |j « g« }|d }|r|D �cg c] }|j « ‘Œ }}t t j
t
t |d « t |d « « t t j |d j « ||d j « g« gz |z « }| j |_ |S c c}w )zfReturns an import statement and calls a method
of the module:
import module
module.name()r- Úafteré r ÚlparÚrpar)
r8 Útyper
r: r rA r/ r) r+ r )r> ÚresultsÚnamesr- Ú
newarglistrz rN Únews r Ú
ImportAndCallrƒ ‚ sû € ð �%‰.×
Ñ
Ó
€CØ
‡x�x”4—<‘<ÒØ—Y‘Y“[‰
äœ$Ÿ,™,¨¯©«¨
Ó6ˆ
Ø�GÑ€EÙÙ$)Ó*¡E˜q�—‘• EˆÐ*Ü
Œt�z‰zÜ”D˜˜q™“N¤D¨¨q©£NÓ3Ü”T—\‘\ؘf‘o×+Ñ+Ó-Ø Ø˜f‘o×+Ñ+Ó-ð/ó0ð 1ñ1ð 49ñ 9ó:€Cð —‘€C„JØ€Jùò +s Á6D"c óì — t | t « r"| j t « t « gk( ryt | t « xr± t | j « dk( xr— t | j d t « xrx t | j d t « xrY t | j d t « xr: | j d j dk( xr | j d j dk( S )z(Does the node represent a tuple literal?Té r{ r é r r )r r rv r r Úlenr r ©r> s r Úis_tupler‰ ž sÐ € ä�$œÔ $§-¡-´F³H¼f»hÐ3GÒ"GØÜ�tœTÓ"ò
.Ü�D—M‘MÓ" aÑ'ò
.ä˜4Ÿ=™=¨Ñ+¬TÓ2ò
.ô ˜4Ÿ=™=¨Ñ+¬TÓ2ò
.ô ˜4Ÿ=™=¨Ñ+¬TÓ2ò
.ð
—
‘
˜aÑ ×&Ñ&¨#Ñ-ò
.ð —
‘
˜aÑ ×&Ñ&¨#Ñ-ð
/r c óJ — t | t « xr’ t | j « dkD xrx t | j d t « xrY t | j d t « xr: | j d j
dk( xr | j d j
dk( S )z'Does the node represent a list literal?r r{ éÿÿÿÿrQ rR )r r r‡ rv r r rˆ s r Úis_listrŒ ª s• € ä�tœTÓ"ò
/Ü�D—M‘MÓ" QÑ&ò
/ä˜4Ÿ=™=¨Ñ+¬TÓ2ò
/ô ˜4Ÿ=™=¨Ñ,¬dÓ3ò
/ð —
‘
˜aÑ ×&Ñ&¨#Ñ-ò
/ð
—
‘
˜bÑ!×'Ñ'¨3Ñ.ð0r c ó\ — t t j t « | t « g« S ©N)r r
r" r r rˆ s r Úparenthesizer� ¸ s € Ü”— ‘ œF›H d¬F«HÐ5Ó6Ð6r >
ÚallÚanyÚmaxÚminÚsetÚsumr! ÚtupleÚsortedÚ enumeratec # óP K — t | |« }|r|–— t ||« }|rŒyyw)al Follow an attribute chain.
If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
use this to iterate over all objects in the chain. Iteration is
terminated by getattr(x, attr) is None.
Args:
obj: the starting object
attr: the name of the chaining attribute
Yields:
Each successive object in the chain.
N)Úgetattr)r- r. Únexts r Ú
attr_chainrœ ¿ s- è ø€ ô �3˜Ó€DÙ
ØŠ
Ü�t˜TÓ"ˆô ùs ‚!&¤&zefor_stmt< 'for' any 'in' node=any ':' any* >
| comp_for< 'for' any 'in' node=any any* >
z³
power<
( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
trailer< '(' node=any ')' >
any*
>
z`
power<
( 'sorted' | 'enumerate' )
trailer< '(' arglist