
    rh                    ^    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Zd Z	ddZ
ddZdd	Zy)zGConvenience functions for writing to and reading from Python variables.    )annotationsN)Anyc                    | j                         st        dj                  |             t        j                  |       rt        dj                  |             y)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)var_names    x/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/google/generativeai/notebook/py_utils.pyvalidate_var_namer      sO      "AHHRSS"?FFxPQQ #    c                 (    t         j                  d   S )N__main__)sysmodules r   r   get_main_moduler       s    ;;z""r   c                    t        |        t        t                     }| |v r||    S | t        t              v rt        t              |    S t	        dj                  |             )z>Retrieves the value of `var_name` from the global environment.z"{}" not found)r   varsr   builtins	NameErrorr   )r   g_varss     r   
get_py_varr   $   s\    h/#$F6h	T(^	#H~h''
$++H5
66r   c                d    	 t        |        t        |       }y# t        $ r Y yt        $ r Y yw xY w)z@Returns true if `var_name` is defined in the global environment.FT)r   r   r   r   )r   _s     r   
has_py_varr   /   s=    (#x     s    	///c                J    t        |        t        t                     }||| <   y)z7Sets the value of `var_name` in the global environment.N)r   r   r   )r   valr   s      r   
set_py_varr    <   s!    h/#$FF8r   )r   strreturnNone)r   r!   r"   r   )r   r!   r"   bool)r   r!   r   r   r"   r#   )__doc__
__future__r   r   r	   r   typingr   r   r   r   r   r    r   r   r   <module>r(      s4    N "   
 R#7
r   