
    $g                     D    d dl mZ d dlmZ d dlmZ  G d d          ZdS )    )render_to_string)settings)get_name_from_objc                   x   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dS )Panelz 
    Base class for panels.
    c                 "    || _         || _        d S N)toolbarget_response)selfr
   r   s      ]/var/www/html/netbox-4.1.3/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                            d| j        z             }||dk    S t          j                    d         }t          |           }||vo|                    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778NOO#4'' &0223CD&t,,
 o- J""9c2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    
 zr   c                     dS )zO
        Subtitle shown in the side bar. Defaults to the empty string.
          r   s    r   nav_subtitlezPanel.nav_subtitle2   s	    
 rr   c                     dS )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	     tr   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                 b    | j         r't          | j        |                                           S dS )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]   s8      	E#DM4>>3C3CDDD	E 	E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                     dS )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                     dS )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                     dS )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                 v    | j         j                            | j        i                               |           dS )
        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   s5     	%%dmR88??FFFFFr   c                 L    | 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!     |!%%dmR888r   c                     |||di}| j         j                            | j        i                               |           dS )rF   )r&   valueN)r
   server_timing_statsrH   r   rI   )r   keyr&   rN   datas        r   record_server_timingzPanel.record_server_timing   sG     uu556(33DM2FFMMdSSSSSr   c                 L    | j         j                            | j        i           S rL   )r
   rO   r   r   r   s    r   get_server_timing_statszPanel.get_server_timing_stats   s!     |/33DM2FFFr   c                 ,    |                      |          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 }                                  }|r6d                     fd|                                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   | ]J\  }}d                      j        ||                    d          |                    d                    V  KdS )z{}_{};dur={};desc="{}"rN   r&   N)formatr   r   ).0rP   recordr   s      r   	<genexpr>z$Panel.get_headers.<locals>.<genexpr>   sp       1 1
  C )//M3

7(;(;VZZ=P=P 1 1 1 1 1 1r   zServer-Timing)rT   joinitems)r   r   headersrG   s   `   r   get_headerszPanel.get_headers   sr     ,,.. 	'+yy 1 1 1 1
 $);;==1 1 1 ( (GO$ r   c                     dS )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                     dS )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      s:        ) ) ) ' ' X' 
 
 
 
 X
(   X   X   X     X  " " X" " " X" 	E 	E X	E   X   [   [    G G G9 9 9T T TG G G	* 	* 	*  4
 
 
   	 	 [	 	 	r   r   N)django.template.loaderr   debug_toolbarr   r   debug_toolbar.utilsr   r   r*   r   r   <module>rr      sw    3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1A A A A A A A A A Ar   