o
    q>e                     @  s   d dl mZ d dlZddlmZ ddlmZ ddlm	Z	 G dd de
eZG d	d
 d
ee
ZG dd de
Zdd ZdddZdddZdS )    )annotationsN   )	Blueprint)request_ctx)Appc                   @  s   e Zd ZdZdS )UnexpectedUnicodeErrorzjRaised in places where we want some better error reporting for
    unexpected unicode or binary data.
    N)__name__
__module____qualname____doc__ r   r   S/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/flask/debughelpers.pyr   
   s    r   c                   @  s    e Zd ZdZdd Zdd ZdS )DebugFilesKeyErrorzRaised from request.files during debugging.  The idea is that it can
    provide a better error message than just a generic KeyError/BadRequest.
    c                 C  sZ   |j |}d|d|jdg}|r%ddd |D }|d|  d|| _d S )	NzYou tried to access the file zX in the request.files dictionary but it does not exist. The mimetype for the request is z instead of 'multipart/form-data' which means that no file contents were transmitted. To fix this error you should provide enctype="multipart/form-data" in your form.z, c                 s  s    | ]}t |V  qd S N)repr.0xr   r   r   	<genexpr>    s    z.DebugFilesKeyError.__init__.<locals>.<genexpr>zG

The browser instead transmitted some file names. This was submitted:  )formgetlistmimetypejoinappendmsg)selfrequestkeyform_matchesbufnamesr   r   r   __init__   s   zDebugFilesKeyError.__init__c                 C  s   | j S r   )r   )r   r   r   r   __str__'   s   zDebugFilesKeyError.__str__N)r   r	   r
   r   r"   r#   r   r   r   r   r      s    r   c                      s    e Zd ZdZ fddZ  ZS )FormDataRoutingRedirectzThis exception is raised in debug mode if a routing redirect
    would cause the browser to drop the method or body. This happens
    when method is not GET, HEAD or OPTIONS and the status code is not
    307 or 308.
    c                   sd   |j }d|j d|j dg}|j d|jdd kr"|d |d t d	| d S )
NzA request was sent to 'z7', but routing issued a redirect to the canonical URL 'z'./?r   z The URL was defined with a trailing slash. Flask will redirect to the URL with a trailing slash if it was accessed without one.z Send requests to the canonical URL, or use 307 or 308 for routing redirects. Otherwise, browsers will drop form data.

This exception is only raised in debug mode.r   )	routing_exceptionurlnew_urlbase_url	partitionr   superr"   r   )r   r   excr    	__class__r   r   r"   2   s   
z FormDataRoutingRedirect.__init__)r   r	   r
   r   r"   __classcell__r   r   r.   r   r$   +   s    r$   c                   s8    j j}G  fddd|}|j|_|j|_| j _dS )zPatch ``request.files.__getitem__`` to raise a descriptive error
    about ``enctype=multipart/form-data``.

    :param request: The request to patch.
    :meta private:
    c                      s   e Zd Z fddZ  ZS )z.attach_enctype_error_multidict.<locals>.newclsc              
     sH   zt  |W S  ty# } z|jvr t||jd d }~ww r   )r,   __getitem__KeyErrorr   r   with_traceback__traceback__)r   r   e)r/   r   r   r   r1   S   s   

z:attach_enctype_error_multidict.<locals>.newcls.__getitem__)r   r	   r
   r1   r0   r   r   r.   r   newclsR   s    r7   N)filesr/   r   r	   )r   oldclsr7   r   r6   r   attach_enctype_error_multidictI   s
   r:   returnt.Generatorc                 c  s    dt | j dt | j V  t| j D ]?\}}|dr!qt|tt	frDt
dd |D s2q| dV  |D ]}d| V  q:qt|ttttfsNq| d|V  qd S )	Nzclass: ._c                 s  s    | ]}t |tV  qd S r   )
isinstancestrr   r   r   r   r   i   s    z$_dump_loader_info.<locals>.<genexpr>:z  - z: )typer	   r   sorted__dict__items
startswithr?   tuplelistallr@   intfloatbool)loaderr   valueitemr   r   r   _dump_loader_infoc   s    
rP   appr   Nonec                 C  st  d|dg}d}d}t rt jjdurt jj}t|D ]a\}\}}}	t|tr.d|j}
nt|tr?d|jd|j d}
nt	|}
|
|d	 d
d|
  t|D ]
}|
d|  qT|	du rfd}nd|	d	 pldd}|d	7 }|
d|  qd}|dkr|
d d}n|d	kr|
d d}|dur|r|
d|d |
d |
d | jd| dS )z2This should help developers understand what failedzLocating template rA   r   Nzapplication z
blueprint z ()r   5z: trying loader of z       zno matchzfound (z<string>z
       -> Fz'Error: the template could not be found.Tz<Warning: multiple loaders returned a match for the template.zL  The template was looked up from an endpoint that belongs to the blueprint r=   z9  Maybe you did not place a template in the right folder?z=  See https://flask.palletsprojects.com/blueprints/#templates
)r   r   	blueprint	enumerater?   r   import_namer   namer   r   rP   loggerinfor   )rQ   templateattemptsr[   total_foundrV   idxrM   srcobjtriplesrc_infolinedetailseems_fishyr   r   r   !explain_template_loading_attemptst   sF   





rf   )r;   r<   )rQ   r   r;   rR   )
__future__r   typingt
blueprintsr   globalsr   
sansio.appr   AssertionErrorUnicodeErrorr   r2   r   r$   r:   rP   rf   r   r   r   r   <module>   s    
