
    hje                        d Z ddlmZ ddlZ ej        e          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 dd
lmZ dZ G d de          ZdS )ze Bokeh Application Handler to look for Bokeh server request callbacks
in a specified Python module.

    )annotationsN)
ModuleType   )PathLike)_check_callback   )
CodeRunner)RequestHandler)ServerRequestHandlerc                       e Zd ZU dZded<   g ddd fdZedd            Zedd            Zedd            Z	ddZ
 xZS )r   zE Load a script which contains server request handler callbacks.

    r   _moduleN)argvpackagefilenamer   r   	list[str]r   ModuleType | NonereturnNonec                   t                                                       t          |d          5 }|                                }ddd           n# 1 swxY w Y   t	          ||||           _         j        j        sF j                                         _        d fd} j        	                     j        |           dS dS )	a  

        Keyword Args:
            filename (str) : path to a module to load request handler callbacks from

            argv (list[str], optional) : a list of string arguments to use as
                ``sys.argv`` when the callback code is executed. (default: [])

        zutf-8)encodingN)r   r   r   c                 p    j         j        } d| v r| d         _        t          j        dd           d S )Nprocess_request)request)what)r   __dict___process_requestr   )contentsselfs    Qlib/python3.11/site-packages/bokeh/application/handlers/server_request_handler.pyextract_callbacksz8ServerRequestHandler.__init__.<locals>.extract_callbacksN   sE    <0$00,45F,GD) 5|J[\\\\\\    )r   r   )
super__init__openreadr	   _runnerfailed
new_moduler   run)r   r   r   r   fsourcer    	__class__s   `      r   r#   zServerRequestHandler.__init__9   s    	(W--- 	VVXXF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 "&(D'JJJ|" 	><2244DL] ] ] ] ] ] LT\+<=====	> 	>s   AAA
str | Nonec                    | j         j        S )zE If the handler fails, may contain a related error message.

        )r&   errorr   s    r   r/   zServerRequestHandler.errorY   s    
 |!!r!   c                    | j         j        S )zJ If the handler fails, may contain a traceback or other details.

        )r&   error_detailr0   s    r   r2   z!ServerRequestHandler.error_detail`   s    
 |((r!   boolc                    | j         j        S )zF ``True`` if the request handler callbacks failed to execute

        )r&   r'   r0   s    r   r'   zServerRequestHandler.failedg   s    
 |""r!   c                    | j         rdS dt          j                            t          j                            | j        j                            d         z   S )z_ The last path component for the basename of the path to the
        callback module.

        N/r   )r'   ospathsplitextbasenamer&   r0   s    r   url_pathzServerRequestHandler.url_pathp   sK    
 ; 	R4 ))"'*:*:4<;L*M*MNNqQQQr!   )r   r   r   r   r   r   r   r   )r   r-   )r   r3   )__name__
__module____qualname____doc____annotations__r#   propertyr/   r2   r'   r;   __classcell__)r,   s   @r   r   r   2   s           @Bae > > > > > > > >@ " " " X" ) ) ) X) # # # X#	R 	R 	R 	R 	R 	R 	R 	Rr!   r   )r?   
__future__r   logging	getLoggerr<   logr7   typesr   
core.typesr   util.callback_managerr   code_runnerr	   request_handlerr
   __all__r    r!   r   <module>rN      s     # " " " " " g!! 
			       # " " " " " 4 4 4 4 4 4 # # # # # # + + + + + +GR GR GR GR GR> GR GR GR GR GRr!   