o
    Š�bc   ã                   @   sV   d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZmZmZ G dd„ dejƒZdS )zoFixer for execfile.

This converts usages of the execfile function into calls to the built-in
exec() function.
é   )Ú
fixer_base)
ÚCommaÚNameÚCallÚLParenÚRParenÚDotÚNodeÚArgListÚStringÚsymsc                   @   s   e Zd ZdZdZdd„ ZdS )ÚFixExecfileTz«
    power< 'execfile' trailer< '(' arglist< filename=any [',' globals=any [',' locals=any ] ] > ')' > >
    |
    power< 'execfile' trailer< '(' filename=any ')' > >
    c                 C   s,  |sJ ‚|d }|  d¡}|  d¡}|jd jd  ¡ }t| ¡ tƒ tddƒg|d�}ttjt	dƒ|gƒ}ttj
tƒ t	d	ƒgƒttj
tƒ tƒ gƒg}	|g|	 }
| ¡ }d|_td
dƒ}|
tƒ |tƒ |g }tt	dƒ|dƒ}|g}|d ur~| tƒ | ¡ g¡ |d urŒ| tƒ | ¡ g¡ tt	dƒ||jd�S )NÚfilenameÚglobalsÚlocalséÿÿÿÿz"rb"ú )ÚrparenÚopenÚreadz'exec'ÚcompileÚ Úexec)Úprefix)ÚgetÚchildrenÚcloner
   r   r   r	   r   Úpowerr   Útrailerr   r   r   r   r   Úextend)ÚselfÚnodeÚresultsr   r   r   Úexecfile_parenÚ	open_argsÚ	open_callr   Ú	open_exprÚfilename_argÚexec_strÚcompile_argsÚcompile_callÚargs© r,   ú1/usr/lib/python3.10/lib2to3/fixes/fix_execfile.pyÚ	transform   s0   

ÿÿ

zFixExecfile.transformN)Ú__name__Ú
__module__Ú__qualname__ÚBM_compatibleÚPATTERNr.   r,   r,   r,   r-   r      s    r   N)Ú__doc__r   r   Ú
fixer_utilr   r   r   r   r   r   r	   r
   r   r   ÚBaseFixr   r,   r,   r,   r-   Ú<module>   s   0