KMa @sgdZddlmZmZddlmZmZmZmZm Z m Z Gdddej Z dS)z7 Convert use of sys.exitfunc to use the atexit module. )pytree fixer_base)NameAttrCallCommaNewlinesymscsReZdZdZdZdZfddZfddZddZS) 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__)selfargs) __class__?/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_exitfunc.pyr szFixExitfunc.__init__cs&tt|j||d|_dS)N)r r start_tree sys_import)r Ztreefilename)rrrr!szFixExitfunc.start_treec Csd|kr,|jdkr(|d|_dS|dj}d|_tjtjttdtd}t ||g|j}|j ||jdkr|j |ddS|jj d}|j tjkr|jt|jtddn|jj}|j j|j}|j} tjtjtd tddg} tjtj| g} |j|dt|j|d | dS) NrfuncatexitregisterzKCan't find sys import; Please add an atexit import at the top of your file. import)rZcloneprefixrZNoder ZpowerrrrreplaceZwarningZchildrentypeZdotted_as_namesZ append_childrparentindexZ import_nameZ simple_stmtZ insert_childr) r ZnodeZresultsrrZcallnamesZcontaining_stmtZpositionZstmt_containerZ new_importnewrrr transform%s2        zFixExitfunc.transform) __name__ __module__ __qualname__Zkeep_line_orderZ BM_compatibleZPATTERNr rr$rr)rrr s r N) __doc__Zlib2to3rrZlib2to3.fixer_utilrrrrrr ZBaseFixr rrrrs.