
    7 f                         d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZ d d	lmZ  G d
 d          Z ed          Z G d de          Ze
j        Z G d dej                  ZdS )    N)
ContextVar)joinnormpath)settings)findersstorage)Warning)
LazyObject)gettext_lazyngettext)panelsc                   *    e Zd ZdZd Zd Zd Zd ZdS )
StaticFilezA
    Representing the different properties of a static file.
    c                     || _         d S Npath)selfr   s     V/var/www/equiseq/venv/lib/python3.11/site-packages/debug_toolbar/panels/staticfiles.py__init__zStaticFile.__init__   s    			    c                     | j         S r   r   r   s    r   __str__zStaticFile.__str__   s
    yr   c                 4    t          j        | j                  S r   )r   findr   r   s    r   	real_pathzStaticFile.real_path   s    |DI&&&r   c                 J    t           j                            | j                  S r   )r   staticfiles_storageurlr   r   s    r   r    zStaticFile.url   s    *..ty999r   N)__name__
__module____qualname____doc__r   r   r   r     r   r   r   r      sZ             ' ' ': : : : :r   r   djdt_static_used_static_filesc                       e Zd ZdZd ZdS )DebugConfiguredStoragez
    A staticfiles storage class to be used for collecting which paths
    are resolved by using the {% static %} template tag (which uses the
    `url` method).
    c                     	 ddl m} |d         j        }n+# t          $ r ddl m}  |t
          j                  }Y nw xY w G d d|          } |            | _        d S )Nr   )storagesstaticfiles)get_storage_classc                        e Zd Z fdZ xZS )>DebugConfiguredStorage._setup.<locals>.DebugStaticFilesStoragec                    t          j        t                    5  t                                                              t          |                     d d d            n# 1 swxY w Y   t                                          |          S r   )	
contextlibsuppressLookupErrorused_static_filesgetappendr   superr    )r   r   	__class__s     r   r    zBDebugConfiguredStorage._setup.<locals>.DebugStaticFilesStorage.url9   s    (55 E E
 &))++22:d3C3CDDDE E E E E E E E E E E E E E E ww{{4(((s   :A!!A%(A%)r!   r"   r#   r    __classcell__r7   s   @r   DebugStaticFilesStorager.   8   s8        ) ) ) ) ) ) ) ) )r   r:   )django.core.files.storager*   r7   ImportErrorr,   r   STATICFILES_STORAGE_wrapped)r   r*   configured_storage_clsr,   r:   s        r   _setupzDebugConfiguredStorage._setup+   s    
	U ;:::::%-m%<%F"" 	U 	U 	UCCCCCC%6%6x7S%T%T"""		U	) 	) 	) 	) 	)&< 	) 	) 	) 0/11s    %>>N)r!   r"   r#   r$   r@   r%   r   r   r(   r(   $   s-         2 2 2 2 2r   r(   c                        e Zd ZdZdZdZed             Z fdZd Z	d Z
ed             Z ed          Zed	             Z fd
Zd Zd Zd Zd Zed             Z xZS )StaticFilesPanelz3
    A panel to display the found staticfiles.
    zStatic filesz%debug_toolbar/panels/staticfiles.htmlc                 @    t          d          | j        | j        dz  S )Nz5Static files (%(num_found)s found, %(num_used)s used))	num_foundnum_used)_rD   rE   r   s    r   titlezStaticFilesPanel.titleP   s.    HIIM
 M
 
 	
r   c                 V     t                      j        |i | d| _        g | _        d S )Nr   )r6   r   rD   
used_paths)r   argskwargsr7   s      r   r   zStaticFilesPanel.__init__W   s1    $)&)))r   c                 6    t                      t          _        d S r   )r(   r   r   r   s    r   enable_instrumentationz'StaticFilesPanel.enable_instrumentation\   s    &<&>&>###r   c                 (    t           t          _        d S r   )_original_storager   r   r   s    r   disable_instrumentationz(StaticFilesPanel.disable_instrumentation_   s    &7###r   c                 >    |                                  }|o|d         S )NrE   )	get_stats)r   statss     r   rE   zStaticFilesPanel.num_usedb   s!      *z**r   c                 <    | j         }t          dd|          d|iz  S )Nz%(num_used)s file usedz%(num_used)s files usedrE   )rE   r   )r   rE   s     r   nav_subtitlezStaticFilesPanel.nav_subtitlei   s0    =$&?
 
"# 	#r   c                    t                               g           }t                                          |          }t                                                                           | _        t                               |           |S r   )r3   setr6   process_requestr4   copyrI   reset)r   requestreset_tokenresponser7   s       r   rX   z StaticFilesPanel.process_requestp   si    '++B//77**733 ,//116688 	,,,r   c           	          |                      | j        t          | j                  | j        |                                 |                                 |                                 d           d S )N)rD   rE   r+   staticfiles_appsstaticfiles_dirsstaticfiles_finders)record_statsrD   lenrI   get_staticfiles_appsget_staticfiles_dirsget_staticfiles_finders)r   r[   r]   s      r   generate_statszStaticFilesPanel.generate_stats{   sr    !^00#$($=$=$?$?$($=$=$?$?'+'C'C'E'E 		
 		
 		
 		
 		
r   c                    i }t          j                    D ]}	 |                    g           D ]\  }}t          |dd          rt	          |j        |          }n|}|j        }d                    |j        |j        g          }|	                    |          }||f}	|
                    |g                               |	           | xj        dz  c_        # t          $ r Y w xY w|S )z
        Returns a sorted mapping between the finder path and the list
        of relative and file system paths which that finder was able
        to find.
        prefixN.   )r   get_finderslistgetattrr   ri   r7   r"   r!   r   
setdefaultr5   rD   OSError)
r   finders_mappingfinderr   finder_storageprefixed_path
finder_clsfinder_pathr   payloads
             r   rf   z(StaticFilesPanel.get_staticfiles_finders   s    )++ 	 	F,2KKOO 
( 
((D.~x>> -(,^-BD(I(I(,!'!1J"%((J,A:CV+W"X"XK . 3 3D 9 9I,i8G#..{B??FFwOOONNa'NNN
(     s   B>C
C%$C%c                     g }t          j                    D ]6}t          |t           j                  r|                    |j                   7d |D             S )zP
        Returns a list of paths to inspect for additional static files
        c                 6    g | ]\  }}|t          |          fS r%   )r   ).0ri   dirs      r   
<listcomp>z9StaticFilesPanel.get_staticfiles_dirs.<locals>.<listcomp>   s'    @@@KFC#'@@@r   )r   rl   
isinstanceFileSystemFinderextend	locations)r   dirsrr   s      r   re   z%StaticFilesPanel.get_staticfiles_dirs   s`     )++ 	. 	.F&'":;; .F,---@@4@@@@r   c                     g }t          j                    D ]?}t          |t           j                  r#|j        D ]}||vr|                    |           @|S )zJ
        Returns a list of app paths that have a static directory
        )r   rl   r}   AppDirectoriesFinderappsr5   )r   r   rr   apps       r   rd   z%StaticFilesPanel.get_staticfiles_apps   si     )++ 	) 	)F&'">?? )!; ) )C$C(((r   c           	         g }t          j                    D ]h}	 |                    g           D ]\  }}|                    |           4# t          $ r( |                    t          ddd                     Y ew xY w|S )z
        Check that the integration is configured correctly for the panel.

        Specifically look for static files that haven't been collected yet.

        Return a list of :class: `django.core.checks.CheckMessage` instances.
        zAdebug_toolbar requires the STATICFILES_DIRS directories to exist.z;Running manage.py collectstatic may help uncover the issue.zdebug_toolbar.staticfiles.W001)hintid)r   rl   rm   r   rp   r5   r	   )clserrorsrr   r   rs   s        r   
run_checkszStaticFilesPanel.run_checks   s     )++ 	 	F
,2KKOO . .(D."''----.   [Z;       s   0A

/A<;A<)r!   r"   r#   r$   nametemplatepropertyrG   r   rM   rP   rE   rF   	nav_titlerU   rX   rg   rf   re   rd   classmethodr   r8   r9   s   @r   rB   rB   H   s=         D6H
 
 X
    
? ? ?8 8 8 + + X+ .!!I# # X#	 	 	 	 	

 

 

  2A A A
 
 
   [    r   rB   )r0   contextvarsr   os.pathr   r   django.confr   django.contrib.staticfilesr   r   django.core.checksr	   django.utils.functionalr
   django.utils.translationr   rF   r   debug_toolbarr   r   r3   r(   r   rO   PanelrB   r%   r   r   <module>r      sd       " " " " " " " " " " " " " "             7 7 7 7 7 7 7 7 & & & & & & . . . . . . @ @ @ @ @ @ @ @            : : : : : : : :& J>?? 2 2 2 2 2Z 2 2 2B / D D D D Dv| D D D D Dr   