o
    ”7?e¢  ã                   @   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   úU/home/www/facesmatcher.com/pyenv/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)Ú.0Ztgt©Únamer   r   Ú
<listcomp>?   s
    
ÿ
ÿzinline_name.<locals>.<listcomp>)r   ZanalyzeÚnamesr   Z
definitionr   r   r   ÚtypeÚparentÚAssignÚvalueÚModuleZreadsÚgetattrÚStorer   Zreplace_childÚcopyÚdeepcopyÚlenÚtargetsZremove_child)Útr   ÚscÚ	name_nodeZassign_noder   ÚrefZtgt_listr   r   r   Úinline_name    s,   


ÿ
ÿ

r'   )Ú__doc__Ú
__future__r   r   r   r   r   Z
pasta.baser   r   Ú	Exceptionr   r'   r   r   r   r   Ú<module>   s   