U iÛ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/python38/lib64/python3.8/lib2to3/fixes/fix_exitfunc.pyr szFixExitfunc.__init__cstt|ƒ ||¡d|_dSr )r r Ú start_treeÚ sys_import)rZtreeÚfilenamerrrr!szFixExitfunc.start_treec Cs&d|kr |jdkr|d|_dS|d ¡}d|_t tjttdƒtdƒƒ¡}t ||g|jƒ}|  |¡|jdkr‚|  |d¡dS|jj d}|j tjkr¸| tƒ¡| tddƒ¡nj|jj}|j  |j¡}|j} t tjtd ƒtddƒg¡} t tj| g¡} | |dtƒ¡| |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) rZnodeZresultsrrZcallÚnamesZcontaining_stmtZpositionZstmt_containerZ new_importÚnewrrrÚ transform%s6   ÿ      ÿzFixExitfunc.transform) Ú__name__Ú __module__Ú __qualname__Zkeep_line_orderZ BM_compatibleZPATTERNr rr&Ú __classcell__rrrrr s   r N) Ú__doc__Zlib2to3rrZlib2to3.fixer_utilrrrrrr ZBaseFixr rrrrÚs