a
    -=ic                     @   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	rd 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                   @   s   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   l/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/werkzeug/routing/exceptions.pyr      s   r   c                       sR   e Zd ZdZdZedd fddZdejej	d  eje
 dd	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  N)new_urlreturnc                    s   t  | || _d S N)super__init__r   )selfr   	__class__r   r   r   "   s    zRequestRedirect.__init__)r   r   r   )environ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edd fddZ  ZS )RequestPathzInternal exception.)	path_infoN)r)   r   c                    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                       s6   e Zd ZdZejeejf edd fddZ  Z	S )RequestAliasRedirectzAThis rule is an alias and wants to redirect to the canonical URL.N)matched_valuesendpointr   c                    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eejeejf eje ejd dd fddZ	e
ejd dd	d
Zejd ejd dddZedddZ  ZS )
BuildErrorz_Raised if the build system cannot find a URL for an endpoint with the
    values provided.
    Nr	   )r-   valuesmethodadapterr   c                    s,   t  ||| || _|| _|| _|| _d S r   )r   r   r-   r1   r2   r3   )r   r-   r1   r2   r3   r   r   r   r   F   s
    zBuildError.__init__r
   )r   c                 C   s   |  | jS r   )closest_ruler3   r   r   r   r   	suggestedS   s    zBuildError.suggested)r3   r   c                    s4   dt d fdd}|r0|jjr0t|jj|dS d S )Nr
   )ruler   c                    sT   t dtd | j j  dtt jp(d| j	 dt| j
oJ j| j
v  gS )Ng\(\?g{Gz?r   )sumdifflibSequenceMatcherr-   ratioboolsetr1   issubset	argumentsmethodsr2   )r7   r5   r   r   _score_ruleX   s    
z,BuildError.closest_rule.<locals>._score_rule)key)floatmapZ_rulesmax)r   r3   rA   r   r5   r   r4   W   s    zBuildError.closest_rulec                 C   s   d| j g}| jr(|d| jd | jrD|dt| j |d | jr| j | jj kr| jr| jjd ur| j| jjvr|dt| jjd | jjt	| jj
pdt	| j  }|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? )r-   r2   appendr1   sortedr6   r@   r?   unionr=   defaultskeysjoin)r   messagemissing_valuesr   r   r   __str__i   s<    


zBuildError.__str__)N)r   r   r   r   r"   r#   r.   r/   r$   r   r   r6   r4   rR   r'   r   r   r   r   r0   A   s   	 r0   c                   @   s   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   r   rS      s   rS   c                   @   s(   e Zd ZdZeje eddddZdS )NoMatchhave_match_forwebsocket_mismatchN)rV   rW   r   c                 C   s   || _ || _d S r   rU   )r   rV   rW   r   r   r   r      s    zNoMatch.__init__)	r   r   r   r*   r#   Setr"   r<   r   r   r   r   r   rT      s   rT   )r9   typingr#   
exceptionsr   r   utilsr   r   TYPE_CHECKINGZ_typeshed.wsgir   rD   r	   rulesr
   Zwrappers.requestr   Zwrappers.responser   	Exceptionr   r   r(   r+   LookupErrorr0   rS   rT   r   r   r   r   <module>   s$   
	F