
    +hZ                    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   )
MapAdapter)Rule)Request)Responsec                      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__     N/var/www/html/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 | 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__5   s    "r   )r.   r'   r(   r)   )r   r   r   r   	__slots__r   r*   r+   s   @r   r-   r-   0   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   r'   r(   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__H   s2     	662 r   c                8    | j                  | j                        S r   )closest_ruler<   )r    s    r   	suggestedzBuildError.suggestedU   s      ..r   c                     d fd}|r7|j                   j                  r!t        |j                   j                  |      S y )Nc           
     l   t        dt        j                  d | j                  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SequenceMatcherr5   ratioboolsetr:   issubset	argumentsmethodsr;   )ruler    s    r   _score_rulez,BuildError.closest_rule.<locals>._score_ruleZ   s    --dmmT]]eg 4DKK$52 6 ? ? OPP4 L1LMM	 	r   )key)rK   r   r(   float)map_rulesmax)r    r<   rL   s   `  r   r>   zBuildError.closest_ruleY   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?   rJ   rI   unionrG   defaultskeysjoin)r    messagemissing_valuess      r   __str__zBuildError.__str__k   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   r'   r:   r6   r;   z
str | Noner<   MapAdapter | Noner(   r)   )r(   Rule | None)r<   r`   r(   ra   )r(   r'   )
r   r   r   r   r   r   r?   r>   r_   r*   r+   s   @r   r8   r8   C   s`     &* & 	
 # 
 / /$ r   r8   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   rc   rc      s    r   rc   c                      e Zd ZdZddZy)NoMatchhave_match_forwebsocket_mismatchc                     || _         || _        y r   rf   )r    rg   rh   s      r   r   zNoMatch.__init__   s    ,"4r   N)rg   zset[str]rh   rF   r(   r)   )r   r   r   r0   r   r   r   r   re   re      s    8I5r   re   )
__future__r   rC   typingt
exceptionsr   r   utilsr   r   TYPE_CHECKING_typeshed.wsgir	   rO   r   rulesr   wrappers.requestr   wrappers.responser   	Exceptionr   r   r-   r2   LookupErrorr8   rc   re   r   r   r   <module>rv      s    "   # & # ??.*,y 1m%5 1*#" #!+ !C !; C L
 5i 5r   