U
    ad                     @   sd   d dl Z d dlZd dl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 de
ZdS )	    N)join)List)settings)BaseCommandCommandError)signalcommandc                   @   s6   e Zd ZU dZg Zee ed< dd Ze	dd Z
dS )Commandz<Removes all python bytecode compiled files from the project.requires_system_checksc              	   C   s0   |j dddddddd |j d	d
dddd d S )Nz
--optimizez-oz-O
store_trueoptimizeFz&Remove optimized python bytecode files)actiondestdefaulthelpz--pathz-pstorepathzSpecify path to recurse into)r   r   r   )add_argument)selfparser r   S/tmp/pip-unpacked-wheel-portabvm/django_extensions/management/commands/clean_pyc.pyadd_arguments   s            zCommand.add_argumentsc                 O   s   | dttdd }|s$ttdd }|d }|s8td|d rDdpFd}t|D ]H\}}}t||D ]0}	t||	}
|dkr| j	
d	|
  t|
 qhqRd S )
Nr   ZBASE_DIR	verbosityz=No --path specified and settings.py does not contain BASE_DIRr   z*.py[co]z*.pyc   z%s
)getgetattrr   r   oswalkfnmatchfilter_jstdoutwriteremove)r   argsoptionsZproject_rootr   extsrootdirs	filenamesfilename	full_pathr   r   r   handle   s    
zCommand.handleN)__name__
__module____qualname__r   r	   r   str__annotations__r   r   r,   r   r   r   r   r      s
   
r   )r   r   os.pathr   r    typingr   Zdjango.confr   Zdjango.core.management.baser   r   Z"django_extensions.management.utilsr   r   r   r   r   r   <module>   s   