o
    'h                     @  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)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__ r   r   W/var/www/html/olx_land/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[str, t.Any] | 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   6   s   

zRequestPath.__init__)r+   r   r   r   )r   r   r   r   	__slots__r   r)   r   r   r!   r   r*   1   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]endpointt.Anyr   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   r1   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   r1   valuesr/   method
str | NoneadapterMapAdapter | Noner   r   c                   s,   t  ||| || _|| _|| _|| _d S r   )r   r   r0   r3   r4   r6   )r    r0   r3   r4   r6   r!   r   r   r   I   s
   
zBuildError.__init__Rule | Nonec                 C  s   |  | jS r   )closest_ruler6   r    r   r   r   	suggestedV   s   zBuildError.suggestedc                   s.   d fdd}|r|j jrt|j j|dS d S )	Nruler   r   floatc                   s\   t dtd t| jt j  dtt jpd	| j
 dt| jo) j| jv  gS )Ng\(\?g{Gz?r   )sumdifflibSequenceMatcherr   r0   ratioboolsetr3   issubset	argumentsmethodsr4   )r<   r:   r   r   _score_rule[   s   z,BuildError.closest_rule.<locals>._score_rule)key)r<   r   r   r=   )map_rulesmax)r    r6   rG   r   r:   r   r9   Z   s   zBuildError.closest_ruler   c                 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   r4   appendr3   sortedr;   rF   rE   unionrC   defaultskeysjoin)r    messagemissing_valuesr   r   r   __str__o   s:   


zBuildError.__str__r   )
r0   r1   r3   r/   r4   r5   r6   r7   r   r   )r   r8   )r6   r7   r   r8   )r   r   )
r   r   r   r   r   r   r;   r9   rX   r)   r   r   r!   r   r2   D   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   rY      r   rY   c                   @  s   e Zd ZdZddd	Zd
S )NoMatchhave_match_forwebsocket_mismatchr\   set[str]r]   rB   r   r   c                 C  s   || _ || _d S r   r[   )r    r\   r]   r   r   r   r      s   
zNoMatch.__init__N)r\   r^   r]   rB   r   r   )r   r   r   r,   r   r   r   r   r   rZ      s    rZ   )
__future__r   r?   typingt
exceptionsr   r   utilsr   r   TYPE_CHECKING_typeshed.wsgir   wrappers.requestr	   wrappers.responser
   rI   r   rulesr   	Exceptionr   r   r*   r-   LookupErrorr2   rY   rZ   r   r   r   r   <module>   s(    
	I