
    jg+                         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y)    N)apps)settings)BaseCommandCommandError)color_style)get_template)get_template_setting)signalcommandc                   P     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         |   |       |j                  ddddd       |j                  dddd	dd
       |j                  ddddg d       |j                  dddg d       y )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     s/var/www/html/Stanley/venv/lib/python3.12/site-packages/django_extensions/management/commands/validate_templates.pyr   zCommand.add_arguments   s    f%9 D 	 	F 	tLw 7 	 	9 	hZB 	 	D 	8-0 	 	2    c                     t         j                  j                  |      }| j                  D ]  }t	        j                  ||      s y y)NTF)ospathbasenameignoresfnmatch)r   filenameignore_patterns      r   ignore_filenamezCommand.ignore_filename,   s:    77##H-"llNx8 + r    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 ]l  }|j                  |v rt        j                  j                  |j                  d      }t        j                  j                  |      s\|j                  |       n t        |      t        j                   d	   d<   d
t        _        |d   }d	}	|D ]  }
t        j$                  |
      D ]~  \  }}}|D ]s  }| j'                  |      rt        j                  j                  ||      }|dkD  r| j(                  j+                  |       	 t-        |       |	sd|d   sjt9        d         |	rt9        d|	z        | j(                  j+                  d|	z         y # t.        $ r`}|	dz  }	| j(                  j+                  |d|j1                  |j2                  j4                  dt7        |                   Y d }~d }~ww xY w)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.handle3   s5   89:"8-IJDL0<=WZ011WX/WY[\]]y!!-0K785U#V%h0PQ++-88{*#%77<<+#F 77==!12!%%&67 . )-](;1f%"&K(	)L)+)>%dI )H++H5 !ww||D(;H 1}))(3x$X. ''"2*>:: !* *? *" 069::+f45 % x!))hWXWbWbWkWkmpqrmsLt@u*vwwxs   H	J	(AJ	J	)rC   
__module____qualname__rE   r   r5   r%   r   r)   r
   rR   __classcell__)r   s   @r   r   r      s:    D<D  G2 ,6 ,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 4 / 9 <L6k L6r    