3 ^ @sJddlmZddlmZmZmZmZmZmZdZ dZ Gdddej Z dS)) fixer_base)CallCommaNameNode BlankLinesymsz0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)z(power< 'type' trailer< '(' x=any ')' > >csPeZdZdZdeeeefZfddZddZddZ d d Z d d Z Z S) FixIdiomsTa 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 ')' > > > '\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* > cs8tt|j|}|r4d|kr4|d|dkr0|SdS|S)NsortedZid1Zid2)superr match)selfnoder) __class__0/usr/lib64/python3.6/lib2to3/fixes/fix_idioms.pyr Os  zFixIdioms.matchcCsHd|kr|j||Sd|kr(|j||Sd|kr<|j||StddS)N isinstancewhiler z Invalid match)transform_isinstancetransform_whiletransform_sort RuntimeError)r rresultsrrr transformZs   zFixIdioms.transformcCsh|dj}|dj}d|_d|_ttd|t|g}d|kr\d|_ttjtd|g}|j|_|S)NxT rnnot)cloneprefixrrrrrZnot_test)r rrrrZtestrrrrds  zFixIdioms.transform_isinstancecCs |d}|jtd|jddS)NrTrue)r")replacerr")r rrZonerrrrpszFixIdioms.transform_whilec Cs|d}|d}|jd}|jd}|r>|jtd|jdn8|rn|j}d|_|jttd|g|jdntd|j|j}d |kr|r|jd d |d jf} d j | |d _n"t } |j j | |jd d | _dS) Nsortnextlistexprr )r"rzshould not have reached here ) getr$rr"r!rrremove rpartitionjoinrparentZ append_child) r rrZ sort_stmtZ next_stmtZ list_callZ simple_exprnewZbtwnZ prefix_linesZend_linerrrrts*   zFixIdioms.transform_sort) __name__ __module__ __qualname__ZexplicitTYPECMPZPATTERNr rrrr __classcell__rr)rrr %s'   r N) rrZ fixer_utilrrrrrrr5r4ZBaseFixr rrrrs