| 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 @ sm d Z d d l m Z d d l m Z m Z m Z m Z m Z m Z d Z
d Z d e j f d YZ
d S( sÜ Adjust some old Python 2 idioms to their modern counterparts.
* Change some type comparisons to isinstance() calls:
type(x) == T -> isinstance(x, T)
type(x) is T -> isinstance(x, T)
type(x) != T -> not isinstance(x, T)
type(x) is not T -> not isinstance(x, T)
* Change "while 1:" into "while True:".
* Change both
v = list(EXPR)
v.sort()
foo(v)
and the more general
v = EXPR
v.sort()
foo(v)
into
v = sorted(EXPR)
foo(v)
i ( t
fixer_base( t Callt Commat Namet Nodet BlankLinet symss0 (n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)s( power< 'type' trailer< '(' x=any ')' > >t FixIdiomsc B sQ e Z e Z d e e e e f Z d Z d Z d Z d Z
d Z RS( sş
isinstance=comparison< %s %s T=any >
|
isinstance=comparison< T=any %s %s >
|
while_stmt< 'while' while='1' ':' any+ >
|
sorted=any<
any*
simple_stmt<
expr_stmt< id1=any '='
power< list='list' trailer< '(' (not arglist<any+>) any ')' > >
>
'\n'
>
sort=
simple_stmt<
power< id2=any
trailer< '.' 'sort' > trailer< '(' ')' >
>
'\n'
>
next=any*
>
|
sorted=any<
any*
simple_stmt< expr_stmt< id1=any '=' expr=any > '\n' >
sort=
simple_stmt<
power< id2=any
trailer< '.' 'sort' > trailer< '(' ')' >
>
'\n'
>
next=any*
>
c C sJ t t | j | } | rF d | k rF | d | d k rB | Sd S| S( Nt sortedt id1t id2( t superR t matcht None( t selft nodet r( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyR O s c C sd d | k r | j | | Sd | k r8 | j | | Sd | k rT | j | | St d d S( Nt
isinstancet whileR s
Invalid match( t transform_isinstancet transform_whilet transform_sortt RuntimeError( R R t results( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyt transformZ s c C s | d j } | d j } d | _ d | _ t t d | t | g } d | k r d | _ t t j t d | g } n | j | _ | S( Nt xt Tu u u
isinstancet nu not( t clonet prefixR R R R R t not_test( R R R R R t test( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyR d s ! !c C s* | d } | j t d d | j d S( NR u TrueR ( t replaceR R ( R R R t one( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyR p s
c C sv | d } | d } | j d } | j d } | rW | j t d d | j nR | r | j } d | _ | j t t d | g d | j n t d | j | j } d | k rr| r| j d d
| d
j f } d j | | d
_ qr| j
st | j d k s+t t }
| j
j |
| j |
k sYt | j d d
|
_ n d S( Nt sortt nextt listt expru sortedR u s should not have reached hereu
i ( t getR R R R R R t removet
rpartitiont joint parentt AssertionErrort next_siblingR
R t append_child( R R R t sort_stmtt next_stmtt list_callt simple_exprt newt btwnt prefix_linest end_line( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyR t s0
( t __name__t
__module__t Truet explicitt TYPEt CMPt PATTERNR R R R R ( ( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyR % s '
N( t __doc__t R t
fixer_utilR R R R R R R; R: t BaseFixR ( ( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_idioms.pyt <module> s
.