
    }tfX                        d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ erddlmZ ddlmZ dd	lmZ  G d
 d      Z G d d      Zy)zAn extension handler.    )annotations)Logger)TYPE_CHECKINGAnycast)TemplateNotFound)FileFindHandler)Config)ExtensionApp)	ServerAppc                  $     e Zd ZdZd fdZ xZS )ExtensionHandlerJinjaMixinz`Mixin class for ExtensionApp handlers that use jinja templating for
    template rendering.
    c                    	 | j                    d}t        t        | j                  |   j	                  |            S # t
        $ r  t        t        t        |   |            cY S w xY w)z1Return the jinja template object for a given name_jinja2_env)namer   strsettingsget_templater   super)selfr   env	__class__s      j/var/www/html/software/conda/envs/higlass/lib/python3.12/site-packages/jupyter_server/extension/handler.pyr   z'ExtensionHandlerJinjaMixin.get_template   s_    	9YYK{+CT]]3/<<TBCC 	9UW1$788	9s   :> &A'&A')r   r   returnr   )__name__
__module____qualname____doc__r   __classcell__r   s   @r   r   r      s    9 9    r   c                       e Zd ZU dZded<   d fdZedd       Zedd       Zed fd       Z	edd       Z
edd	       Zedd
       Zedd       Zedd       ZdddZ xZS )ExtensionHandlerMixina.  Base class for Jupyter server extension handlers.

    Subclasses can serve static files behind a namespaced
    endpoint: "<base_url>/static/<name>/"

    This allows multiple extensions to serve static files under
    their own namespace and avoid intercepting requests for
    other extensions.
    zdict[str, Any]r   c                R    || _         	 t        |   |i | y # t        $ r Y y w xY wN)r   r   
initialize	TypeError)r   r   argskwargsr   s       r   r&   z ExtensionHandlerMixin.initialize.   s3    		G// 		s    	&&c                H    t        d| j                  | j                           S )Nr   r   r   r   r   s    r   extensionappz"ExtensionHandlerMixin.extensionapp5   s    NDMM$))$<==r!   c                8    d}t        d| j                  |         S )N	serverappr   r   r   )r   keys     r   r/   zExtensionHandlerMixin.serverapp9   s    Ks!344r!   c                    t        | d      st        t        t        |         S 	 t        t        | j
                  j                        S # t        $ r' t        t        | j                  j                        cY S w xY w)Nr   )hasattrr   r   r   logr-   AttributeErrorr/   )r   r   s    r   r4   zExtensionHandlerMixin.log>   sb    tV$,,	4 1 1 5 566 	4 2 233	4s   #A -A;:A;c                N    t        d| j                  | j                   d         S )Nr
   _configr+   r,   s    r   configzExtensionHandlerMixin.configH   s#    Hdmmtyyk,ABCCr!   c                4    t        d| j                  d         S )Nr
   r8   r0   r,   s    r   server_configz#ExtensionHandlerMixin.server_configL   s    HdmmH566r!   c                V    t        t        | j                  j                  dd            S )Nbase_url/)r   r   r   getr,   s    r   r<   zExtensionHandlerMixin.base_urlP   s     C**:s;<<r!   c                .    | j                   j                  S r%   )r-   static_url_prefixr,   s    r   r@   z'ExtensionHandlerMixin.static_url_prefixT   s      222r!   c                V    t        t        | j                  | j                   d         S )N_static_paths)r   r   r   r   r,   s    r   static_pathz!ExtensionHandlerMixin.static_pathX   s#    C$))M'BCDDr!   c           	        | j                    d}	 | j                  |d       | j                  j	                  dt
              j                  }|t        | dd      }d}|r0| j                  j                  d	z   | j                  j                  z   }| j                  | j                  d
}	|t        t         ||	|fi |      z   S # t        $ r#}|| j                  v rd}t        |      d|d}~ww xY w)a  Returns a static URL for the given relative static file path.
        This method requires you set the ``{name}_static_path``
        setting in your extension (which specifies the root directory
        of your static files).
        This method returns a versioned url (by default appending
        ``?v=<signature>``), which allows the static files to be
        cached indefinitely.  This can be disabled by passing
        ``include_version=False`` (in the default implementation;
        other static file implementations are not required to support
        this, but they may support other options).
        By default this method returns URLs relative to the current
        host, but if ``include_host`` is true the URL returned will be
        absolute.  If this handler has an ``include_host`` attribute,
        that value will be used as the default for all `static_url`
        calls that do not pass ``include_host`` as a keyword argument.
        rB   
static_urlzlThis extension doesn't have any static paths listed. Check that the extension's `static_paths` trait is set.Nstatic_handler_classinclude_hostF z://)rC   r@   )r   require_setting	Exceptionr   r>   r	   make_static_urlgetattrrequestprotocolhostrC   r@   r   r   )
r   pathrG   r)   r1   emsgget_urlbaser   s
             r   rE   z ExtensionHandlerMixin.static_url\   s    " =)
	  l3 --##$:OL\\"4?L<<((504<<3D3DDD
  ++!%!7!7

 d3$ A& ABBB5  	dmm#?   n$.	s   C 	C0C++C0)r   r   r(   r   r)   r   r   None)r   r   )r   r   )r   r   )r   r
   )r   r   r%   )rP   r   rG   zbool | Noner)   r   r   r   )r   r   r   r   __annotations__r&   propertyr-   r/   r4   r8   r:   r<   r@   rC   rE   r   r    s   @r   r#   r#   !   s      > > 5 5 4 4 D D 7 7 = = 3 3 E E.C .Cr!   r#   N)r   
__future__r   loggingr   typingr   r   r   jinja2.exceptionsr   jupyter_server.base.handlersr	   traitlets.configr
   $jupyter_server.extension.applicationr   jupyter_server.serverappr   r   r#    r!   r   <module>ra      s>     "  + + . 8'A29 9iC iCr!   