
W
                 @   s   d  d l  m Z d d l m Z m Z m Z e e j  d d    Z d d   Z d d	   Z	 d
 d   Z
 d d   Z d d   Z d S)    )unicode_literals   )TagsWarningregisterc             K   s#   d d l  m } |   } t |  S)Nr   )get_resolver)django.core.urlresolversr   check_resolver)Zapp_configskwargsr   resolver r   9/tmp/pip-build-5ouued3s/Django/django/core/checks/urls.pycheck_url_config   s    	r   c             C   s   d d l  m } m } g  } x |  j D]v } t | |  rd | j t |   | j t |   n% t | |  r | j t |   n  | j t	 |   q& W| S)z)
    Recursively check the resolver.
    r   )RegexURLPatternRegexURLResolver)
r   r   r   Zurl_patterns
isinstanceextendcheck_include_trailing_dollarr	   check_pattern_namecheck_pattern_startswith_slash)r   r   r   warningspatternr   r   r   r	      s    r	   c             C   sD   d j  |  j j  } t |  d d  r@ | d j  |  j  7} n  | S)zA
    Format the URL pattern for display in warning messages.
    z'{}'nameFz [name='{}'])formatregexr   getattrr   )r   descriptionr   r   r   describe_pattern    s    r   c             C   s[   |  j  j } | j d  rS | j d  rS t d j t |    d d } | g Sg  Sd S)zK
    Check that include is not used with a regex ending with a dollar.
    $z\$zYour URL pattern {} uses include with a regex ending with a '$'. Remove the dollar from the regex to avoid problems including URLs.idz	urls.W001N)r   r   endswithr   r   r   )r   regex_patternwarningr   r   r   r   *   s    	r   c             C   sZ   |  j  j } | j d  s* | j d  rR t d j t |    d d } | g Sg  Sd S)zE
    Check that the pattern does not begin with a forward slash.
    /z^/z]Your URL pattern {} has a regex beginning with a '/'. Remove this slash as it is unnecessary.r   z	urls.W002N)r   r   
startswithr   r   r   )r   r!   r"   r   r   r   r   ;   s    	r   c             C   sN   |  j  d k	 rF d |  j  k rF t d j t |    d d } | g Sg  Sd S)z?
    Check that the pattern name does not contain a colon.
    N:zjYour URL pattern {} has a name including a ':'. Remove the colon, to avoid ambiguous namespace references.r   z	urls.W003)r   r   r   r   )r   r"   r   r   r   r   K   s    	r   N)
__future__r    r   r   r   urlsr   r	   r   r   r   r   r   r   r   r   <module>   s   
