Ñò §ÚêLc @ s´ d Z d d k l Z d d k l Z d d k l Z d d k l Z l Z l Z l Z l Z l Z d „ Z d e i f d „ ƒ YZ d „ Z d „ Z g d d „ Z d „ Z d 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 ( t pytree( t token( t fixer_base( t Assignt Namet Newlinet Numbert Subscriptt symsc C s* t | t i ƒ o | i d i t i j S( Ni ( t isinstanceR t Nodet childrent typeR t STRING( t stmt( ( s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyt is_docstring s t FixTupleParamsc B s e Z d Z d „ Z d „ Z RS( s funcdef< 'def' any parameters< '(' args=any ')' > ['->' any] ':' suite=any+ > | lambda= lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > ':' body=any > c s@ d | j o ˆ i | | ƒ Sg ‰ | d } | d } | d i d i t i j o' d } | d i d i } t ƒ ‰ n" d } d } t i t i d ƒ ‰ t ‡ ‡ ‡ f d † } | i t i j o | | ƒ ne | i t i j oQ xN t | i ƒ D]9 \ } } | i t i j o | | d | d j ƒqú qú Wn ˆ p d Sx ˆ D] } | d | _ qNW| } | d j o d ˆ d _ n4 t | d i | ƒ o | ˆ d _ | d } n x ˆ D] } | d | _ qÃWˆ | d i | | +x= t | d | t ˆ ƒ d ƒ D] } | | d i | _ qW| d i ƒ d S( Nt lambdat suitet argsi i i u ; u c s‰ t ˆ i ƒ ƒ } | i ƒ } d | _ t | | i ƒ ƒ } | o d | _ n | i | ƒ ˆ i t i t i | ˆ i ƒ g ƒ ƒ d S( Nu u ( R t new_namet clonet prefixR t replacet appendR R R t simple_stmt( t tuple_argt add_prefixt nt argR ( t new_linest endt self( s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyt handle_tuple? s R u ( t transform_lambdaR R R t INDENTt valueR R t Leaft FalseR t tfpdeft typedargslistt enumeratet parentR R t ranget lent changed( R t nodet resultsR R t startt indentR! t iR t linet after( ( R R R s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyt transform* sN " " c C s[ | d } | d } t | d ƒ } | i t i j o' | i ƒ } d | _ | i | ƒ d St | ƒ } t | ƒ } | i t | ƒ ƒ } t | d d ƒ} | i | i ƒ ƒ x¤ | i ƒ D]– } | i t i j o} | i | j om g } | | i D] } | | i ƒ qø ~ } t i t i | i ƒ g | ƒ } | i | _ | i | ƒ q½ q½ Wd S( NR t bodyt inneru R ( t simplify_argsR R t NAMER R R t find_paramst map_to_indexR t tuple_nameR t post_orderR$ R R R t power( R R. R/ R R6 R7 t paramst to_indext tup_namet new_paramR t _[1]t ct subscriptst new( ( s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyR" j s* #.( t __name__t __module__t PATTERNR5 R" ( ( ( s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyR s @c C su | i t i t i f j o | S| i t i j o- x% | i t i j o | i d } q7 W| St d | ƒ ‚ d S( Ni s Received unexpected node %s( R R t vfplistR R9 t vfpdefR t RuntimeError( R. ( ( s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyR8 ‡ s c C s | i t i j o t | i d ƒ S| i t i j o | i Sg } | i D]* } | i t i j o | t | ƒ qN qN ~ S( Ni ( R R RK R: R R R9 R$ t COMMA( R. RC RD ( ( s6 /usr/lib64/python2.6/lib2to3/fixes/fix_tuple_params.pyR: ’ s c C sˆ | d j o h } n xj t | ƒ D]\ \ } } t t t | ƒ ƒ ƒ g } t | t ƒ o t | | d | ƒq$ | | | |