î j f¿ ã@sgdZddlmZmZddlmZmZmZmZm Z m Z Gdd„dej ƒZ dS)z7 Convert use of sys.exitfunc to use the atexit module. é)ÚpytreeÚ fixer_base)ÚNameÚAttrÚCallÚCommaÚNewlineÚsymscsReZdZdZdZdZ‡fdd†Z‡fdd†Zdd„Z‡S) Ú FixExitfuncTa” ( sys_import=import_name<'import' ('sys' | dotted_as_names< (any ',')* 'sys' (',' any)* > ) > | expr_stmt< power< 'sys' trailer< '.' 'exitfunc' > > '=' func=any > ) cstt|ƒj|ŒdS)N)Úsuperr Ú__init__)ÚselfÚargs)Ú __class__©ú?/opt/alt/python34/lib64/python3.4/lib2to3/fixes/fix_exitfunc.pyr szFixExitfunc.__init__cs&tt|ƒj||ƒd|_dS)N)r r Ú start_treeÚ sys_import)r ZtreeÚfilename)rrrr!szFixExitfunc.start_treec Cs d|kr/|jdkr+|d|_ndS|djƒ}d|_tjtjttdƒtdƒƒƒ}t ||g|jƒ}|j |ƒ|jdkrº|j |dƒdS|jj d}|j tjkr|jtƒƒ|jtddƒƒn—|jj}|j j|jƒ}|j} tjtjtd ƒtddƒgƒ} tjtj| gƒ} |j|dtƒƒ|j|d | ƒdS) NrÚfuncÚÚatexitÚregisterzKCan't find sys import; Please add an atexit import at the top of your file.éú Úimporté)rZcloneÚprefixrZNoder ZpowerrrrÚreplaceZwarningZchildrenÚtypeZdotted_as_namesZ append_childrÚparentÚindexZ import_nameZ simple_stmtZ insert_childr) r ZnodeZresultsrrÚcallÚnamesZcontaining_stmtZpositionZstmt_containerZ new_importÚnewrrrÚ transform%s2       zFixExitfunc.transform) Ú__name__Ú __module__Ú __qualname__Zkeep_line_orderZ BM_compatibleZPATTERNr rr%rr)rrr s r N) Ú__doc__Zlib2to3rrZlib2to3.fixer_utilrrrrrr ZBaseFixr rrrrÚs.