3 ª f¿ ã@sJdZddlmZmZddlmZmZmZmZm 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Úsymscs<eZdZdZdZdZ‡fdd„Z‡fdd„Zdd„Z‡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/python36/lib64/python3.6/lib2to3/fixes/fix_exitfunc.pyr szFixExitfunc.__init__cstt|ƒj||ƒd|_dS)N)r r Ú start_treeÚ sys_import)r ZtreeÚfilename)rrrr!szFixExitfunc.start_treec Cs&d|kr |jdkr|d|_dS|djƒ}d|_tjtjttdƒtdƒƒƒ}t ||g|jƒ}|j |ƒ|jdkr‚|j |dƒdS|jj d}|j tjkr¸|jtƒƒ|jtddƒƒnj|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 ZnodeZresultsrrZcallÚnamesZcontaining_stmtZpositionZstmt_containerZ new_importÚnewrrrÚ transform%s2         zFixExitfunc.transform) Ú__name__Ú __module__Ú __qualname__Zkeep_line_orderZ BM_compatibleZPATTERNr rr$Ú __classcell__rr)rrr s   r N) Ú__doc__Zlib2to3rrZlib2to3.fixer_utilrrrrrr ZBaseFixr rrrrÚs