a
    5XhS
                     @   s   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
mZmZ e	de dd	Zee
jd
d Zee
jdddd Zee
jdd ZdS )    N)settings)DEFAULT_CACHE_ALIAScaches)FileBasedCache   )ErrorTagsWarningregisterz4You must define a '%s' cache in your CACHES setting.zcaches.E001idc                 K   s   t tjvrtgS g S N)r   r   CACHESE001)app_configskwargs r   ^/var/www/viveiro_mudafortebrasil/venv/lib/python3.9/site-packages/django/core/checks/caches.py!check_default_cache_is_configured   s    
r   T)Zdeployc                    s&  g }dD ]}t t|d }|s q|dkrdt }|D ].}t|ttfrL|\}}|t|	  q2nt|	 h}tj
D ]}t| }	t|	tsqzt|	j	  t fdd|D rd}
n:t fdd|D rd}
nt fdd|D rzd	}
nqz|td
| d|
 d| ddd qzq|S )N)Z
MEDIA_ROOTZSTATIC_ROOTSTATICFILES_DIRSr   c                 3   s   | ]}| kV  qd S r   r   .0path
cache_pathr   r   	<genexpr>*       z3check_cache_location_not_exposed.<locals>.<genexpr>matchesc                 3   s   | ]}| j v V  qd S r   parentsr   r   r   r   r   ,   r   z	is insidec                 3   s   | ]} |j v V  qd S r   r   r   r   r   r   r   .   r   containsYour 'zf' cache configuration might expose your cache or lead to corruption of your data because its LOCATION  .zcaches.W002r   )getattrr   set
isinstancelisttupleaddpathlibPathresolver   r   r   Z_diranyappendr	   )r   r   errorsnameZsettingpathsZstaticfiles_dir_aliascacheZrelationr   r   r    check_cache_location_not_exposed   sF    


r5   c                 K   s\   g }t j D ]H\}}t| }t|ts*qt|d  s|	t
d| ddd q|S )NZLOCATIONr!   z@' cache LOCATION path is relative. Use an absolute path instead.zcaches.W003r   )r   r   itemsr   r&   r   r*   r+   is_absoluter.   r	   )r   r   r/   r3   configr4   r   r   r   "check_file_based_cache_is_absolute=   s    

r9   )r*   Zdjango.confr   Zdjango.core.cacher   r   Z$django.core.cache.backends.filebasedr    r   r   r	   r
   r   r   r5   r9   r   r   r   r   <module>   s   

&