ok
Direktori : /lib64/python2.7/lib2to3/fixes/ |
Current File : //lib64/python2.7/lib2to3/fixes/fix_tuple_params.pyc |
� {fc @ 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"