a
    Lcòf   ã                   @   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   úT/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/django/core/checks/urls.pyÚcheck_url_config   s
    r   c                 C   s4   t | ddƒ}|dur|ƒ S t| dƒs,t| ƒS g S dS )z)
    Recursively check the resolver.
    ÚcheckNÚresolve)r   ÚhasattrÚget_warning_for_invalid_pattern)r   Z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	�¡ qL|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>,   ó    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   Zall_namespacesÚcounterZnon_unique_namespacesÚerrorsÚ	namespacer   r   r   Úcheck_url_namespaces_unique   s$    ÿýÿr'   r   c                    s^   t | dg ƒ}‡ fdd„|D ƒ}|D ]6}t |ddƒ}ˆ }|durH||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   )r0   r2   r   r   r   r   L   s     
ÿÿ
ÿüÿr   c                 K   s8   g }dD ]*}t t|ƒ}|r| d¡s| t|ƒ¡ q|S )N)Z
STATIC_URLZ	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#   )r9   r   r   r   r8   q   s    þr8   N)r   )Úcollectionsr   Zdjango.confr   Ú r   r   r   r   Úurlsr   r   r'   r    r   r;   r8   r   r   r   r   Ú<module>   s   
	


	