o
    ~¨ÊhÐ  ã                   @   sT   d dl Z d dlZd dlmZmZ d dlmZ d dlmZm	Z	m
Z
 G dd„ deƒZdS )é    N)ÚBaseCommandÚCommandError)Úsettings)ÚcacheÚ	get_mtimeÚget_mtime_cachekeyc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚCommandz-Add or remove all mtime values from the cachec              	   C   st   |j dddg dddd�f |j dd	d
ddd�f |j ddddd�f |j dddddd�f |j dddddd�f d S )Nz-iz--ignoreÚappendÚignore_patternsÚPATTERNz`Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.)ÚactionÚdefaultÚdestÚmetavarÚhelpz--no-default-ignoreÚstore_falseÚuse_default_ignore_patternsTzIDon't ignore the common private glob-style patterns 'CVS', '.*' and '*~'.)r   r   r   r   z--follow-linksÚfollow_linksÚ
store_truez¼Follow symlinks when traversing the COMPRESS_ROOT (which defaults to STATIC_ROOT). Be aware that using this can lead to infinite recursion if a link points to a parent directory of itself.)r   r   r   z-cz--cleanÚcleanzRemove all itemsz-az--addÚaddzAdd all items)Úadd_argument)ÚselfÚparser© r   ú\/var/www/html/env/lib/python3.10/site-packages/compressor/management/commands/mtime_cache.pyÚadd_arguments   s,   ýýþþþzCommand.add_argumentsc                 C   s"   | j D ]}t ||¡r dS qdS )z–
        Return True or False depending on whether the ``path`` should be
        ignored (if it matches any pattern in ``ignore_patterns``).
        TF)r
   ÚfnmatchÚfnmatchcase)r   ÚpathÚpatternr   r   r   Ú
is_ignored%   s
   
ÿzCommand.is_ignoredc                 K   s€  |d }|d r|g d¢7 }||d< || _ |d r|d s%|d s)|d s)tdƒ‚tjs0tdƒ‚tƒ }tƒ }tjtj|d d	�D ]S\}}}|D ]}|  |¡rS| 	|¡ qG|D ]<}	d
 
| tj¡¡}
|
 tj¡rp|
ttjƒd … }
|  tj 
|
|	¡¡r{qVtj 
||	¡}	| t|	ƒ¡ |d r’| |	¡ qVq@|r§t t|ƒ¡ | j dt|ƒ ¡ |r¾|D ]}	t|	ƒ q«| j dt|ƒ ¡ d S d S )Nr
   r   )ÚCVSz.*z*~r   r   z*Please specify either "--add" or "--clean"zhmtime caching is currently disabled. Please set the COMPRESS_MTIME_DELAY setting to a number of seconds.r   )ÚfollowlinksÚ z*Deleted mtimes of %d files from the cache.z"Added mtimes of %d files to cache.)r
   r   r   ÚCOMPRESS_MTIME_DELAYÚsetÚosÚwalkÚCOMPRESS_ROOTr!   ÚremoveÚjoinÚsplitÚ
startswithÚsepÚlenr   r   r   r   Údelete_manyÚlistÚstdoutÚwriter   )r   Úoptionsr
   Úfiles_to_addÚkeys_to_deleteÚrootÚdirsÚfilesÚdir_ÚfilenameÚcommonr   r   r   Úhandle/   s`   ÿÿÿÿ

€
€÷ÿ

ÿýzCommand.handleN)Ú__name__Ú
__module__Ú__qualname__r   r   r!   r=   r   r   r   r   r   
   s
    
r   )r   r'   Údjango.core.management.baser   r   Úcompressor.confr   Úcompressor.cacher   r   r   r   r   r   r   r   Ú<module>   s    