
    wdfK                         d 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 ddl	m
Z
 dd	lmZ  G d
 dee          Ze G d dee                      Z G d de          Zd Zd Zd Zd ZdS )z
    flask.debughelpers
    ~~~~~~~~~~~~~~~~~~

    Various helpers to make the development experience better.

    :copyright: 2010 Pallets
    :license: BSD-3-Clause
    N)warn   )implements_to_string)	text_type)Flask)	Blueprint)_request_ctx_stackc                       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__     W/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/flask/debughelpers.pyr   r      s           r   r   c                       e Zd ZdZd Z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                     |j                             |          }d|d|j        dg}|r5|                    dd                    d |D                       z             d                    |          | _        d S )NzYou tried to access the file "z[" 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.zI

The browser instead transmitted some file names. This was submitted: %sz, c              3       K   | ]	}d |z  V  
dS )z"%s"Nr   .0xs     r   	<genexpr>z.DebugFilesKeyError.__init__.<locals>.<genexpr>.   s&      4V4VAVaZ4V4V4V4V4V4Vr    )formgetlistmimetypeappendjoinmsg)selfrequestkeyform_matchesbufs        r   __init__zDebugFilesKeyError.__init__!   s    |++C00 ssG$$$&
  	JJ)+/994V4V4V4V4V+V+VW   773<<r   c                     | j         S N)r!   )r"   s    r   __str__zDebugFilesKeyError.__str__2   s	    xr   N)r   r   r   r   r'   r*   r   r   r   r   r      s<              "    r   r   c                       e Zd ZdZd ZdS )FormDataRoutingRedirectzThis exception is raised by Flask in debug mode if it detects a
    redirect caused by the routing system when the request method is not
    GET, HEAD or OPTIONS.  Reasoning: form data will be dropped.
    c                    |j         }d|j        d|j        dg}|j        dz   |j                            d          d         k    r|                    d           |                    d|j        z             |                    d	           t                              | d
	                    |          
                    d                     d S )Nz A request was sent to this URL (zD) but a redirect was issued automatically by the routing system to "z"./?r   z  The URL was defined with a trailing slash so Flask will automatically redirect to the URL with the trailing slash if it was accessed without one.z  Make sure to directly send your %s-request to this URL since we can't make browsers or HTTP clients redirect with form data reliably or without user interaction.z3

Note: this exception is only raised in debug moder   zutf-8)routing_exceptionurlnew_urlbase_urlsplitr   methodAssertionErrorr'   r    encode)r"   r#   excr&   s       r   r'   z FormDataRoutingRedirect.__init__<   s    ' {{{CKKK)
 c!S[%6%6s%;%;A%>>>JJ   	

CEL^T	
 	
 	

 	

JKKKbggcll&9&9'&B&BCCCCCr   N)r   r   r   r   r'   r   r   r   r,   r,   6   s2         
D D D D Dr   r,   c                       j         j         G  fdd          }j        |_        j        |_        | j         _        dS )zSince Flask 0.8 we're monkeypatching the files object in case a
    request is detected that does not use multipart form data but the files
    object is accessed.
    c                       e Zd Z fdZdS ).attach_enctype_error_multidict.<locals>.newclsc                     	                      | |          S # t          $ r |j        vr t          |          w xY wr)   )__getitem__KeyErrorr   r   )r"   r$   oldclsr#   s     r   r=   z:attach_enctype_error_multidict.<locals>.newcls.__getitem__^   sY    7))$444 7 7 7gl**(#6667s    %>N)r   r   r   r=   )r?   r#   s   r   newclsr;   ]   s3        	7 	7 	7 	7 	7 	7 	7 	7r   r@   N)files	__class__r   r   )r#   r@   r?   s   ` @r   attach_enctype_error_multidictrC   V   so    
 ]$F7 7 7 7 7 7 7 7 7 7 7 oFO)F$GMr   c           	   #     K   dt          |           j        dt          |           j        V  t          | j                                                  D ]\  }}|                    d          rt          |t          t          f          r.t          d |D                       sQd|z  V  |D ]	}d|z  V  
et          |t          t          t          t          t          f          s|d|V  d S )Nzclass: ._c              3   N   K   | ] }t          |t          t          f          V  !d S r)   )
isinstancestrr   r   s     r   r   z$_dump_loader_info.<locals>.<genexpr>q   s1      FF1z!c9%566FFFFFFr   z%s:z  - %sz: )typer   r   sorted__dict__items
startswithrH   tuplelistallrI   r   intfloatbool)loaderr$   valueitems       r   _dump_loader_inforX   k   s%       LL333T&\\5J5J
KKKKV_224455 & &
U>># 	eeT]++ 	FFFFFFF #+ & &o%%%%ECC#EFF 	##uu%%%%%& &r   c                    d|z  g}d}d}t           j        }||j        j        |j        j        }t	          |          D ]\  }\  }}	}
t          |	t                    rd|	j        z  }n8t          |	t                    rd|	j	        d|	j        d}nt          |	          }|                    d|d	z   |fz             t          |          D ]}|                    d
|z             |
d}nd|
d	         pdz  }|d	z  }|                    d|z             d}|dk    r|                    d           d}n|d	k    r|                    d           d}|D|rB|                    d|z             |                    d           |                    d           | j                            d                    |                     dS )z2This should help developers understand what failedzLocating template "%s":r   Nzapplication "%s"zblueprint "z" ()z% 5d: trying loader of %sr   z	       %szno matchz
found (%r)z<string>z       -> %sFz'Error: the template could not be found.Tz<Warning: multiple loaders returned a match for the template.zQ  The template was looked up from an endpoint that belongs to the blueprint "%s".z9  Maybe you did not place a template in the right folder?z7  See http://flask.pocoo.org/docs/blueprints/#templates
)r	   topr#   	blueprint	enumeraterH   r   import_namer   namereprr   rX   loggerinfor    )apptemplateattemptsrc   total_foundr]   reqctxidxrU   srcobjtriplesrc_infolinedetailseems_fishys                  r   !explain_template_loading_attemptsrp   |   s   %01DKI#Ffn6BN,	)28)<)< - -%%ffffe$$ 	$)F,>>HH	** 	$ 	$06V=O=O=OPHHF||H/37H2EEFFF%f-- 	, 	,DKKd*++++>FF!VAY%<*=F1KNV+,,,,Ka=>>>	qRSSS-/89	
 	
 	
 	OPPPMNNNJOODIIdOO$$$$$r   c                      t           j                            d          dk    r t          t	          d          d           d S d S )NWERKZEUG_RUN_MAINtruezSilently ignoring app.run() because the application is run from the flask command line executable.  Consider putting app.run() behind an if __name__ == "__main__" guard to silence this warning.   )
stacklevel)osenvirongetr   Warningr   r   r   explain_ignored_app_runrz      s\    	z~~)**f44  		
 		
 		
 		
 		
 		
 54r   )r   rv   warningsr   _compatr   r   rd   r   
blueprintsr   globalsr	   r6   UnicodeErrorr   r>   r   r,   rC   rX   rp   rz   r   r   r   <module>r      se    
			       ) ) ) ) ) )             ! ! ! ! ! ! ' ' ' ' ' '    ^\        >   4D D D D Dn D D D@% % %*& & &"-% -% -%`
 
 
 
 
r   