Files
PowerToys/PythonHome/Lib/lib2to3/fixes/fix_idioms.pyc

90 lines
4.3 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@smdZddlmZddlmZmZmZmZmZm Z dZ
dZ dej fd<00><00>YZ dS( 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(tCalltCommatNametNodet BlankLinetsymss0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)s(power< 'type' trailer< '(' x=any ')' > >t FixIdiomscBsQeZeZdeeeefZd<00>Zd<00>Zd<00>Z d<00>Z
d<00>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*
>
cCsJtt|<00>j|<00>}|rFd|krF|d|dkrB|SdS|S(Ntsortedtid1tid2(tsuperRtmatchtNone(tselftnodetr((s!.\Lib\lib2to3\fixes\fix_idioms.pyR Os cCsdd|kr|j||<00>Sd|kr8|j||<00>Sd|krT|j||<00>Std<00><00>dS(Nt
isinstancetwhileRs Invalid match(ttransform_isinstancettransform_whilettransform_sortt RuntimeError(RRtresults((s!.\Lib\lib2to3\fixes\fix_idioms.pyt transformZs   cCs<>|dj<00>}|dj<00>}d|_d|_ttd<00>|t<00>|g<00>}d|kr<>d|_ttjtd<00>|g<00>}n|j|_|S(NtxtTuu u
isinstancetnunot(tclonetprefixRRRRRtnot_test(RRRRRttest((s!.\Lib\lib2to3\fixes\fix_idioms.pyRds  !  ! cCs*|d}|jtdd|j<00><01>dS(NRuTrueR(treplaceRR(RRRtone((s!.\Lib\lib2to3\fixes\fix_idioms.pyRps
c Csv|d}|d}|jd<00>}|jd<00>}|rW|jtdd|j<00><01>nR|r<>|j<00>}d|_|jttd<00>|gd|j<00><01>n td<00><00>|j<00>|j}d |krr|r|jd <00>d
|d
jf} d j | <00>|d
_qr|j
st <00>|j dks+t <00>t<00>}
|j
j|
<00>|j |
ksYt <00>|jd <00>d
|
_ndS( NtsorttnexttlisttexprusortedRusshould not have reached hereu
i(tgetR RRRRRtremovet
rpartitiontjointparenttAssertionErrort next_siblingR Rt append_child( RRRt sort_stmtt next_stmtt list_callt simple_exprtnewtbtwnt prefix_linestend_line((s!.\Lib\lib2to3\fixes\fix_idioms.pyRts0

   
    ( t__name__t
__module__tTruetexplicittTYPEtCMPtPATTERNR RRRR(((s!.\Lib\lib2to3\fixes\fix_idioms.pyR%s'
N(t__doc__tRt
fixer_utilRRRRRRR;R:tBaseFixR(((s!.\Lib\lib2to3\fixes\fix_idioms.pyt<module>s
.