
    Mh                         d Z ddlZddlZddlZ G d de          Z G d de          Z G d de          Z G d	 d
e          ZddZ	ddZ
d ZdS )zExtension utilities.    Nc                       e Zd ZdZdS )ExtensionLoadingErrorzAn extension loading error.N__name__
__module____qualname____doc__     ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyter_server/extension/utils.pyr   r      s        %%%%r   r   c                       e Zd ZdZdS )ExtensionMetadataErrorzAn extension metadata error.Nr   r
   r   r   r   r      s        &&&&r   r   c                       e Zd ZdZdS )ExtensionModuleNotFoundz$An extension module not found error.Nr   r
   r   r   r   r      s        ....r   r   c                       e Zd ZdZdS )NotAnExtensionAppz2An error raised when a module is not an extension.Nr   r
   r   r   r   r      s        <<<<r   r   c                     	 | j         S # t          $ r Y nw xY w	 | j        }n # t          $ r d}t          |          dw xY wt	          j        d| dt          d           |S )zLooks for _load_jupyter_server_extension as an attribute
    of the object or module.

    Adds backwards compatibility for old function name missing the
    underscore prefix.
    z6_load_jupyter_server_extension function was not found.Nz=A `_load_jupyter_server_extension` function was not found in z. Instead, a `load_jupyter_server_extension` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.   )
stacklevel)_load_jupyter_server_extensionAttributeErrorload_jupyter_server_extensionr   warningswarnDeprecationWarning)objloggerfuncmsgs       r   
get_loaderr       s    11   30 3 3 3F#C((d23 M		 	 	
 	    Ks   	 
" ?c                    t          j                    }t          j        |           }t          j                    }||z
  }|r'|dk    r|j        n|j        } |d|  d|dd           	 ||                                fS # t          $ r Y nw xY w	 |                                }|r|	                    d|  d           ||fS # t          $ r Y nw xY w|r|                    d|  d           || | d	gfS )
a5  Find the extension metadata from an extension package.

    This looks for a `_jupyter_server_extension_points` function
    that returns metadata about all extension points within a Jupyter
    Server Extension package.

    If it doesn't exist, return a basic metadata packet given
    the module name.
    g?zExtension package z took z.4fzs to importz?A `_jupyter_server_extension_points` function was not found in z. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.zS, so Jupyter Server will look for extension points in the extension pacakge's root.)modulename)
timeperf_counter	importlibimport_moduleinfodebug _jupyter_server_extension_pointsr   _jupyter_server_extension_pathswarning)package_namer   
start_timer"   end_timedurationlogextension_pointss           r   get_metadatar3   6   s    "$$J$\22F ""H*$H  P%^^fkkNNNXNNNNOOOv>>@@@@   !AACC 	NN%(% % %   '''   
  
(  	
 	
 	
 |\BBCCCs$   *B   
BB2C 
CCc                 &    ddl m}  ||           S )a[  Raises an exception is the extension is missing a needed
    hook or metadata field.
    An extension is valid if:
    1) name is an importable Python package.
    1) the package has a _jupyter_server_extension_points function
    2) each extension path has a _load_jupyter_server_extension function

    If this works, nothing should happen.
       )ExtensionPackage)r#   )managerr6   )r#   r6   s     r   validate_extensionr8   m   s*     *)))))&&&&r   )N)r	   r&   r$   r   	Exceptionr   r   r   r   r    r3   r8   r
   r   r   <module>r:      s          & & & & &I & & &' ' ' ' 'Y ' ' '/ / / / /i / / /= = = = =	 = = =   <4D 4D 4D 4Dn' ' ' ' 'r   