ó
®â0_c           @  sÕ   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d d l m	 Z	 m
 Z
 m Z m Z e e
 j ƒ d „  ƒ Z d „  Z e e
 j ƒ d	 „  ƒ Z d d
 „ Z d „  Z e e
 j ƒ d „  ƒ Z d „  Z d S(   iÿÿÿÿ(   t   unicode_literals(   t   Counter(   t   settings(   t   sixi   (   t   Errort   Tagst   Warningt   registerc         K  s9   t  t d d  ƒ r5 d d l m } | ƒ  } t | ƒ Sg  S(   Nu   ROOT_URLCONFiÿÿÿÿ(   t   get_resolver(   t   getattrR   t   Nonet   django.urlsR   t   check_resolver(   t   app_configst   kwargsR   t   resolver(    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyt   check_url_config   s
    	
c         C  sF   t  |  d d ƒ } | d k	 r% | ƒ  St |  d ƒ s> t |  ƒ Sg  Sd S(   u)   
    Recursively check the resolver.
    u   checku   resolveN(   R	   R
   t   hasattrt   get_warning_for_invalid_pattern(   R   t   check_method(    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyR      s    
c         K  sµ   t  t d d ƒ s g  Sd d l m } | ƒ  } t | ƒ } t | ƒ } g  | j ƒ  D] \ } } | d k rT | ^ qT } g  }	 x0 | D]( }
 |	 j t	 d j
 |
 ƒ d d ƒƒ q… W|	 S(	   uD   
    Warn if URL namespaces used in applications aren't unique.
    u   ROOT_URLCONFiÿÿÿÿ(   R   i   uZ   URL namespace '{}' isn't unique. You may not be able to reverse all URLs in this namespacet   idu	   urls.W005N(   R	   R   R
   R   R   t   _load_all_namespacesR   t   itemst   appendR   t   format(   R   R   R   R   t   all_namespacest   countert   nt   countt   non_unique_namespacest   errorst	   namespace(    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyt   check_url_namespaces_unique!   s    	1		c         C  sµ   t  |  d g  ƒ } g  | D]7 } t  | d d ƒ d k	 r d j | | j f ƒ ^ q } xX | D]P } t  | d d ƒ } | } | d k	 r— | | f 7} n  | j t | | ƒ ƒ q] W| S(   u<   
    Recursively load all namespaces from URL patterns.
    u   url_patternsu	   namespaceu   :N(   R	   R
   t   joinR   t   extendR   (   R   t   parentst   url_patternst   urlt
   namespacest   patternR   t   current(    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyR   8   s    7c         C  sd   t  |  t j ƒ r$ d j |  ƒ } n t  |  t ƒ r< d } n d } t d j |  ƒ d | d d ƒg S(   uÄ   
    Return a list containing a warning that the pattern is invalid.

    describe_pattern() cannot be used here, because we cannot rely on the
    urlpattern having regex or name attributes.
    uk   Try removing the string '{}'. The list of urlpatterns should not have a prefix string as the first element.u#   Try using url() instead of a tuple.uW   Your URL pattern {!r} is invalid. Ensure that urlpatterns is a list of url() instances.t   hintR   u	   urls.E004N(   t
   isinstanceR   t   string_typesR   t   tupleR
   R   (   R'   R)   (    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyR   J   s    		c         K  sV   g  } xI d D]A } t  t | ƒ } | r | j d ƒ r | j t | ƒ ƒ q q W| S(   Nu
   STATIC_URLu	   MEDIA_URLu   /(   u
   STATIC_URLu	   MEDIA_URL(   R	   R   t   endswithR   t   E006(   R   R   R   t   namet   value(    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyt   check_url_settingsc   s    c         C  s   t  d j |  ƒ d d ƒS(   Nu%   The {} setting must end with a slash.R   u	   urls.E006(   R   R   (   R/   (    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyR.   m   s    N(    (   t
   __future__R    t   collectionsR   t   django.confR   t   django.utilsR   t    R   R   R   R   t   urlsR   R   R    R   R   R1   R.   (    (    (    s9   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/urls.pyt   <module>   s   "			
