File: //lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyo
ó
áû²_c @ s´ d Z d d l m Z d d l m Z d d l m Z d d l m Z m Z m Z m
Z
m Z m Z d „ Z
d e j 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 j ƒ o( | j d j t j k S( Ni ( t
isinstanceR t Nodet childrent typeR t STRING( t stmt( ( s6 /usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyt is_docstring s t FixTupleParamsc B s, e Z d Z e Z d Z d „ Z d „ Z RS( i s
funcdef< 'def' any parameters< '(' args=any ')' >
['->' any] ':' suite=any+ >
|
lambda=
lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
':' body=any
>
c s0 d | k r ˆ j | | ƒ Sg ‰ | d } | d } | d j d j t j k ry d } | d j d j } t ƒ ‰ n! d } d } t j t j d ƒ ‰ t ‡ ‡ ‡ f d † } | j t
j k rÑ | | ƒ n` | j t
j k r1xK t
| j ƒ D]7 \ } } | j t
j k ró | | d
| d k ƒqó qó Wn ˆ s;d Sx ˆ D] }
| d |
_ qBW| } | d k r{d ˆ d _ n1 t | d j | ƒ r¬| ˆ d _ | d } n x ˆ D] }
| d |
_ q³Wˆ | d j | | +x= t | d | t ˆ ƒ d ƒ D] } | | d j | _ q W| d j ƒ d S( Nt lambdat suitet argsi i i u ; u c s‡ t ˆ j ƒ ƒ } | j ƒ } d | _ t | | j ƒ ƒ } | rN d | _ n | j | ƒ ˆ j t j t j
| ˆ j ƒ 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 endt new_linest self( s6 /usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyt handle_tupleC 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.7/lib2to3/fixes/fix_tuple_params.pyt transform. sF
(c C sN | d } | d } t | d ƒ } | j t j k r\ | j ƒ } d | _ | j | ƒ d St | ƒ } t | ƒ } | j t
| ƒ ƒ } t | d d ƒ} | j | j ƒ ƒ x™ | j ƒ D]‹ }
|
j t j k r» |
j
| k r» g | |
j
D] } | j ƒ ^ qð } t j t j | j ƒ g | ƒ }
|
j |
_ |
j |
ƒ 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 ct
subscriptst new( ( s6 /usr/lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyR"