tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Y\¬Qc@smdZddlmZddlmZmZmZmZmZm    Z    dZ
dZ dej fd„ƒ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„Zd„Zd„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*
        >
    cCsJtt|ƒj|ƒ}|rFd|krF|d|dkrB|SdS|S(Ntsortedtid1tid2(tsuperRtmatchtNone(tselftnodetr((s`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyR Os cCsdd|kr|j||ƒSd|kr8|j||ƒSd|krT|j||ƒStdƒ‚dS(Nt
isinstancetwhileRs Invalid match(ttransform_isinstancettransform_whilettransform_sortt RuntimeError(RRtresults((s`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyt    transformZs   cCs™|djƒ}|djƒ}d|_d|_ttdƒ|tƒ|gƒ}d|kr‰d|_ttjtdƒ|gƒ}n|j|_|S(NtxtTuu u
isinstancetnunot(tclonetprefixRRRRRtnot_test(RRRRRttest((s`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyRds        !     ! cCs*|d}|jtdd|jƒƒdS(NRuTrueR(treplaceRR(RRRtone((s`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyRps
c Csv|d}|d}|jdƒ}|jdƒ}|rW|jtdd|jƒƒnR|r|jƒ}d|_|jttdƒ|gd|jƒƒn tdƒ‚|jƒ|j}d    |krr|r|jd    ƒd
|d
jf}    d    j    |    ƒ|d
_qr|j
st ‚|j dks+t ‚tƒ}
|j
j|
ƒ|j |
ksYt ‚|jd    ƒ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`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyRts0
 
      
          ( t__name__t
__module__tTruetexplicittTYPEtCMPtPATTERNR RRRR(((s`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyR%s'        
       N(t__doc__tRt
fixer_utilRRRRRRR;R:tBaseFixR(((s`/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_idioms.pyt<module>s
.