
    'g                    B   d dl mZ d dlZd dlZddlmZ ddlmZ ddlm	Z	 ddlm
Z
 ej                  r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  G d de      Z G d dee      Z G d de      Z G d de      Z G d dee      Z G d de      Z G d de      Zy)    )annotationsN   )
BadRequest)HTTPException)cached_property)redirect)WSGIEnvironment)Request)Response   )
MapAdapter)Rulec                      e Zd ZdZy)RoutingExceptionzxSpecial exceptions that require the application to redirect, notifying
    about missing urls, etc.

    :internal:
    N__name__
__module____qualname____doc__     S/var/www/html/knws/venv/lib/python3.12/site-packages/werkzeug/routing/exceptions.pyr   r      s    r   r   c                  @     e Zd ZdZdZd fdZ	 	 d	 	 	 	 	 ddZ xZS )RequestRedirectzRaise if the map requests a redirect. This is for example the case if
    `strict_slashes` are activated and an url that requires a trailing slash.

    The attribute `new_url` contains the absolute destination url.
    i4  c                2    t         |   |       || _        y N)super__init__new_url)selfr   	__class__s     r   r   zRequestRedirect.__init__%   s    !r   c                B    t        | j                  | j                        S r   )r   r   code)r    environscopes      r   get_responsezRequestRedirect.get_response)   s    
 dii00r   )r   strreturnNone)NN)r$   z WSGIEnvironment | Request | Noner%   zdict[str, t.Any] | Noner(   r   )r   r   r   r   r#   r   r&   __classcell__r!   s   @r   r   r      s=     D 59)-111 '1 
	1r   r   c                  (     e Zd ZdZdZd fdZ xZS )RequestPathzInternal exception.)	path_infoc                0    t         |           || _        y r   )r   r   r.   )r    r.   r!   s     r   r   zRequestPath.__init__6   s    "r   )r.   r'   r(   r)   )r   r   r   r   	__slots__r   r*   r+   s   @r   r-   r-   1   s    I# #r   r-   c                  $     e Zd ZdZd fdZ xZS )RequestAliasRedirectzAThis rule is an alias and wants to redirect to the canonical URL.c                >    t         |           || _        || _        y r   )r   r   matched_valuesendpoint)r    r4   r5   r!   s      r   r   zRequestAliasRedirect.__init__>   s    , r   )r4   t.Mapping[str, t.Any]r5   t.Anyr(   r)   )r   r   r   r   r   r*   r+   s   @r   r2   r2   ;   s    K! !r   r2   c                  \     e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 d fdZedd       Zd	dZd
dZ xZ	S )
BuildErrorz_Raised if the build system cannot find a URL for an endpoint with the
    values provided.
    c                `    t         |   |||       || _        || _        || _        || _        y r   )r   r   r5   valuesmethodadapter)r    r5   r;   r<   r=   r!   s        r   r   zBuildError.__init__I   s2     	662 r   c                8    | j                  | j                        S r   )closest_ruler=   )r    s    r   	suggestedzBuildError.suggestedV   s      ..r   c                     d fd}|r7|j                   j                  r!t        |j                   j                  |      S y )Nc           
        t        dt        j                  d t        | j                        t        j                              j                         z  dt        t        j                  xs d      j                  | j                              z  dt        | j                  xr j                  | j                  v       z  g      S )Ng\(\?g{Gz?r   )sumdifflibSequenceMatcherr'   r5   ratioboolsetr;   issubset	argumentsmethodsr<   )ruler    s    r   _score_rulez,BuildError.closest_rule.<locals>._score_rule[   s    --DMM*DMM*	
 eg 4DKK$52 6 ? ? OPP4 L1LMM
 r   )key)rL   r   r(   float)map_rulesmax)r    r=   rM   s   `  r   r?   zBuildError.closest_ruleZ   s3    	 w{{))w{{)){;;r   c                   d| j                   g}| j                  r|j                  d| j                  d       | j                  r'|j                  dt	        | j                               |j                  d       | j
                  rN| j                   | j
                  j                   k(  r| j                  rj| j
                  j                  T| j                  | j
                  j                  vr2|j                  dt	        | j
                  j                        d       | j
                  j                  j                  t        | j
                  j                  xs d            t        | j                  j                               z
  }|rH|j                  d	t	        |      d       n)|j                  d
| j
                  j                   d       dj                  |      S )Nz!Could not build url for endpoint z ()z with values .z Did you mean to use methods ?r   z" Did you forget to specify values z Did you mean z	 instead? )r5   r<   appendr;   sortedr@   rK   rJ   unionrH   defaultskeysjoin)r    messagemissing_valuess      r   __str__zBuildError.__str__o   s   6t}}6GHI;;NNRa01;;NN]6$+++>*ABCs>>}} 7 77KK..:4>>+A+AANN"4>>#9#9:=Q@ "&!9!9!?!?//526"((*+", "NN<VN=S<VVWX 0G0G/J)TUwwwr   r   )
r5   r7   r;   r6   r<   z
str | Noner=   MapAdapter | Noner(   r)   )r(   Rule | None)r=   ra   r(   rb   )r(   r'   )
r   r   r   r   r   r   r@   r?   r`   r*   r+   s   @r   r9   r9   D   s`     &* & 	
 # 
 / /* r   r9   c                      e Zd ZdZy)WebsocketMismatchzThe only matched rule is either a WebSocket and the request is
    HTTP, or the rule is HTTP and the request is a WebSocket.
    Nr   r   r   r   rd   rd      s    r   rd   c                      e Zd ZdZddZy)NoMatchhave_match_forwebsocket_mismatchc                     || _         || _        y r   rg   )r    rh   ri   s      r   r   zNoMatch.__init__   s    ,"4r   N)rh   zset[str]ri   rG   r(   r)   )r   r   r   r0   r   r   r   r   rf   rf      s    8I5r   rf   )
__future__r   rD   typingt
exceptionsr   r   utilsr   r   TYPE_CHECKING_typeshed.wsgir	   wrappers.requestr
   wrappers.responser   rP   r   rulesr   	Exceptionr   r   r-   r2   LookupErrorr9   rd   rf   r   r   r   <module>rw      s    "   # & # ??.*,y 1m%5 1*#" #!+ !F !; F R
 5i 5r   