3
g+                 @   s|   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
 d dlmZ d dlmZ d dlmZ G d	d
 d
eZdS )    N)apps)settings)BaseCommandCommandError)color_style)get_template)get_template_setting)signalcommandc                   sF   e Zd ZdZdZedddgZ fddZdd	 Ze	d
d Z
  ZS )Command z/Validate templates on syntax and compile errorsz	.DS_Storez*.swpz*~c                sd   t  j| |jdddddd |jdddd	dd
d |jddddg dd |jdddg dd d S )Nz	--no-apps
store_trueno_appsFz"Do not automatically include apps.)actiondestdefaulthelpz--breakz-bbreakzBreak on first error.z	--includez-iappendincludesz#Append these paths to TEMPLATE DIRSz--ignore-appignore_appszIgnore these apps)superadd_argumentsadd_argument)selfparser)	__class__ v/var/www/tester-filtro-web/env/lib/python3.6/site-packages/django_extensions/management/commands/validate_templates.pyr      s    


zCommand.add_argumentsc             C   s0   t jj|}x| jD ]}tj||rdS qW dS )NTF)ospathbasenameignoresfnmatch)r   filenameZignore_patternr   r   r   ignore_filename,   s
    zCommand.ignore_filenamec             O   s  t tdrttd| _t }ttdg }|t|d O }|tttdg O }|d s|d }| rxt tdrxttd}xBtj D ]6}|j	|krqt
jj|jd}t
jj|r|j| qW t|tjd	 d< d
t_|d }d	}	x|D ]}
xt
j|
D ]\}}}x|D ]}| j|rqt
jj||}|dkr>| jj| yt| W nV tk
r } z8|	d7 }	| jjd||jd|jjt|f f  W Y d d }~X nX |	r|d rtdqW qW qW |	rtd|	 | jjd|	  d S )NZVALIDATE_TEMPLATES_IGNORESZDIRSr   Z&VALIDATE_TEMPLATES_EXTRA_TEMPLATE_DIRSr   r   ZVALIDATE_TEMPLATES_IGNORE_APPSZ	templatesr   T	verbosity   z%s: %sz%s %sr   zErrors foundz%s errors found)hasattrr   getattrr!   r   setr   r   Zget_app_configsnamer   r   joinisdiraddlistZ	TEMPLATESZTEMPLATE_DEBUGwalkr$   stdoutwriter   	ExceptionERRORr   __name__strr   )r   argsoptionsstyleZtemplate_dirsr   ZappZapp_template_dirr%   errorsZtemplate_dirrootdirs	filenamesr#   filepather   r   r   handle3   sL    





<zCommand.handle)r4   
__module____qualname__r6   r   r)   r!   r   r$   r	   r?   __classcell__r   r   )r   r   r
      s   r
   )r   r"   Zdjango.appsr   Zdjango.confr   Zdjango.core.management.baser   r   Zdjango.core.management.colorr   Zdjango.template.loaderr   Zdjango_extensions.compatr   Z"django_extensions.management.utilsr	   r
   r   r   r   r   <module>   s   