U if@sddlmZddlmZddlmZddlmZmZmZm Z m Z m Z ddZ Gdddej Zd d Zd d Zgd fddZddZd S))pytree)token) fixer_base)AssignNameNewlineNumber SubscriptsymscCst|tjo|jdjtjkS)N) isinstancerNodechildrentyperSTRING)stmtrC/opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_tuple_params.py is_docstrings rc@s(eZdZdZdZdZddZddZdS) FixTupleParamsTa funcdef< 'def' any parameters< '(' args=any ')' > ['->' any] ':' suite=any+ > | lambda= lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > ':' body=any > c sd|kr||Sg|d}|d}|djdjtjkrZd}|djdj}tnd}d}ttjddfd d }|jt j kr||n<|jt j krt |jD]$\}} | jt j kr|| |dkd qsdSD]} |d| _ q|} |dkr d d_n&t|dj|r0|d_|d} D]} |d| _ q4|dj| | <t| d| tdD]}||dj|_qr|ddS)Nlambdasuiteargsr rz; Fcs\t}|}d|_t||}|r2d|_||tt j |gdS)Nr ) rnew_namecloneprefixrreplaceappendrr r Z simple_stmt)Z tuple_arg add_prefixnargrendZ new_linesselfrr handle_tupleCs    z.FixTupleParams.transform..handle_tuple)r"r)F)transform_lambdarrrINDENTvaluerrZLeafr ZtfpdefZ typedargslist enumerateparentrrrangelenZchanged) r'noderesultsrrstartindentr(ir$lineZafterrr%r transform.sF         zFixTupleParams.transformc Cs|d}|d}t|d}|jtjkrD|}d|_||dSt|}t|}| t |}t |dd} || | D]X} | jtjkr| j |krdd|| j D} ttj| g| } | j| _| | qdS)Nrbodyinnerr)rcSsg|] }|qSr)r.0crrr sz3FixTupleParams.transform_lambda..) simplify_argsrrNAMErrr find_params map_to_indexr tuple_namerZ post_orderr+rr r Zpower) r'r0r1rr7r8ZparamsZto_indexZtup_nameZ new_paramr#Z subscriptsnewrrrr)ns*      zFixTupleParams.transform_lambdaN)__name__ __module__ __qualname__Z run_orderZ BM_compatibleZPATTERNr6r)rrrrrs  @rcCsN|jtjtjfkr|S|jtjkr>|jtjkr:|jd}q"|Std|dS)NrzReceived unexpected node %s)rr Zvfplistrr>vfpdefr RuntimeErrorr0rrrr=s   r=cCs<|jtjkrt|jdS|jtjkr,|jSdd|jDS)NrcSs g|]}|jtjkrt|qSr)rrCOMMAr?r9rrrr<s zfind_params..)rr rFr?rrr>r+rHrrrr?s   r?NcCsZ|dkr i}t|D]@\}}ttt|g}t|trHt|||dq||||<q|S)N)d)r,r rstrr listr@) param_listrrJr4objZtrailerrrrr@s r@cCs<g}|D](}t|tr&|t|q||qd|S)N_)r rLr!rAjoin)rMlrNrrrrAs   rA)rrZpgen2rrZ fixer_utilrrrrr r rZBaseFixrr=r?r@rArrrrs    l