î
à^Q\ü  ã               @   sx   d  d l  Z  d  d l Z d  d l m Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z Gd d „  d e ƒ Z d S)é    N)Újoin)Úsettings)ÚBaseCommandÚCommandError)Úsignalcommandc               @   s:   e  Z d  Z d Z d Z d d „  Z e d d „  ƒ Z d S)ÚCommandz<Removes all python bytecode compiled files from the project.Fc          
   C   sK   | j  d d d d d d d d d	 ƒ| j  d
 d d d d d d d ƒd  S)Nz
--optimizez-oz-OÚactionÚ
store_trueÚdestÚoptimizeÚhelpz&Remove optimized python bytecode filesz--pathz-pÚstoreÚpathzSpecify path to recurse into)Úadd_argument)ÚselfÚparser© r   ú`/var/www/dbchiro/venv/build/django-extensions/django_extensions/management/commands/clean_pyc.pyÚadd_arguments   s
    zCommand.add_argumentsc             O   s  | j  d t t d d  ƒ ƒ } | s9 t t d d  ƒ } n  t | j  d ƒ ƒ } | sc t d ƒ ‚ n  | j  d d ƒ r{ d p~ d } x| t j | ƒ D]k \ } } } xY t j | | ƒ D]E }	 t	 | |	 ƒ }
 | d	 k rë |  j
 j d
 |
 ƒ n  t j |
 ƒ q³ Wq‘ Wd  S)Nr   ZBASE_DIRÚ	verbosityz=No --path specified and settings.py does not contain BASE_DIRr   Fz*.py[co]z*.pycé   z%s
)ÚgetÚgetattrr   Úintr   Ú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   Zrequires_system_checksr   r   r*   r   r   r   r   r      s   r   )r   r   Úos.pathr   r   Zdjango.confr   Zdjango.core.management.baser   r   Z"django_extensions.management.utilsr   r   r   r   r   r   Ú<module>   s   