
    kh                         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
e          ZdS )    N)apps)settings)BaseCommandCommandError)color_style)get_template)get_template_setting)signalcommandc                   \     e Zd ZdZdZ eg d          Z fdZd Ze	d             Z
 xZS )Command z/Validate templates on syntax and compile errors)z	.DS_Storez*.swpz*~c                    t                                          |           |                    ddddd           |                    dddd	dd
           |                    ddddg d           |                    dddg 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__s     o/var/www/histauto/venv/lib/python3.11/site-packages/django_extensions/management/commands/validate_templates.pyr   zCommand.add_arguments   s    f%%%5 	 	
 	
 	
 	( 	 	
 	
 	
 	6 	 	
 	
 	
 	$ 	 	
 	
 	
 	
 	
    c                     t           j                            |          }| j        D ]}t	          j        ||          r dS dS )NTF)ospathbasenameignoresfnmatch)r   filenameignore_patterns      r   ignore_filenamezCommand.ignore_filename@   sM    7##H--"l 	 	Nx88 ttur    c                    t          t          d          rt          t          d          | _        t	                      }t          t          dg                     }|t          |d                   z  }|t          t          t          dg                     z  }|d         s|d         }|s*t          t          d          rt          t          d          }t          j                    D ]e}|j	        |v rt          j                            |j        d          }t          j                            |          r|                    |           ft          |          t          j        d	         d<   d
t          _        |d         }d	}	|D ]}
t          j        |
          D ]\  }}}|D ]}|                     |          rt          j                            ||          }|dk    r| j                            |           	 t-          |           nj# t.          $ r]}|	dz  }	| j                            |d|                    |j        j        dt7          |                               Y d }~nd }~ww xY w|	r|d         rt9          d          |	rt9          d|	z            | j                            d|	z             d S )NVALIDATE_TEMPLATES_IGNORESDIRSr   &VALIDATE_TEMPLATES_EXTRA_TEMPLATE_DIRSr   r   VALIDATE_TEMPLATES_IGNORE_APPS	templatesr   T	verbosity   z:  r   zErrors foundz%s errors found)hasattrr   getattrr%   r   setr	   r   get_app_configsnamer"   r#   joinisdiraddlist	TEMPLATESTEMPLATE_DEBUGwalkr)   stdoutwriter   	ExceptionERRORr   __name__strr   )r   argsoptionsstyletemplate_dirsr   appapp_template_dirr0   errorstemplate_dirrootdirs	filenamesr'   filepathes                    r   handlezCommand.handleG   s   89:: 	K"8-IJJDL0<<==WZ0111HFKK
 
 	
 y! 		8!-0K R785U#V#V R%h0PQQ+-- 8 88{**#%7<<+#F#F 7==!122 8!%%&6777(,](;(;1f%"&K(	) 	; 	;L)+)>)> ; ;%dI ) ; ;H++H55 ! !w||D(;;H 1}}))(333
$X....$   !)) !) %q{7K7K7KSQRVVV,T U U U         ;''"2 ;*>:::';;,  	;069:::+f455555s    H
I7	AI2	2I7	)rC   
__module____qualname__rE   r   r5   r%   r   r)   r
   rR   __classcell__)r   s   @r   r   r      s        D<Dc	
 	
 	
 G
 
 
 
 
B   46 46 ]46 46 46 46 46r    r   )r"   r&   django.appsr   django.confr   django.core.management.baser   r   django.core.management.colorr   django.template.loaderr   django_extensions.compatr	   "django_extensions.management.utilsr
   r    r    r   <module>r^      s    				                    A A A A A A A A 4 4 4 4 4 4 / / / / / / 9 9 9 9 9 9 < < < < < <h6 h6 h6 h6 h6k h6 h6 h6 h6 h6r    