Your IP : 3.15.142.42


Current Path : /opt/alt/python33/lib64/python3.3/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/lib2to3/fixes/__pycache__/fix_tuple_params.cpython-33.pyo

�
��f�c@s�dZddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZdd�Z
Gdd	�d	ej�Zd
d�Zdd
�Zgddd�Zdd�ZdS(u:Fixer for function definitions with tuple parameters.

def func(((a, b), c), d):
    ...

    ->

def func(x, d):
    ((a, b), c) = x
    ...

It will also support lambdas:

    lambda (x, y): x + y -> lambda t: t[0] + t[1]

    # The parens are a syntax error in Python 3
    lambda (x): x + y -> lambda x: x + y
i(upytree(utoken(u
fixer_base(uAssignuNameuNewlineuNumberu	SubscriptusymscCs)t|tj�o(|jdjtjkS(Ni(u
isinstanceupytreeuNodeuchildrenutypeutokenuSTRING(ustmt((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyuis_docstringsuis_docstringcBs>|EeZdZdZdZdZdd�Zdd�ZdS(	uFixTupleParamsiu
              funcdef< 'def' any parameters< '(' args=any ')' >
                       ['->' any] ':' suite=any+ >
              |
              lambda=
              lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
                       ':' body=any
              >
              cs6d|kr�j||�Sg�|d}|d}|djdjtjkryd}|djdj}t��n!d}d}tjtjd��d
���fd	d
�}|jt
jkr�||�n`|jt
jkr4xKt
|j�D]7\}}	|	jt
jkr�||	d|dk�q�q�Wn�s>dSx�D]}
|d|
_qEW|}|dkr~d�d_n1t|dj|�r�|�d_|d}nx�D]}
|d|
_q�W�|dj||�<x=t|d|t��d�D]}||dj|_qW|dj�dS(Nulambdausuiteuargsiiiu; ucs�t�j��}|j�}d|_t||j��}|rNd|_n|j|��jtjt	j
|�j�g��dS(Nuu (uNameunew_nameucloneuprefixuAssignureplaceuappendupytreeuNodeusymsusimple_stmt(u	tuple_argu
add_prefixunuargustmt(uendu	new_linesuself(uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyuhandle_tupleCs	
u.FixTupleParams.transform.<locals>.handle_tupleu
add_prefixu F(utransform_lambdauchildrenutypeutokenuINDENTuvalueuNewlineupytreeuLeafuFalseusymsutfpdefu
typedargslistu	enumerateuparentuprefixuis_docstringurangeulenuchanged(uselfunodeuresultsusuiteuargsustartuindentuhandle_tupleuiuargulineuafter((uendu	new_linesuselfuC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyu	transform.sF


 



(uFixTupleParams.transformc
CsB|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�q�WdS(Nuargsubodyuinneru uprefixcSsg|]}|j��qS((uclone(u.0uc((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyu
<listcomp>�s	u3FixTupleParams.transform_lambda.<locals>.<listcomp>(u
simplify_argsutypeutokenuNAMEucloneuprefixureplaceufind_paramsumap_to_indexunew_nameu
tuple_nameuNameu
post_orderuvalueupytreeuNodeusymsupower(
uselfunodeuresultsuargsubodyuinneruparamsuto_indexutup_nameu	new_paramunu
subscriptsunew((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyutransform_lambdans(

	
!uFixTupleParams.transform_lambdaNT(	u__name__u
__module__u__qualname__u	run_orderuTrueu
BM_compatibleuPATTERNu	transformutransform_lambda(u
__locals__((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyuFixTupleParamss

@uFixTupleParamscCso|jtjtjfkr|S|jtjkr[x#|jtjkrV|jd}q4W|Std|��dS(NiuReceived unexpected node %s(utypeusymsuvfplistutokenuNAMEuvfpdefuchildrenuRuntimeError(unode((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyu
simplify_args�su
simplify_argscCsP|jtjkr#t|jd�S|jtjkr<|jSdd�|jD�S(NicSs.g|]$}|jtjkrt|��qS((utypeutokenuCOMMAufind_params(u.0uc((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyu
<listcomp>�s	ufind_params.<locals>.<listcomp>(utypeusymsuvfpdefufind_paramsuchildrenutokenuNAMEuvalue(unode((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyufind_params�s
ufind_paramscCs�|dkri}nxht|�D]Z\}}ttt|���g}t|t�rnt||d|�q"||||<q"W|S(Nud(uNoneu	enumerateu	SubscriptuNumberustru
isinstanceulistumap_to_index(u
param_listuprefixuduiuobjutrailer((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyumap_to_index�s	umap_to_indexcCsVg}x@|D]8}t|t�r8|jt|��q
|j|�q
Wdj|�S(Nu_(u
isinstanceulistuappendu
tuple_nameujoin(u
param_listuluobj((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyu
tuple_name�s
u
tuple_nameN(u__doc__uupytreeupgen2utokenu
fixer_baseu
fixer_utiluAssignuNameuNewlineuNumberu	Subscriptusymsuis_docstringuBaseFixuFixTupleParamsu
simplify_argsufind_paramsuNoneumap_to_indexu
tuple_name(((uC/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_tuple_params.pyu<module>s.l

?>