
    Ui*                     &   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 ee
j                        d        Zy)    )Counter)settings)ViewDoesNotExist)	signature   )ErrorTagsWarningregisterc                 X    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   resolvers       J/var/www/opsc/venv/lib/python3.12/site-packages/django/core/checks/urls.pycheck_url_configr   
   s(    x.,>h''I    c                 `    t        | dd      }| |       S t        | d      st        |       S g S )z)
    Recursively check the resolver.
    checkNresolve)r   hasattrget_warning_for_invalid_pattern)r   check_methods     r   r   r      s:     8Wd3L~Xy).x88	r   c                 6   t        t        dd      sg S ddlm}  |       }t	        |      }t        |      }|j                         D cg c]  \  }}|dkD  s| }}}g }	|D ]-  }
|	j                  t        dj                  |
      d             / |	S c c}}w )	zD
    Warn if URL namespaces used in applications aren't unique.
    r   Nr   r   r   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ncountnon_unique_namespaceserrors	namespaces              r   check_url_namespaces_uniquer-   !   s    
 8^T2	(~H)(3Nn%G/6}}L81e%!)QLLF* 
	--3VI->	

 M Ms   
BBc                    t        | dg       }|D cg c].  }t        |dd      dj                  g ||j                        0 }}|D ]4  }t        |dd      }|}|||fz  }|j                  t	        ||             6 |S c c}w )z<
    Recursively load all namespaces from URL patterns.
    url_patternsr,   N:)r   joinr,   extendr"   )r   parentsr/   url
namespacespatternr,   currents           r   r"   r"   ;   s     8^R8L  3T*6 	*7*CMM*+J 
   BG[$7	 	|#G.w@AB s   3Bc                     t        | t              rdj                  |       }nt        | t              rd}nd}t	        dj                  |       |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   )r6   r:   s     r   r   r   N   s_     '399? 	 
GU	#5 	44:F7O		
 r   c                     g }dD ]A  }t        t        |      }|s|j                  d      r(|j                  t	        |             C |S )N)
STATIC_URL	MEDIA_URL/)r   r   endswithr$   E006)r   r   r+   namevalues        r   check_url_settingsrF   i   sG    F+ &$',MM$t*%& Mr   c                 :    t        dj                  |       d      S )Nz%The {} setting must end with a slash.z	urls.E006r    )r   r%   )rD   s    r   rC   rC   s   s     /66t< r   c           
      ^   t        t        dd       sg S ddlm}  |       }g }dD ]6  \  }}	 |j	                  |      }d g|z  }	  t        |      j                  |  8 |S # t
        t        f$ r\}t        |j                  d|z        }	dj                  ||	      }
|j                  t        |
t        |      d	             Y d }~d }~ww xY w# t        $ rU d
j                  ||j                  dz   |j                   z   |dk(  rdnd      }
|j                  t        |
d             Y w xY w)Nr   r   r   ))i     )i  rI   )i  rI   )i  r   z	handler%szDThe custom handler{status_code} view '{path}' could not be imported.)status_codepathz	urls.E008r9   zeThe custom handler{status_code} view '{path}' does not take the correct number of arguments ({args})..rI   zrequest, exceptionrequest)rJ   rK   argsz	urls.E007r    )r   r   r   r   resolve_error_handlerImportErrorr   urlconf_moduler%   r$   r   r<   r   bind	TypeError
__module____qualname__)r   r   r   r   r+   rJ   num_parametershandlererK   msgrN   s               r   check_custom_error_handlersrZ   z   sJ   8^T2	(~HF (P 6#^		44[AG v&	6#Ig##T*60 M+ -. 	822K+4MNDf4f8  MM%#a&[AB	  		6Af'''#-0D0DD-;q-@)i    MM%45		6s+   A C C/ACCAD,+D,N) )collectionsr   django.confr   django.core.exceptionsr   django.utils.inspectr    r   r	   r
   r   urlsr   r   r-   r"   r   rF   rC   rZ   r[   r   r   <module>rb      s       3 * , , 
$)) 
 
$)) 2&6 
$))  
$))# #r   