o
    ¶2úh¢  ã                   @   sl   d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlmZ ddlm	Z	 G dd	„ d	e
ƒZd
d„ ZdS )z$Inline constants in a python module.é    )Úabsolute_import)Údivision)Úprint_functionN)Ú	ast_utils)Úscopec                   @   s   e Zd ZdS )ÚInlineErrorN)Ú__name__Ú
__module__Ú__qualname__© r   r   úO/var/www/html/chatgem/venv/lib/python3.10/site-packages/pasta/augment/inline.pyr      s    r   c                    s  t  | ¡}|jˆ  }t|jtjƒstdˆ t|jƒf ƒ‚| 	|j¡}t|tj
ƒs.tdˆ  ƒ‚|j}t| 	|¡tjƒs@tdˆ  ƒ‚|jD ]}tt|ddƒtjƒrUtdˆ  ƒ‚qC|jD ]}t | 	|¡|t |¡¡ qYt|jƒdkr{t | 	|¡|¡ dS ‡ fdd	„|jD ƒ}||_dS )
z%Inline a constant name into a module.z$%r is not a constant; it has type %rz#%r is not declared in an assignmentz%r is not a top-level nameÚctxNz%r is not a constanté   c                    s&   g | ]}t |tjƒr|jˆ ks|‘qS r   )Ú
isinstanceÚastÚNameÚid)Ú.0Útgt©Únamer   r   Ú
<listcomp>?   s    
ÿ
ÿzinline_name.<locals>.<listcomp>)r   ÚanalyzeÚnamesr   Ú
definitionr   r   r   ÚtypeÚparentÚAssignÚvalueÚModuleÚreadsÚgetattrÚStorer   Úreplace_childÚcopyÚdeepcopyÚlenÚtargetsÚremove_child)Útr   ÚscÚ	name_nodeÚassign_noder   ÚrefÚtgt_listr   r   r   Úinline_name    s,   


ÿ
ÿ

r/   )Ú__doc__Ú
__future__r   r   r   r   r$   Ú
pasta.baser   r   Ú	Exceptionr   r/   r   r   r   r   Ú<module>   s   