
    /h                    d   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dS )    )annotationsN   )
BadRequest)HTTPException)cached_property)redirect)WSGIEnvironment)Request)Response   )
MapAdapter)Rulec                      e Zd ZdZdS )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.11/site-packages/werkzeug/routing/exceptions.pyr   r      s           r   r   c                  6     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  new_urlstrreturnNonec                X    t                                          |           || _        d S N)super__init__r   )selfr   	__class__s     r   r"   zRequestRedirect.__init__%   s&    !!!r   Nenviron WSGIEnvironment | Request | Nonescopedict[str, t.Any] | Noner   c                6    t          | j        | j                  S r    )r   r   code)r#   r%   r'   s      r   get_responsezRequestRedirect.get_response)   s    
 di000r   )r   r   r   r   )NN)r%   r&   r'   r(   r   r   )r   r   r   r   r*   r"   r+   __classcell__r$   s   @r   r   r      so          D      59)-1 1 1 1 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_infor0   r   r   r   c                V    t                                                       || _        d S r    )r!   r"   r0   )r#   r0   r$   s     r   r"   zRequestPath.__init__6   s$    "r   )r0   r   r   r   )r   r   r   r   	__slots__r"   r,   r-   s   @r   r/   r/   1   sH        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.matched_valuest.Mapping[str, t.Any]endpointt.Anyr   r   c                d    t                                                       || _        || _        d S r    )r!   r"   r5   r7   )r#   r5   r7   r$   s      r   r"   zRequestAliasRedirect.__init__>   s,    , r   )r5   r6   r7   r8   r   r   )r   r   r   r   r"   r,   r-   s   @r   r4   r4   ;   sC        KK! ! ! ! ! ! ! ! ! !r   r4   c                  P     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.
    Nr7   r8   valuesr6   method
str | NoneadapterMapAdapter | Noner   r   c                    t                                          |||           || _        || _        || _        || _        d S r    )r!   r"   r7   r<   r=   r?   )r#   r7   r<   r=   r?   r$   s        r   r"   zBuildError.__init__I   sA     	66222 r   Rule | Nonec                6    |                      | j                  S r    )closest_ruler?   )r#   s    r   	suggestedzBuildError.suggestedV   s      ...r   c                f     d fd}|r'|j         j        rt          |j         j        |          S d S )Nruler   r   floatc           
        t          dt          j        d t          | j                  t          j                                                            z  dt          t          j        pd          	                    | j
                            z  dt          | j        oj        | j        v           z  g          S )Ng\(\?g{Gz?r   )sumdifflibSequenceMatcherr   r7   ratioboolsetr<   issubset	argumentsmethodsr=   )rG   r#   s    r   _score_rulez,BuildError.closest_rule.<locals>._score_rule[   s    -DM**DM**	 
 egg 4DK$52 6 6 ? ? O OPPP4 L1LMMM
  r   )key)rG   r   r   rH   )map_rulesmax)r#   r?   rS   s   `  r   rD   zBuildError.closest_ruleZ   sT    	 	 	 	 	 	  	<w{) 	<w{){;;;;tr   r   c                T   d| j         g}| j        r|                    d| j        d           | j        r*|                    dt	          | j                             |                    d           | j        r| j         | j        j         k    r| j        rO| j        j        C| j        | j        j        vr0|                    dt	          | j        j                  d           | j        j                            t          | j        j
        pd                    t          | j                                                  z
  }|r&|                    d	t	          |          d           n#|                    d
| j        j         d           d                    |          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? )r7   r=   appendr<   sortedrE   rR   rQ   unionrO   defaultskeysjoin)r#   messagemissing_valuess      r   __str__zBuildError.__str__o   s   Ht}HHI; 	2NN0000111; 	DNNB6$++>+>BBCCCs> 	V} 777K.:4>+AAANN@"4>#9::@ @ @   "&!9!?!?/5266" "((**++", " NNXVN=S=SXXX   T0GTTTUUUwwwr   r    )
r7   r8   r<   r6   r=   r>   r?   r@   r   r   )r   rB   )r?   r@   r   rB   )r   r   )
r   r   r   r   r"   r   rE   rD   re   r,   r-   s   @r   r;   r;   D   s          &*       / / / _/   *               r   r;   c                      e Zd ZdZdS )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   rg   rg      s           r   rg   c                      e Zd ZdZd
dZd	S )NoMatchhave_match_forwebsocket_mismatchrk   set[str]rl   rN   r   r   c                "    || _         || _        d S r    rj   )r#   rk   rl   s      r   r"   zNoMatch.__init__   s    ,"4r   N)rk   rm   rl   rN   r   r   )r   r   r   r2   r"   r   r   r   ri   ri      s-        8I5 5 5 5 5 5r   ri   )
__future__r   rK   typingt
exceptionsr   r   utilsr   r   TYPE_CHECKING_typeshed.wsgir	   wrappers.requestr
   wrappers.responser   rU   r   rulesr   	Exceptionr   r   r/   r4   LookupErrorr;   rg   ri   r   r   r   <module>r{      s   " " " " " "      # # # # # # & & & & & & # # # # # #      ? ......******,,,,,,    y   1 1 1 1 1m%5 1 1 1*# # # # #" # # #! ! ! ! !+ ! ! !F  F  F  F  F !; F  F  F R    
   5 5 5 5 5i 5 5 5 5 5r   