ó
¸9—^c           @   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 d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿN(   t   apps(   t   settings(   t   BaseCommandt   CommandError(   t   color_style(   t   get_template(   t   get_template_setting(   t   signalcommandt   Commandc           B   sJ   e  Z d  Z d Z e d d d g ƒ Z d „  Z d „  Z e d „  ƒ Z	 RS(   t    s/   Validate templates on syntax and compile errorss	   .DS_Stores   *.swps   *~c         C   s´   t  t |  ƒ j | ƒ | j d d d d d d t d d ƒ| j d	 d
 d d d d d t d d ƒ| j d d d d d d d g  d d ƒ| j d d d d d d g  d d ƒd  S(   Ns	   --no-appst   actiont
   store_truet   destt   no_appst   defaultt   helps"   Do not automatically include apps.s   --breaks   -bt   breaks   Break on first error.s	   --includes   -it   appendt   includess#   Append these paths to TEMPLATE DIRSs   --ignore-appt   ignore_appss   Ignore these apps(   t   superR   t   add_argumentst   add_argumentt   False(   t   selft   parser(    (    sZ   /tmp/pip-unpacked-wheel-a0M10Y/django_extensions/management/commands/validate_templates.pyR      s    c         C   s@   t  j j | ƒ } x' |  j D] } t j | | ƒ r t Sq Wt S(   N(   t   ost   patht   basenamet   ignorest   fnmatcht   TrueR   (   R   t   filenamet   ignore_pattern(    (    sZ   /tmp/pip-unpacked-wheel-a0M10Y/django_extensions/management/commands/validate_templates.pyt   ignore_filename,   s
    c         O   s‰  t  t d ƒ r$ t t d ƒ |  _ n  t ƒ  } t t d ƒ ƒ } | t | d ƒ O} | t t t d g  ƒ ƒ O} | d s| d } | r« t  t d ƒ r« t t d ƒ } n  xf t j ƒ  D]U } | j	 | k rÓ q¸ n  t
 j j | j d ƒ } t
 j j | ƒ r¸ | j | ƒ q¸ q¸ Wn  t | ƒ t j d	 d <t t _ | d
 } d	 }	 x| D]	}
 x t
 j |
 ƒ D]ï \ } } } xÝ | D]Õ } |  j | ƒ r’qwn  t
 j j | | ƒ } | d k rÆ|  j j | ƒ n  y t | ƒ WnV t k
 r,} |	 d 7}	 |  j j d | | j d | j j t | ƒ f ƒ f ƒ n X|	 rw| d rwt d ƒ ‚ qwqwWqaWqKW|	 rqt d |	 ƒ ‚ n  |  j j d |	 ƒ d  S(   Nt   VALIDATE_TEMPLATES_IGNORESt   DIRSR   t&   VALIDATE_TEMPLATES_EXTRA_TEMPLATE_DIRSR   R   t   VALIDATE_TEMPLATES_IGNORE_APPSt	   templatesi    t	   verbosityi   s   %s: %ss   %s %sR   s   Errors founds   %s errors found(   t   hasattrR   t   getattrR   R   t   setR   R    t   get_app_configst   nameR   R   t   joint   isdirt   addt   listt	   TEMPLATESR   t   TEMPLATE_DEBUGt   walkR"   t   stdoutt   writeR   t	   Exceptiont   ERRORt	   __class__t   __name__t   strR   (   R   t   argst   optionst   stylet   template_dirsR   t   appt   app_template_dirR(   t   errorst   template_dirt   roott   dirst	   filenamesR    t   filepatht   e(    (    sZ   /tmp/pip-unpacked-wheel-a0M10Y/django_extensions/management/commands/validate_templates.pyt   handle3   sL    	

	

=(
   R:   t
   __module__R<   R   R+   R   R   R"   R   RI   (    (    (    sZ   /tmp/pip-unpacked-wheel-a0M10Y/django_extensions/management/commands/validate_templates.pyR      s   		(   R   R   t   django.appsR    t   django.confR   t   django.core.management.baseR   R   t   django.core.management.colorR   t   django.template.loaderR   t   django_extensions.compatR   t"   django_extensions.management.utilsR   R   (    (    (    sZ   /tmp/pip-unpacked-wheel-a0M10Y/django_extensions/management/commands/validate_templates.pyt   <module>   s   