U
    ÌZj�  ã                   @   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	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„ 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   ú^/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/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 )ÚRequestRedirectzÜRaise 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
kƒ gƒS )Ng\�Âõ(\ï?g{®Gáz„?r   )ÚsumÚdifflibZ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   r@   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 k	rœ| j| jjkrœ| dt| jjƒ›d�¡ | jj t	| jj
p°dƒ¡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   ÚmessageZmissing_valuesr   r   r   Ú__str__i   s8    
ÿ
þýÿÿþÿzBuildError.__str__)N)r   r   r   r   r"   r#   r.   r/   r$   r   r   r6   r4   rP   r'   r   r   r   r   r0   A   s   	 ûúr0   c                   @   s   e Zd ZdZdS )ÚWebsocketMismatchz�The 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   rQ   ‡   s   rQ   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)rT   rU   r   c                 C   s   || _ || _d S r   rS   )r   rT   rU   r   r   r   r   �   s    zNoMatch.__init__)	r   r   r   r*   r#   ÚSetr"   r;   r   r   r   r   r   rR   �   s   rR   )r9   Útypingr#   Ú
exceptionsr   r   Úutilsr   r   ÚTYPE_CHECKINGZ_typeshed.wsgir   rC   r	   Úrulesr
   Zwrappers.requestr   Zwrappers.responser   Ú	Exceptionr   r   r(   r+   ÚLookupErrorr0   rQ   rR   r   r   r   r   Ú<module>   s$   
	F