U ÙAT^f c@sjddlmZddlmZddlmZddlmZm Z m Z dZ Gdd„dej ƒZ dd „Zd d „Zd d „ZdS)i)Útoken)Úpython_symbols)Ú fixer_base)ÚNameÚCallÚ find_bindingz;Calls to builtin next() possibly shadowed by global bindingcs0eZdZdZdZdZ‡fdd„Zdd„Z‡ZS)ÚFixNextTa¾ power< base=any+ trailer< '.' attr='next' > trailer< '(' ')' > > | power< head=any+ trailer< '.' attr='next' > not trailer< '(' ')' > > | classdef< 'class' any+ ':' suite< any* funcdef< 'def' name='next' parameters< '(' NAME ')' > any+ > any* > > | global=global_stmt< 'global' any* 'next' any* > Zprecs>tt|ƒ ||¡td|ƒ}|r4| |t¡d|_nd|_dS)NÚnextTF)ZsuperrÚ start_treerÚwarningÚ bind_warningÚ shadowed_next)ÚselfZtreeZfilenameÚn©Z __class__©ú./usr/lib64/python3.8/lib2to3/fixes/fix_next.pyr$s   zFixNext.start_treecCsþ| d¡}| d¡}| d¡}|rr|jr>| td|jd¡qúdd„|Dƒ}d|d _| ttd |jd|ƒ¡nˆ|rtd|jd}| |¡nj|ràt|ƒrÐ|d }d d d„|Dƒ¡ ¡d krÌ|  |t ¡dS| tdƒ¡nd|krú|  |t ¡d|_dS)NÚbaseÚattrÚnameZ__next__)ÚprefixcSsg|] }| ¡‘qSr)Zclone©Ú.0r rrrÚ 9óz%FixNext.transform..ÚirÚheadcSsg|] }t|ƒ‘qSr)ZstrrrrrrErZ __builtin__ZglobalT) Zgetr ZreplacerrrÚis_assign_targetZjoinZstripr r )r ÚnodeZresultsrrrr rrrrÚ transform.s,       zFixNext.transform) Z__name__Z __module__Z __qualname__Z BM_compatibleZPATTERNZorderrrZ __classcell__rrrrrs  rcCsFt|ƒ}|dkrdS|jD]&}|jtjkr0dSt||ƒrdSqdS)NFT)Ú find_assignÚchildrenÚtyperZEQUALÚ is_subtree)rZassignZchildrrrrQs   rcCs4|jtjkr|S|jtjks&|jdkr*dSt|jƒS©N)r ÚsymsZ expr_stmtZ simple_stmtZparentr©rrrrr]s  rcs$|ˆkr dSt‡fdd„|jDƒƒS)NTc3s|]}t|ˆƒVqdSr")r!)rZcr$rrZ gszis_subtree..)Zanyr)Zrootrrr$rr!dsr!N)Zpgen2rZpygramrr#rrZ fixer_utilrrrr ZBaseFixrrrr!rrrrZ s   @