o
    €j6h  ã                   @  sh   d Z ddlmZ ddlZddlZddlZddlmZ dd	d
„Zdd„ Z	ddd„Z
ddd„Zddd„ZdS )zGConvenience functions for writing to and reading from Python variables.é    )ÚannotationsN)ÚAnyÚvar_nameÚstrÚreturnÚNonec                 C  s2   |   ¡ std | ¡ƒ‚t | ¡rtd | ¡ƒ‚dS )z7Validates that the variable name is a valid identifier.z&Invalid Python variable name, got "{}"z$Cannot use Python keywords, got "{}"N)ÚisidentifierÚ
ValueErrorÚformatÚkeywordÚ	iskeyword)r   © r   út/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/generativeai/notebook/py_utils.pyÚvalidate_var_name   s
   
ÿr   c                   C  s
   t jd S )NÚ__main__)ÚsysÚmodulesr   r   r   r   Úget_main_module    s   
r   r   c                 C  sH   t | ƒ ttƒ ƒ}| |v r||  S | ttƒv rttƒ|  S td | ¡ƒ‚)z>Retrieves the value of `var_name` from the global environment.z"{}" not found)r   Úvarsr   ÚbuiltinsÚ	NameErrorr
   )r   Úg_varsr   r   r   Ú
get_py_var$   s   
r   Úboolc                 C  s>   zt | ƒ t| ƒ}W dS  ty   Y dS  ty   Y dS w )z@Returns true if `var_name` is defined in the global environment.FT)r   r   r	   r   )r   Ú_r   r   r   Ú
has_py_var/   s   
ûÿr   Úvalc                 C  s   t | ƒ ttƒ ƒ}||| < dS )z7Sets the value of `var_name` in the global environment.N)r   r   r   )r   r   r   r   r   r   Ú
set_py_var<   s   
r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   )Ú__doc__Ú
__future__r   r   r   r   Útypingr   r   r   r   r   r   r   r   r   r   Ú<module>   s   


