
    &e(                    l    d dl mZ d dlZd dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ  G d d          ZdS )	    )annotationsN)Any)config)magic)open_python_filec                  (    e Zd ZdZd ZddZdd	Zd
S )ScriptCachez,Thread-safe cache of Python script bytecode.c                D    i | _         t          j                    | _        d S )N)_cache	threadingLock_lockselfs    Klib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_cache.py__init__zScriptCache.__init__   s    &(^%%


    returnNonec                x    | j         5  | j                                         ddd           dS # 1 swxY w Y   dS )z~Remove all entries from the cache.

        Notes
        -----
        Threading: SAFE. May be called on any thread.
        N)r   r   clearr   s    r   r   zScriptCache.clear"   s     Z 	  	 K	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   /33script_pathstrr   c           	        t           j                            |          }| j        5  | j                            |d          }||cddd           S t          |          5 }|                                }ddd           n# 1 swxY w Y   t          j	        d          rt          j        ||          }t          ||dddd          }|| j        |<   |cddd           S # 1 swxY w Y   dS )a\  Return the bytecode for the Python script at the given path.

        If the bytecode is not already in the cache, the script will be
        compiled first.

        Raises
        ------
        Any Exception raised while reading or compiling the script.

        Notes
        -----
        Threading: SAFE. May be called on any thread.
        Nzrunner.magicEnabledexecr      )modeflagsdont_inheritoptimize)ospathabspathr   r   getr   readr   
get_optionr   	add_magiccompile)r   r   bytecodeffilebodys        r   get_bytecodezScriptCache.get_bytecode,   s    gook22Z 	 	{{D99H#		 	 	 	 	 	 	 	 "+.. $!6688$ $ $ $ $ $ $ $ $ $ $ $ $ $ $  !677 B ?8[AA   H (0DK$9	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s<   C$C$"B7C$B	C$
B	AC$$C(+C(N)r   r   )r   r   r   r   )__name__
__module____qualname____doc__r   r   r-    r   r   r	   r	      sQ        66& & &
       - - - - - -r   r	   )
__future__r   os.pathr"   r   typingr   	streamlitr   streamlit.runtime.scriptrunnerr   streamlit.source_utilr   r	   r2   r   r   <module>r9      s    # " " " " "                  0 0 0 0 0 0 2 2 2 2 2 2? ? ? ? ? ? ? ? ? ?r   