
    7 f                     <    d dl mZ d dlmZ d dlmZ  G d d      Zy)    )render_to_string)settings)get_name_from_objc                   (   e Zd ZdZd Zed        Zedefd       Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zed        Zy)Panelz 
    Base class for panels.
    c                      || _         || _        y N)toolbarget_response)selfr
   r   s      S/var/www/equiseq/venv/lib/python3.11/site-packages/debug_toolbar/panels/__init__.py__init__zPanel.__init__   s    (    c                 .    | j                   j                  S r	   )	__class____name__r   s    r   panel_idzPanel.panel_id   s    ~~&&&r   returnc                     | j                   j                  j                  j                  d| j                  z         }||dk(  S t        j                         d   }t        |       }||vxr |j                  dd      |vS )NdjdtonDISABLE_PANELSz.panel..)	r
   requestCOOKIESgetr   dt_settings
get_configr   replace)r   cookie_valuedisabled_panels
panel_paths       r   enabledzPanel.enabled   s     ||++33778NO#4'' &0023CD&t,
 o- J""9c2/I	
r   c                     | j                   S )zI
        Title shown in the side bar. Defaults to :attr:`title`.
        )titler   s    r   	nav_titlezPanel.nav_title+   s    
 zzr   c                      y)zO
        Subtitle shown in the side bar. Defaults to the empty string.
          r   s    r   nav_subtitlezPanel.nav_subtitle2   s    
 r   c                      y)z
        ``True`` if the panel can be displayed in full screen, ``False`` if
        it's only shown in the side bar. Defaults to ``True``.
        Tr*   r   s    r   has_contentzPanel.has_content9   s     r   c                     | j                   S )zg
        Panel supports rendering historical values.

        Defaults to :attr:`has_content`.
        )r-   r   s    r   is_historicalzPanel.is_historicalA   s     r   c                     t         )z
        Title shown in the panel when it's displayed in full screen.

        Mandatory, unless the panel sets :attr:`has_content` to ``False``.
        NotImplementedErrorr   s    r   r&   zPanel.titleJ   s
     "!r   c                     t         )z
        Template used to render :attr:`content`.

        Mandatory, unless the panel sets :attr:`has_content` to ``False`` or
        overrides :attr:`content`.
        r1   r   s    r   templatezPanel.templateS   s
     "!r   c                 d    | j                   r$t        | j                  | j                               S y)z
        Content of the panel when it's displayed in full screen.

        By default this renders the template defined by :attr:`template`.
        Statistics stored with :meth:`record_stats` are available in the
        template's context.
        N)r-   r   r4   	get_statsr   s    r   contentzPanel.content]   s*     #DMM4>>3CDD r   c                     g S )a  
        Scripts used by the HTML content of the panel when it's displayed.

        When a panel is rendered on the frontend, the ``djdt.panel.render``
        JavaScript event will be dispatched. The scripts can listen for
        this event to support dynamic functionality.
        r*   r   s    r   scriptszPanel.scriptsi   s	     	r   c                      y)a  
        Perform early initialization for the panel.

        This should only include initialization or instrumentation that needs to
        be done unconditionally for the panel regardless of whether it is
        enabled for a particular request.  It should be idempotent.
        Nr*   clss    r   readyzPanel.readyv       r   c                     g S )zE
        Return URLpatterns, if the panel has its own views.
        r*   r;   s    r   get_urlszPanel.get_urls   s	    
 	r   c                      y)a  
        Enable instrumentation to gather data for this panel.

        This usually means monkey-patching (!) or registering signal
        receivers. Any instrumentation with a non-negligible effect on
        performance should be installed by this method rather than at import
        time.

        Unless the toolbar or this panel is disabled, this method will be
        called early in ``DebugToolbarMiddleware``. It should be idempotent.
        Nr*   r   s    r   enable_instrumentationzPanel.enable_instrumentation   r>   r   c                      y)a  
        Disable instrumentation to gather data for this panel.

        This is the opposite of :meth:`enable_instrumentation`.

        Unless the toolbar or this panel is disabled, this method will be
        called late in the middleware. It should be idempotent.
        Nr*   r   s    r   disable_instrumentationzPanel.disable_instrumentation   r>   r   c                     | j                   j                  j                  | j                  i       j	                  |       y)
        Store data gathered by the panel. ``stats`` is a :class:`dict`.

        Each call to ``record_stats`` updates the statistics dictionary.
        N)r
   stats
setdefaultr   update)r   rG   s     r   record_statszPanel.record_stats   s-     	%%dmmR8??Fr   c                 b    | j                   j                  j                  | j                  i       S zK
        Access data stored by the panel. Returns a :class:`dict`.
        )r
   rG   r   r   r   s    r   r6   zPanel.get_stats   s%     ||!!%%dmmR88r   c                     |||di}| j                   j                  j                  | j                  i       j	                  |       y)rF   )r&   valueN)r
   server_timing_statsrH   r   rI   )r   keyr&   rN   datas        r   record_server_timingzPanel.record_server_timing   s<     uu56((33DMM2FMMdSr   c                 b    | j                   j                  j                  | j                  i       S rL   )r
   rO   r   r   r   s    r   get_server_timing_statszPanel.get_server_timing_stats   s%     ||//33DMM2FFr   c                 $    | j                  |      S )z
        Like __call__ in Django's middleware.

        Write panel logic related to the request there. Save data with
        :meth:`record_stats`.

        Return the existing response or overwrite it.
        )r   )r   r   s     r   process_requestzPanel.process_request   s       ))r   c                      i } j                         }|r+dj                   fd|j                         D              |d<   |S )a  
        Get headers the panel needs to set.

        Called after :meth:`process_request
        <debug_toolbar.panels.Panel.generate_stats>` and
        :meth:`process_request<debug_toolbar.panels.Panel.generate_stats>`

        Header values will be appended if multiple panels need to set it.

        By default it sets the Server-Timing header.

        Return dict of headers to be appended.
        z, c           	   3      K   | ]C  \  }}d j                  j                  ||j                  d      |j                  d             E yw)z{}_{};dur={};desc="{}"rN   r&   N)formatr   r   ).0rP   recordr   s      r   	<genexpr>z$Panel.get_headers.<locals>.<genexpr>   sI      1
  C )//MM3

7(;VZZ=P1s   A	AzServer-Timing)rT   joinitems)r   r   headersrG   s   `   r   get_headerszPanel.get_headers   sJ     ,,.'+yy 1
 $);;=1 (GO$ r   c                      y)a*  
        Write panel logic related to the response there. Post-process data
        gathered while the view executed. Save data with :meth:`record_stats`.

        Called after :meth:`process_request
        <debug_toolbar.panels.Panel.process_request>`.


        Does not return a value.
        Nr*   r   r   responses      r   generate_statszPanel.generate_stats   r>   r   c                      y)z
        Similar to :meth:`generate_stats
        <debug_toolbar.panels.Panel.generate_stats>`,

        Generate stats for Server Timing https://w3c.github.io/server-timing/

        Does not return a value.
        Nr*   rb   s      r   generate_server_timingzPanel.generate_server_timing   r>   r   c                     g S )a  
        Check that the integration is configured correctly for the panel.

        This will be called as a part of the Django checks system when the
        application is being setup.

        Return a list of :class:`django.core.checks.CheckMessage` instances.
        r*   r;   s    r   
run_checkszPanel.run_checks   s	     	r   N)r   
__module____qualname____doc__r   propertyr   boolr$   r'   r+   r-   r/   r&   r4   r7   r9   classmethodr=   r@   rB   rD   rJ   r6   rR   rT   rV   r`   rd   rf   rh   r*   r   r   r   r      sN   ) ' ' 
 
 
(           " " " " 	E 	E      G9TG	*4
 	 	r   r   N)django.template.loaderr   debug_toolbarr   r   debug_toolbar.utilsr   r   r*   r   r   <module>rr      s    3 1 1A Ar   