Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/libfuturize/fixes/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/libfuturize/fixes/__pycache__/fix_next_call.cpython-36.pyc

3

�uGhV�@sndZddlmZddlmZddlmZddlm	Z	m
Z
mZdZGdd�dej
�Zd	d
�Zdd�Zd
d�ZdS)a
Based on fix_next.py by Collin Winter.

Replaces it.next() -> next(it), per PEP 3114.

Unlike fix_next.py, this fixer doesn't replace the name of a next method with __next__,
which would break Python 2 compatibility without further help from fixers in
stage 2.
�)�token)�python_symbols)�
fixer_base)�Name�Call�find_bindingz;Calls to builtin next() possibly shadowed by global bindingcs0eZdZdZdZdZ�fdd�Zdd�Z�ZS)�FixNextCallTz�
    power< base=any+ trailer< '.' attr='next' > trailer< '(' ')' > >
    |
    power< head=any+ trailer< '.' attr='next' > not trailer< '(' ')' > >
    |
    global=global_stmt< 'global' any* 'next' any* >
    �precs>tt|�j||�td|�}|r4|j|t�d|_nd|_dS)N�nextTF)�superr�
start_treer�warning�bind_warning�
shadowed_next)�self�tree�filename�n)�	__class__��F/root/tmp/pip-build-gzoz1_uw/future/libfuturize/fixes/fix_next_call.pyr s
zFixNextCall.start_treecCs�|st�|jd�}|jd�}|jd�}|rf|jr2q�dd�|D�}d|d_|jttd|jd	�|��nb|rln\|r�t|�r�|d
}djdd�|D��j	�dkr�|j
|t�dSnd
|kr�|j
|t�d|_dS)N�base�attr�namecSsg|]}|j��qSr)�clone)�.0rrrr�
<listcomp>7sz)FixNextCall.transform.<locals>.<listcomp>�rr
)�prefix�headcSsg|]}t|��qSr)�str)rrrrrrEs�__builtin__�globalT)�AssertionError�getrr�replacerr�is_assign_target�join�stripr
r)r�node�resultsrrrrrrr�	transform*s*



zFixNextCall.transform)	�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERN�orderrr+�
__classcell__rr)rrrs

rcCsFt|�}|dkrdSx,|jD]"}|jtjkr0dSt||�rdSqWdS)NFT)�find_assign�children�typer�EQUAL�
is_subtree)r)Zassign�childrrrr&Rs
r&cCs4|jtjkr|S|jtjks&|jdkr*dSt|j�S)N)r3�symsZ	expr_stmtZsimple_stmt�parentr1)r)rrrr1^s
r1cs$|�krdSt�fdd�|jD��S)NTc3s|]}t|��VqdS)N)r5)r�c)r)rr�	<genexpr>hszis_subtree.<locals>.<genexpr>)�anyr2)�rootr)r)r)rr5esr5N)�__doc__Z
lib2to3.pgen2rZlib2to3.pygramrr7Zlib2to3rZlib2to3.fixer_utilrrrrZBaseFixrr&r1r5rrrr�<module>	s>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists