ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/usr/lib64/python2.7/lib2to3/fixes/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyc

�
{fc@s�dZddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZd�Z
dejfd��YZd	�Zd
�Zgd
d�Zd�Zd
S(s: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(tpytree(ttoken(t
fixer_base(tAssigntNametNewlinetNumbert	SubscripttsymscCs)t|tj�o(|jdjtjkS(Ni(t
isinstanceRtNodetchildrenttypeRtSTRING(tstmt((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pytis_docstringstFixTupleParamscBs,eZdZeZdZd�Zd�ZRS(is
              funcdef< 'def' any parameters< '(' args=any ')' >
                       ['->' any] ':' suite=any+ >
              |
              lambda=
              lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
                       ':' body=any
              >
              cs0d|kr�j||�Sg�|d}|d}|djdjtjkryd}|djdj}t��n!d}d}tjtjd��t	���fd	�}|jt
jkr�||�n`|jt
jkr1xKt
|j�D]7\}}	|	jt
jkr�||	d
|dk�q�q�Wn�s;dSx�D]}
|d|
_qBW|}|dkr{d�d_n1t|dj|�r�|�d_|d}nx�D]}
|d|
_q�W�|dj||+x=t|d|t��d�D]}||dj|_qW|dj�dS(Ntlambdatsuitetargsiiiu; ucs�t�j��}|j�}d|_t||j��}|rNd|_n|j|��jtjt	j
|�j�g��dS(Nuu (Rtnew_nametclonetprefixRtreplacetappendRR
Rtsimple_stmt(t	tuple_argt
add_prefixtntargR(tendt	new_linestself(s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pythandle_tupleCs	
Ru (ttransform_lambdaRRRtINDENTtvalueRRtLeaftFalseRttfpdeft
typedargslistt	enumeratetparentRRtrangetlentchanged(R tnodetresultsRRtstarttindentR!tiRtlinetafter((RRR s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyt	transform.sF


 



(cCsN|d}|d}t|d�}|jtjkr\|j�}d|_|j|�dSt|�}t|�}|j	t
|��}t|dd�}	|j|	j��x�|j�D]�}
|
jtjkr�|
j
|kr�g||
j
D]}|j�^q�}tjtj|	j�g|�}
|
j|
_|
j|
�q�q�WdS(NRtbodytinneru R(t
simplify_argsRRtNAMERRRtfind_paramstmap_to_indexRt
tuple_nameRt
post_orderR$RR
Rtpower(R R.R/RR6R7tparamstto_indexttup_namet	new_paramRtct
subscriptstnew((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyR"ns(

	
!&(t__name__t
__module__t	run_ordertTruet
BM_compatibletPATTERNR5R"(((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyRs

	@cCso|jtjtjfkr|S|jtjkr[x#|jtjkrV|jd}q4W|Std|��dS(NisReceived unexpected node %s(RRtvfplistRR9tvfpdefRtRuntimeError(R.((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyR8�scCsn|jtjkr#t|jd�S|jtjkr<|jSg|jD]$}|jtjkrFt|�^qFS(Ni(	RRRMR:RRR9R$tCOMMA(R.RC((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyR:�s
cCs�|dkri}nxht|�D]Z\}}ttt|���g}t|t�rnt||d|�q"||||<q"W|S(Ntd(tNoneR)RRtunicodeR	tlistR;(t
param_listRRPR2tobjttrailer((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyR;�s	cCsVg}x@|D]8}t|t�r8|jt|��q
|j|�q
Wdj|�S(Nu_(R	RSRR<tjoin(RTtlRU((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyR<�s
N(t__doc__tRtpgen2RRt
fixer_utilRRRRRRRtBaseFixRR8R:RQR;R<(((s6/usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyt<module>s.	l		

Zerion Mini Shell 1.0