Your IP : 18.220.226.147


Current Path : /opt/alt/python39/lib64/python3.9/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/lib2to3/__pycache__/fixer_util.cpython-39.opt-2.pyc

a

R�ff;�@s�ddlmZddlmZmZddlmZddlm	Z	dd�Z
dd�Zd	d
�Zdd�Z
dMdd�Zdd�Zdd�Zdd�Ze�e�fdd�ZdNdd�Zdd�Zdd�ZdOdd�Zd d!�ZdPd"d#�ZdQd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zhd0�Zd1d2�Z d3a!d4a"d5a#d6a$d7d8�Z%d9d:�Z&d;d<�Z'd=d>�Z(d?d@�Z)dAdB�Z*dCdD�Z+dEdF�Z,ej-ej.hZ/dRdGdH�Z0ej.ej-ej1hZ2dIdJ�Z3dSdKdL�Z4d
S)T�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�7/opt/alt/python39/lib64/python3.9/lib2to3/fixer_util.py�
KeywordArgs�rcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)N� r��prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

�rNcCsttj||d�S�Nr)rr�NAME)�namerrrr
�Name$sr!cCs|ttjt�|g�gS�N)rr�trailer�Dot)�obj�attrrrr
�Attr(sr'cCsttjd�S)N�,)rr�COMMArrrr
�Comma,sr*cCsttjd�S)N�.)rr�DOTrrrr
r$0sr$cCs4ttj|��|��g�}|r0|�dttj|��|S)Nr)rrr#�clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr2cCs&ttj|t|�g�}|dur"||_|Sr")rr�powerr2r)Z	func_namer0rr1rrr
�Call;sr4cCsttjd�S)N�
�rr�NEWLINErrrr
�NewlineBsr8cCsttjd�S)N�r6rrrr
�	BlankLineFsr:cCsttj||d�Sr)rr�NUMBER)�nrrrr
�NumberJsr=cCs"ttjttjd�|ttjd�g�S)N�[�])rrr#rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMs
�rBcCsttj||d�Sr)rr�STRING)�stringrrrr
�StringSsrEc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|�ttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)Nr9r�for�in�ifr>r?)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr@rA)	Zxp�fp�it�testZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs(

��rNcCsV|D]}|��qttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)N�fromrr�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos


�rVc	Cs�|d��}|jtjkr"|��}nttj|��g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|d��||d��g�g|�}|j	|_	|S)	Nr%�aftercSsg|]}|���qSr)r-)�.0r<rrr
�
<listcomp>��z!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r-�typerr/rr3r'r!r#r)r1�results�namesr%Z
newarglistrW�newrrr
�
ImportAndCall�s*


�����r`cCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)NT�r[r�rr)rrrTrr�lenrr�r1rrr
�is_tuple�s
������recCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)Nrr[���r>r?)rrrcrTrrrdrrr
�is_list�s
�����rgcCsttjt�|t�g�Sr")rrrrrrdrrr
�parenthesize�srh>
�min�tuple�	enumerate�all�any�sortedr�max�sum�setccs$t||�}|r |Vt||�}q
dSr")�getattr)r%r&�nextrrr
�
attr_chain�s
rtzefor_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<node=any any*> ')' >
    any*
>
FcCspts&t�t�at�t�at�t�adatttg}t|t|d��D]*\}}i}|�||�r@|d|ur@dSq@dS)NT�parentr1F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprt�match)r1Zpatterns�patternrur]rrr
�in_special_context�s



r}cCs�|j}|dur|jtjkrdS|j}|jtjtjfvr:dS|jtjkrX|j	d|urXdS|jtj
ks�|jtjkr�|dur�|jtjks�|j	d|ur�dSdS)NFr[T)
Zprev_siblingr\rr,rur�funcdef�classdef�	expr_stmtrT�
parametersZ
typedargslistr))r1�prevrurrr
�is_probably_builtin�s&
��
��r�cCsJ|durF|jtjkr>t|j�dkr>|jd}|jtjkr>|jS|j}qdS)Nrbrr9)	r\r�suitercrTr�INDENTrru)r1�indentrrr
�find_indentations
r�cCs>|jtjkr|S|��}|jd}|_ttj|g�}||_|Sr")r\rr�r-rur)r1rur�rrr
�
make_suitesr�cCs$|jtjkr |j}|std��q|S)Nz,root found before file_input node was found.)r\rZ
file_inputru�
ValueErrorrdrrr
�	find_root&s

r�cCst|t|�|�}t|�Sr")�find_bindingr��bool)�packager r1Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfvSr")r\r�import_namerSrdrrr
�	is_import7sr�cCs.dd�}t|�}t|||�r dSd}}t|j�D]F\}}||�sDq2t|j|d��D]\}}||�sVqlqV||}qzq2|dkr�t|j�D]8\}}|jtjkr�|jr�|jdjtjkr�|d}q�q�|dur�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|�|t	tj|
��dS)NcSs |jtjko|jot|jd�S)Nr[)r\r�simple_stmtrTr�rdrrr
�is_import_stmt>s�z$touch_import.<locals>.is_import_stmtr[rrPrr)r�r�rkrTr\rr�rrCrr�rrrVr8r.)r�r r1r��rootZ
insert_pos�offset�idxZnode2�import_rTrrr
�touch_import;s8�
�
r�cCs�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n0|jtjtjfvr�t|t|jd�|�}|r�|}�n�|jtj	k�rt|t|jd�|�}|r�|}nTt
|jdd��D]@\}}|jtjkr�|j
dkr�t|t|j|d�|�}|r�|}q�nx|jtv�r2|jdj
|k�r2|}nTt|||��rF|}n@|jtjk�rbt|||�}n$|jtjk�r�t||jd��r�|}|r|�s�|St|�r|SqdS)Nrrfrbra�:�r[)rTr\rZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrkr�COLONr�	_def_syms�_is_import_bindingr�r�r�)r r1r��childZretr<�iZkidrrr
r�isB
r�cCsT|g}|rP|��}|jdkr4|jtvr4|�|j�q|jtjkr|j|kr|SqdS)N�)�popr\�_block_syms�extendrTrrr)r r1Znodesrrr
r��sr�cCs�|jtjkr�|s�|jd}|jtjkrx|jD]H}|jtjkrV|jdj|krt|Sq,|jtjkr,|j|kr,|Sq,nL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd���|kr�dS|jd}|�rtd|��rdS|jtj
k�r0t||��r0|S|jtjk�rh|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)Nrrbrfra�as)r\rr�rTZdotted_as_namesZdotted_as_namerrrrS�str�stripr�rRZimport_as_name�STAR)r1r r�rUr�Zlastr<rrr
r��s@





r�)N)NN)N)N)N)N)N)5Zpgen2rZpytreerrZpygramrrr9rrrrrr!r'r*r$r2r4r8r:r=rBrErNrVr`rergrhZconsuming_callsrtrwrxryrvr}r�r�r�r�r�r�r�rr~r�r�r#r�r�r�rrrr
�<module>sV




		-
*

?>