
    ^hr                        S r SSKJr  SSKJr  SSKJrJrJr  SSK	J
r
  SSKJr  SSKJr  \(       a  SSKJr  SS	KJr  SS
KJr   " S S5      r " S S5      rg)zAn extension handler.    )annotations)Logger)TYPE_CHECKINGAnycast)Template)TemplateNotFound)FileFindHandler)Config)ExtensionApp)	ServerAppc                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )ExtensionHandlerJinjaMixin   zXMixin class for ExtensionApp handlers that use jinja templating for
template rendering.
c                   >  U R                    S3n[        [        U R                  U   R	                  U5      5      nU$ ! [
         a     [        [        [        TU ]  U5      5      s $ f = f)z1Return the jinja template object for a given name_jinja2_env)namer   r   settingsget_templater	   super)selfr   envtemplate	__class__s       Z/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_server/extension/handler.pyr   'ExtensionHandlerJinjaMixin.get_template   sc    	>YYK{+CHdmmC&8&E&Ed&KLHO 	>%'"6t"<==	>s   <A   'A*)A* )r   strreturnr   )__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__r   s   @r   r   r      s    > >    r   c                     ^  \ rS rSr% SrS\S'   SU 4S jjr\SS j5       r\SS j5       r	\SU 4S jj5       r
\SS	 j5       r\SS
 j5       r\SS j5       rSU 4S jjr\SS j5       r\SS j5       rSSS jjrSrU =r$ )ExtensionHandlerMixin#   a  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                T   > Xl          [        TU ]  " U0 UD6  g ! [         a     g f = fN)r   r   
initialize	TypeError)r   r   argskwargsr   s       r   r.    ExtensionHandlerMixin.initialize0   s1    		G// 		s    
''c                H    [        SU R                  U R                     5      $ )Nr   r   r   r   r   s    r   extensionapp"ExtensionHandlerMixin.extensionapp7   s    NDMM$))$<==r(   c                8    Sn[        SU R                  U   5      $ )N	serverappr   r   r   )r   keys     r   r9   ExtensionHandlerMixin.serverapp;   s    Ks!344r(   c                  > [        U S5      (       d  [        [        [        TU ]  5      $  [        [        U R
                  R                  5      $ ! [         a'    [        [        U R                  R                  5      s $ f = f)Nr   )hasattrr   r   r   logr6   AttributeErrorr9   )r   r   s    r   r?   ExtensionHandlerMixin.log@   se    tV$$,,	4 1 1 5 566 	4 2 233	4s   #A .B Bc                N    [        SU R                  U R                   S3   5      $ )Nr   _configr4   r5   s    r   configExtensionHandlerMixin.configJ   s#    Hdmmtyyk,ABCCr(   c                4    [        SU R                  S   5      $ )Nr   rD   r:   r5   s    r   server_config#ExtensionHandlerMixin.server_configN   s    HdmmH566r(   c                V    [        [        U R                  R                  SS5      5      $ )Nbase_url/)r   r   r   getr5   s    r   rJ   ExtensionHandlerMixin.base_urlR   s     C**:s;<<r(   c                
  > [        [        U R                  U5      5      nUR                  U R                  5        UR
                  U R                  S   L a  [        TU ]   US'   [        [        UR                  " S0 UD65      $ )zOverride render template to handle static_paths

If render_template is called with a template from the base environment
(e.g. default error pages)
make sure our extension-specific static_url is _not_ used.

jinja2_env
static_urlr   )r   r   r   updatetemplate_namespaceenvironmentr   r   rP   r   render)r   r   nsr   r   s       r   render_template%ExtensionHandlerMixin.render_templateV   sm     $"3"3D"9:
		$))*4==#>>$w1B|C.2.//r(   c                .    U R                   R                  $ r-   )r6   static_url_prefixr5   s    r   rY   'ExtensionHandlerMixin.static_url_prefixd   s      222r(   c                V    [        [        U R                  U R                   S3   5      $ )N_static_paths)r   r   r   r   r5   s    r   static_path!ExtensionHandlerMixin.static_pathh   s#    C$))M'BCDDr(   c           	        U R                    S3n U R                  US5        U R                  R	                  S[
        5      R                  nUc  [        U SS5      nSnU(       a0  U R                  R                  S	-   U R                  R                  -   nU R                  U R                  S
.n	U[        [        U" X40 UD65      -   $ ! [         a$  nX@R                  ;   a  Sn[        U5      SeUeSnAff = f)aK  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.
r\   rP   zlThis 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://)r]   rY   )r   require_setting	Exceptionr   rL   r
   make_static_urlgetattrrequestprotocolhostr]   rY   r   r   )
r   pathra   r1   r;   emsgget_urlbaser   s
             r   rP    ExtensionHandlerMixin.static_urll   s    " =)
	  l3 --##$:OL\\"4?L<<((504<<3D3DDD
  ++!%!7!7

 d3 A& ABBB5  	mm#?   n$.	s   C	 	
C7C22C7)r   )r   r   r0   r   r1   r   r   None)r   r   )r   r   )r   r   )r   r   )r   r   )r   r   r   r   r-   )rj   r   ra   zbool | Noner1   r   r   r   )r    r!   r"   r#   r$   __annotations__r.   propertyr6   r9   r?   rD   rG   rJ   rV   rY   r]   rP   r%   r&   r'   s   @r   r*   r*   #   s      > > 5 5 4 4 D D 7 7 = =0 3 3 E E.C .Cr(   r*   N)r$   
__future__r   loggingr   typingr   r   r   jinja2r   jinja2.exceptionsr	   jupyter_server.base.handlersr
   traitlets.configr   $jupyter_server.extension.applicationr   jupyter_server.serverappr   r   r*   r   r(   r   <module>r|      sA     "  + +  . 8'A2> >wC wCr(   