Your IP : 18.221.221.171


Current Path : /opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/fix_tuple_params.cpython-35.opt-2.pyc



���]��@s�ddlmZddlmZddlmZddlmZmZmZm	Z	m
Z
mZdd�ZGdd�dej
�Zd	d
�Zdd�Zgd
dd�Zdd�Zd
S)�)�pytree)�token)�
fixer_base)�Assign�Name�Newline�Number�	Subscript�symscCs)t|tj�o(|jdjtjkS)N�)�
isinstancer�Node�children�typer�STRING)�stmt�r�5/opt/alt/python35/lib64/python3.5/fix_tuple_params.py�is_docstringsrc@s:eZdZdZdZdZdd�Zdd�ZdS)	�FixTupleParams�Ta
              funcdef< 'def' any parameters< '(' args=any ')' >
                       ['->' any] ':' suite=any+ >
              |
              lambda=
              lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
                       ':' body=any
              >
              cs-d|kr�j||�Sg�|d}|d}|djdjtjkryd}|djdj}t��n!d}d}tjtjd��d	���fd
d�}|jt	j
kr�||�nZ|jt	jkr.xEt|j�D]4\}}	|	jt	j
kr�||	d|dk�q�W�s8dSx�D]}
|d|
_
q?W|}|dkrxd
�d_n.t|dj|�r�|�d_|d}x�D]}
|d|
_
q�W�|dj||�<x=t|d|t��d�D]}||dj|_q�W|dj�dS)N�lambda�suite�argsr�rz; �Fcs�t�j��}|j�}d|_t||j��}|rKd|_|j|��jtjt	j
|�j�g��dS)Nr� )r�new_name�clone�prefixr�replace�appendrr
r
Zsimple_stmt)Z	tuple_arg�
add_prefix�n�argr)�end�	new_lines�selfrr�handle_tupleCs		
z.FixTupleParams.transform.<locals>.handle_tupler"r)�transform_lambdarrr�INDENT�valuerrZLeafr
ZtfpdefZ
typedargslist�	enumerate�parentrr�range�lenZchanged)r'�node�resultsrr�start�indentr(�ir$�line�afterr)r%r&r'r�	transform.sF






(zFixTupleParams.transformc
Cs?|d}|d}t|d�}|jtjkr\|j�}d|_|j|�dSt|�}t|�}|j	t
|��}t|dd�}	|j|	j��x�|j�D]|}
|
jtjkr�|
j
|kr�dd�||
j
D�}tjtj|	j�g|�}|
j|_|
j|�q�WdS)Nr�body�innerrrcSsg|]}|j��qSr)r)�.0�crrr�
<listcomp>�s	z3FixTupleParams.transform_lambda.<locals>.<listcomp>)�
simplify_argsrr�NAMErrr �find_params�map_to_indexr�
tuple_namerZ
post_orderr+rr
r
Zpower)
r'r0r1rr8r9�paramsZto_indexZtup_nameZ	new_paramr#Z
subscripts�newrrrr)ns(

	
!zFixTupleParams.transform_lambdaN)�__name__�
__module__�__qualname__Z	run_orderZ
BM_compatibleZPATTERNr7r)rrrrrs

@rcCso|jtjtjfkr|S|jtjkr[x#|jtjkrV|jd}q4W|Std|��dS)NrzReceived unexpected node %s)rr
Zvfplistrr>�vfpdefr�RuntimeError)r0rrrr=�sr=cCsP|jtjkr#t|jd�S|jtjkr<|jSdd�|jD�S)NrcSs.g|]$}|jtjkrt|��qSr)rr�COMMAr?)r:r;rrrr<�s	zfind_params.<locals>.<listcomp>)rr
rGr?rrr>r+)r0rrrr?�s
r?NcCs�|dkri}xht|�D]Z\}}ttt|���g}t|t�rkt||d|�q||||<qW|S)N�d)r,r	r�strr�listr@)�
param_listrrJr4�objZtrailerrrrr@�sr@cCsVg}x@|D]8}t|t�r8|jt|��q
|j|�q
Wdj|�S)N�_)rrLr!rA�join)rM�lrNrrrrA�s
rA)rrZpgen2rrZ
fixer_utilrrrrr	r
rZBaseFixrr=r?r@rArrrr�<module>s.l

?>