o
    e                      @   s   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d Z
dd Zeej	d	d
 ZdddZdd Zeej	dd Zdd ZdS )    )Counter)settings   )ErrorTagsWarningregisterc                 K   s*   t tdd rddlm} | }t|S g S )NROOT_URLCONFr   get_resolver)getattrr   django.urlsr   check_resolver)app_configskwargsr   resolver r   J/var/www/html/venv/lib/python3.10/site-packages/django/core/checks/urls.pycheck_url_config   s
   r   c                 C   s0   t | dd}|dur| S t| dst| S g S )z)
    Recursively check the resolver.
    checkNresolve)r   hasattrget_warning_for_invalid_pattern)r   check_methodr   r   r   r      s   
r   c           	      K   sn   t tddsg S ddlm} | }t|}t|}dd | D }g }|D ]}|td	|dd	 q&|S )
zD
    Warn if URL namespaces used in applications aren't unique.
    r	   Nr   r
   c                 S   s   g | ]
\}}|d kr|qS )r   r   ).0ncountr   r   r   
<listcomp>,   s    z/check_url_namespaces_unique.<locals>.<listcomp>zZURL namespace '{}' isn't unique. You may not be able to reverse all URLs in this namespacez	urls.W005id)
r   r   r   r   _load_all_namespacesr   itemsappendr   format)	r   r   r   r   all_namespacescounternon_unique_namespaceserrors	namespacer   r   r   check_url_namespaces_unique   s"   r)   r   c                    s^   t | dg } fdd|D }|D ]}t |dd} }|dur$||f7 }|t|| q|S )z<
    Recursively load all namespaces from URL patterns.
    url_patternsc                    s.   g | ]}t |d ddurd |jf qS )r(   N:)r   joinr(   )r   urlparentsr   r   r   >   s
    z(_load_all_namespaces.<locals>.<listcomp>r(   N)r   extendr    )r   r/   r*   
namespacespatternr(   currentr   r.   r   r    9   s   

r    c                 C   s@   t | trd| }n
t | trd}nd}td| |ddgS )z
    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.
    zkTry removing the string '{}'. The list of urlpatterns should not have a prefix string as the first element.z$Try using path() instead of a tuple.NziYour URL pattern {!r} is invalid. Ensure that urlpatterns is a list of path() and/or re_path() instances.z	urls.E004)hintr   )
isinstancestrr#   tupler   )r2   r4   r   r   r   r   L   s   

r   c                 K   s8   g }dD ]}t t|}|r|ds|t| q|S )N)
STATIC_URL	MEDIA_URL/)r   r   endswithr"   E006)r   r   r'   namevaluer   r   r   check_url_settingsg   s   
r?   c                 C   s   t d| ddS )Nz%The {} setting must end with a slash.z	urls.E006r   )r   r#   )r=   r   r   r   r<   q   s   r<   N)r   )collectionsr   django.confr    r   r   r   r   urlsr   r   r)   r    r   r?   r<   r   r   r   r   <module>   s    
	


	