Your IP : 3.16.130.96


Current Path : /lib64/python3.6/lib2to3/__pycache__/
Upload File :
Current File : //lib64/python3.6/lib2to3/__pycache__/fixer_util.cpython-36.opt-2.pyc

3


 \g;�
@s�ddlmZddlmZmZddlmZddlm	Z	dd�Z
dd�Zd	d
�Zdd�Z
dVdd�Zdd�Zdd�Zdd�Ze�e�fdd�ZdWdd�Zdd�Zdd�ZdXdd�Zd d!�ZdYd"d#�ZdZd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1d2d3d4d5d6d7d8d9h
Zd:d;�Z d<a!d=a"d>a#d?a$d@dA�Z%dBdC�Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,ej-ej.hZ/d[dPdQ�Z0ej.ej-ej1hZ2dRdS�Z3d\dTdU�Z4d
S)]�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.6/lib2to3/fixer_util.py�
KeywordArgsrcCs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)N)r)rr�NAME)�namerrrr
�Name$srcCs|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|j�|j�g�}|r0|jdttj|��|S)Nr)rrr �clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr/cCs&ttj|t|�g�}|dk	r"||_|S)N)rr�powerr/r)Z	func_namer-rr.rrr
�Call;sr1cCsttjd�S)N�
)rr�NEWLINErrrr
�NewlineBsr4cCsttjd�S)N�)rrr3rrrr
�	BlankLineFsr6cCsttj||d�S)N)r)rr�NUMBER)�nrrrr
�NumberJsr9cCs"ttjttjd�|ttjd�g�S)N�[�])rrr rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMsr>cCsttj||d�S)N)r)rr�STRING)�stringrrrr
�StringSsrAc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|jttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)Nr5r�for�in�ifr:r;)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr<r=)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs$
rIcCsZx|D]}|j�qWttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)N�fromr)r�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos

rQc	Cs�|dj�}|jtjkr"|j�}nttj|j�g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|dj�||dj�g�g|�}|j	|_	|S)	Nr"�aftercSsg|]}|j��qSr)r*)�.0r8rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r*�typerr,rr0r$rr r)r.�results�namesr"Z
newarglistrR�newrrr
�
ImportAndCall�s
DrZcCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)NT�rUr�rr)rrrOrr�lenrr)r.rrr
�is_tuple�s
r^cCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)NrrUr:r;���r_)rrr]rOrr)r.rrr
�is_list�s
r`cCsttjt�|t�g�S)N)rrrrr)r.rrr
�parenthesize�sra�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs(t||�}x|r"|Vt||�}qWdS)N)�getattr)r"r#�nextrrr
�
attr_chain�s
rmzefor_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*
>
FcCsrts&tjt�atjt�atjt�adatttg}x<t|t|d��D](\}}i}|j||�rB|d|krBdSqBWdS)NT�parentr.F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprm�match)r.Zpatterns�patternrnrWrrr
�in_special_context�s



rvcCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)NFrUT)
Zprev_siblingrVrr)rnr�funcdef�classdef�	expr_stmtrOZ
parametersZ
typedargslistr&)r.�prevrnrrr
�is_probably_builtin�sr{cCsNxH|dk	rH|jtjkr@t|j�dkr@|jd}|jtjkr@|jS|j}qWdS)Nr\rr5)	rVr�suiter]rOr�INDENTrrn)r.�indentrrr
�find_indentations


rcCs>|jtjkr|S|j�}|jd}|_ttj|g�}||_|S)N)rVrr|r*rnr)r.rnr|rrr
�
make_suitesr�cCs(x"|jtjkr"|j}|std��qW|S)Nz,root found before file_input node was found.)rVrZ
file_inputrn�
ValueError)r.rrr
�	find_root&s
r�cCst|t|�|�}t|�S)N)�find_bindingr��bool)�packagerr.Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkS)N)rVr�import_namerN)r.rrr
�	is_import7sr�cCs4dd�}t|�}t|||�r dSd}}xTt|j�D]F\}}||�sFq4x(t|j|d��D]\}}||�sZPqZW||}Pq4W|dkr�xDt|j�D]6\}}|jtjkr�|jr�|jdjtjkr�|d}Pq�W|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|j|t	tj|
��dS)NcSs |jtjko|jot|jd�S)NrU)rVr�simple_stmtrOr�)r.rrr
�is_import_stmt>sz$touch_import.<locals>.is_import_stmtrUrrKr)r)r�r�rjrOrVrr�rr?rr�rrrQr4r+)r�rr.r��rootZ
insert_pos�offset�idxZnode2�import_rOrrr
�touch_import;s4

r�cCs��x�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n4|jtjtjfkr�t|t|jd�|�}|r�|}�n|jtj	k�rt|t|jd�|�}|r�|}nXx�t
|jdd��D]@\}}|jtjko�|j
dkr�t|t|j|d�|�}|r�|}q�Wnx|jtk�r6|jdj
|k�r6|}nTt|||��rJ|}n@|jtjk�rft|||�}n$|jtjk�r�t||jd��r�|}|r
|�s�|St|�r
|Sq
WdS)	Nrr\r[�:�rUr_r_)rOrVrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrjr�COLONr�	_def_syms�_is_import_bindingr�ryr�)rr.r��childZretr8�iZkidrrr
r�isH
r�cCsX|g}xL|rR|j�}|jdkr6|jtkr6|j|j�q|jtjkr|j|kr|SqWdS)N�)�poprV�_block_syms�extendrOrrr)rr.Znodesrrr
r��sr�cCs�|jtjkr�|r�|jd}|jtjkrvx�|jD]@}|jtjkrV|jdj|krp|Sq0|jtjkr0|j|kr0|Sq0WnL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd�j�|kr�dS|jd}|�rtd|��rdS|jtj
k�r.t||��r.|S|jtjk�rf|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)Nrr\r[�asr_)rVrr�rOZdotted_as_namesZdotted_as_namerrrrN�str�stripr�rMZimport_as_name�STAR)r.rr�rPr�Zlastr8rrr
r��s@




r�)N)NN)N)N)N)N)N)5Zpgen2rZpytreerrZpygramrrr5rrrrrrr$r'r!r/r1r4r6r9r>rArIrQrZr^r`raZconsuming_callsrmrprqrrrorvr{rr�r�r�r�r�rxrwr�r�r r�r�r�rrrr
�<module>sX





		-
*

?>