o
    q>eZ                     @  s  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rGd 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 )    )annotationsN   )
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/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/werkzeug/routing/exceptions.pyr          r   c                      s6   e Zd ZdZdZd fddZ				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  new_urlstrreturnNonec                   s   t  | || _d S N)super__init__r   )selfr   	__class__r   r   r   $   s   
zRequestRedirect.__init__Nenviron WSGIEnvironment | Request | Nonescopedict | Noner   c                 C  s   t | j| jS r   )r   r   code)r    r#   r%   r   r   r   get_response(   s   zRequestRedirect.get_response)r   r   r   r   )NN)r#   r$   r%   r&   r   r   )r   r   r   r   r'   r   r(   __classcell__r   r   r!   r   r      s    r   c                      s&   e Zd ZdZdZd	 fddZ  ZS )
RequestPathzInternal exception.)	path_infor+   r   r   r   c                   s   t    || _d S r   )r   r   r+   )r    r+   r!   r   r   r   5   s   

zRequestPath.__init__)r+   r   r   r   )r   r   r   r   	__slots__r   r)   r   r   r!   r   r*   0   s    r*   c                      s"   e Zd ZdZd
 fdd	Z  ZS )RequestAliasRedirectzAThis rule is an alias and wants to redirect to the canonical URL.matched_valuest.Mapping[str, t.Any]endpointr   r   r   c                   s   t    || _|| _d S r   )r   r   r.   r0   )r    r.   r0   r!   r   r   r   =   s   

zRequestAliasRedirect.__init__)r.   r/   r0   r   r   r   )r   r   r   r   r   r)   r   r   r!   r   r-   :   s    r-   c                      sH   e Zd ZdZ	dd fddZedddZdddZdddZ  Z	S )
BuildErrorz_Raised if the build system cannot find a URL for an endpoint with the
    values provided.
    Nr0   r   valuesr/   method
str | NoneadapterMapAdapter | Noner   r   c                   s,   t  ||| || _|| _|| _|| _d S r   )r   r   r0   r2   r3   r5   )r    r0   r2   r3   r5   r!   r   r   r   H   s
   
zBuildError.__init__Rule | Nonec                 C  s   |  | jS r   )closest_ruler5   r    r   r   r   	suggestedU   s   zBuildError.suggestedc                   s.   d fdd}|r|j jrt|j j|dS d S )	Nruler   r   floatc                   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SequenceMatcherr0   ratioboolsetr2   issubset	argumentsmethodsr3   )r;   r9   r   r   _score_ruleZ   s   
z,BuildError.closest_rule.<locals>._score_rule)key)r;   r   r   r<   )map_rulesmax)r    r5   rF   r   r9   r   r8   Y   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? )r0   r3   appendr2   sortedr:   rE   rD   unionrB   defaultskeysjoin)r    messagemissing_valuesr   r   r   __str__k   s:   


zBuildError.__str__r   )
r0   r   r2   r/   r3   r4   r5   r6   r   r   )r   r7   )r5   r6   r   r7   )r   r   )
r   r   r   r   r   r   r:   r8   rW   r)   r   r   r!   r   r1   C   s    	
r1   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   rX      r   rX   c                   @  s   e Zd ZdZddd	Zd
S )NoMatchhave_match_forwebsocket_mismatchr[   set[str]r\   rA   r   r   c                 C  s   || _ || _d S r   rZ   )r    r[   r\   r   r   r   r      s   
zNoMatch.__init__N)r[   r]   r\   rA   r   r   )r   r   r   r,   r   r   r   r   r   rY      s    rY   )
__future__r   r>   typingt
exceptionsr   r   utilsr   r   TYPE_CHECKING_typeshed.wsgir   rH   r
   rulesr   wrappers.requestr   wrappers.responser   	Exceptionr   r   r*   r-   LookupErrorr1   rX   rY   r   r   r   r   <module>   s(    
	F