o
    d                     @   s   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	rAd 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 deZG dd deeZG dd deZG dd deZG dd deeZG dd deZG dd deZdS )    N   )
BadRequest)HTTPException)cached_property)redirect)WSGIEnvironment   )
MapAdapter)Rule)Request)Responsec                   @      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__ r   r   `/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/werkzeug/routing/exceptions.pyr          r   c                       s\   e Zd ZdZdZdeddf fddZ		ddejej	d	  d
eje
 ddfddZ  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returnNc                    s   t  | || _d S N)super__init__r   )selfr   	__class__r   r   r   "   s   
zRequestRedirect.__init__environ)r   r   scoper   c                 C   s   t | j| jS r   )r   r   code)r   r    r!   r   r   r   get_response&   s   zRequestRedirect.get_response)NN)r   r   r   r   r"   strr   tOptionalUniondictr#   __classcell__r   r   r   r   r      s    r   c                       s.   e Zd ZdZdZdeddf fddZ  ZS )RequestPathzInternal exception.)	path_infor+   r   Nc                    s   t    || _d S r   )r   r   r+   )r   r+   r   r   r   r   3   s   

zRequestPath.__init__)r   r   r   r   	__slots__r$   r   r)   r   r   r   r   r*   .   s    r*   c                       s:   e Zd ZdZdejeejf deddf fddZ  Z	S )RequestAliasRedirectzAThis rule is an alias and wants to redirect to the canonical URL.matched_valuesendpointr   Nc                    s   t    || _|| _d S r   )r   r   r.   r/   )r   r.   r/   r   r   r   r   ;   s   

zRequestAliasRedirect.__init__)
r   r   r   r   r%   Mappingr$   Anyr   r)   r   r   r   r   r-   8   s    .r-   c                       s   e Zd ZdZ	ddedejeejf deje dejd ddf
 fd	d
Z	e
dejd fddZdejd dejd fddZdefddZ  ZS )
BuildErrorz_Raised if the build system cannot find a URL for an endpoint with the
    values provided.
    Nr/   valuesmethodadapterr	   r   c                    s,   t  ||| || _|| _|| _|| _d S r   )r   r   r/   r3   r4   r5   )r   r/   r3   r4   r5   r   r   r   r   F   s
   
zBuildError.__init__r
   c                 C   s   |  | jS r   )closest_ruler5   r   r   r   r   	suggestedS   s   zBuildError.suggestedc                    s6   dddt f fdd}|r|jjrt|jj|dS d S )Nruler
   r   c                    sT   t dtd | j j  dtt jpd| j	 dt| j
o% j| j
v  gS )Ng\(\?g{Gz?r   )sumdifflibSequenceMatcherr/   ratioboolsetr3   issubset	argumentsmethodsr4   )r9   r7   r   r   _score_ruleX   s   
z,BuildError.closest_rule.<locals>._score_rule)key)floatmap_rulesmax)r   r5   rC   r   r7   r   r6   W   s   zBuildError.closest_rulec                 C   s   d| j g}| jr|d| jd | jr"|dt| j |d | jr{| j | jj krp| jrN| jjd urN| j| jjvrN|dt| jjd | jjt	| jj
pXdt	| j  }|ro|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? )r/   r4   appendr3   sortedr8   rB   rA   unionr?   defaultskeysjoin)r   messagemissing_valuesr   r   r   __str__i   s>   



zBuildError.__str__r   )r   r   r   r   r$   r%   r0   r1   r&   r   r   r8   r6   rU   r)   r   r   r   r   r2   A   s$    	r2   c                   @   r   )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   r   rV      r   rV   c                   @   s,   e Zd ZdZdeje deddfddZdS )NoMatchhave_match_forwebsocket_mismatchrY   rZ   r   Nc                 C   s   || _ || _d S r   rX   )r   rY   rZ   r   r   r   r      s   
zNoMatch.__init__)	r   r   r   r,   r%   Setr$   r>   r   r   r   r   r   rW      s     rW   )r;   typingr%   
exceptionsr   r   utilsr   r   TYPE_CHECKING_typeshed.wsgir   rF   r	   rulesr
   wrappers.requestr   wrappers.responser   	Exceptionr   r   r*   r-   LookupErrorr2   rV   rW   r   r   r   r   <module>   s&    
	F