| Server IP : 61.19.30.66 / Your IP : 216.73.216.15 Web Server : Apache/2.2.22 (Ubuntu) System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 User : www-data ( 33) PHP Version : 5.3.10-1ubuntu3.48 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/lib/python2.7/lib2to3/fixes/ |
Upload File : |
ó
—|_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( ( s4 /usr/lib/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 new_linest endt self( s4 /usr/lib/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 s4 /usr/lib/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( ( s4 /usr/lib/python2.7/lib2to3/fixes/fix_tuple_params.pyR"