
    fi                        d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	 d dl
mZmZmZmZ d dlmZ d dlmZ d dlmZ er6d 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 d dlmZmZmZ d dl m!Z!m"Z" 	 d dlm#Z#m$Z$m%Z%m&Z'm(Z) n# e*$ r  ed          w xY wdZ+ G d de          Z, G d de          Z-d Z.d Z/d Z0dS )    N)SOURCE_FOR_STYLE)capture_internal_exceptionsensure_integration_enabledevent_from_exceptionparse_versiontransaction_from_function)IntegrationDidNotEnable$_DEFAULT_FAILED_REQUEST_STATUS_CODES_check_minimum_version)SentryWsgiMiddleware)RequestExtractor)TYPE_CHECKING)Set)_ScopedResponse)Any)Dict)Callable)Optional)
FileUpload	FormsDictLocalRequest)EventProcessorEvent)BottleHTTPResponseRouterequest__version__zBottle not installed)endpointurlc                   F    e Zd ZdZde ZdZ	 d	eddZed             Z	dS )
BottleIntegrationbottlez
auto.http. r    )failed_request_status_codesc                j    |t           vrt          d|dt           d          || _        || _        d S )Nz%Invalid value for transaction_style: z (must be in ))TRANSACTION_STYLE_VALUES
ValueErrortransaction_styler&   )selfr+   r&   s      n/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/sentry_sdk/integrations/bottle.py__init__zBottleIntegration.__init__8   sT     $<<<*$$$&>&>&>@   "3+F(((    c                     t          t                    } t          t          |            t          j        t          t                    fd            }|t          _        t          j        t          j	                  fd            }|t          _        t          j        t          j	                  fd            }|t          _        d S )Nc                 \     t           fdt          j                  } |||          S )Nc                       g| R i |S N )akwold_appr,   s     r-   <lambda>zOBottleIntegration.setup_once.<locals>.sentry_patched_wsgi_app.<locals>.<lambda>T   s!    !8!8!8!8R!8!8 r/   )span_origin)r   r#   origin)r,   environstart_response
middlewarer7   s   `   r-   sentry_patched_wsgi_appz=BottleIntegration.setup_once.<locals>.sentry_patched_wsgi_appP   sC     .88888-4  J
 :g~666r/   c                    t          j                                        t                    }| | |          S t          j                    }d|_        |                    t          | t          |                      | |          }|S )Nr$   )	
sentry_sdk
get_clientget_integrationr#   get_isolation_scope_nameadd_event_processor_make_request_event_processorbottle_request)r,   r;   integrationscoperes
old_handles        r-   _patched_handlez5BottleIntegration.setup_once.<locals>._patched_handle^   s     %/11AABSTTK"!z$000244E"EK%%-dNKPP   *T7++CJr/   c                      | g|R i |t          j                                        t                    S fd}|S )Nc                      	  | i |}n%# t           $ r}t          |d           |d }~ww xY wt          |t                    r|j        j        v rt          |d           |S )NF)handledT)	Exception_capture_exception
isinstancer   status_coder&   )argskwargsrJ   	exceptionrH   prepared_callbacks       r-   wrapped_callbackzUBottleIntegration.setup_once.<locals>.patched_make_callback.<locals>.wrapped_callback{   s    $++T<V<<CC  $ $ $&y%@@@@#O$
 sL11:;+RRR&sD9999
s    
.).)r@   rA   rB   r#   )r,   rT   rU   rX   rH   rW   old_make_callbacks       @@r-   patched_make_callbackz;BottleIntegration.setup_once.<locals>.patched_make_callbackr   sw     !2 1$ H H H H H H$/11AABSTTK"((       $#r/   )r   BOTTLE_VERSIONr   r#   r   __call__r   _handle	functoolswrapsr   _make_callback)versionr>   rL   rZ   r7   rK   rY   s       @@@r-   
setup_oncezBottleIntegration.setup_onceH   s      //0':::/	#$5w	?	?	7 	7 	7 	7 
@	?	7 2^
		$	$	 	 	 	 
%	$	 )!0	*	+	+	$ 	$ 	$ 	$ 
,	+	$4  5r/   N)r    )
__name__
__module____qualname__
identifierr:   r+   r   r.   staticmethodrb   r4   r/   r-   r#   r#   2   s{        J&*&&F %G %I	G G G G G  D5 D5 \D5 D5 D5r/   r#   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )BottleRequestExtractorc                     | j         j        S r3   )r   r;   r,   s    r-   envzBottleRequestExtractor.env       |##r/   c                     | j         j        S r3   )r   cookiesrk   s    r-   ro   zBottleRequestExtractor.cookies   rm   r/   c                 >    | j         j                                        S r3   )r   bodyreadrk   s    r-   raw_datazBottleRequestExtractor.raw_data   s    | %%'''r/   c                 j    |                                  rd S | j        j                                        S r3   )is_jsonr   formsdecoderk   s    r-   formzBottleRequestExtractor.form   s.    <<>> 	4|!((***r/   c                 F    |                                  rd S | j        j        S r3   )ru   r   filesrk   s    r-   rz   zBottleRequestExtractor.files   s"    <<>> 	4|!!r/   c                     |j         S r3   )content_length)r,   files     r-   size_of_filez#BottleRequestExtractor.size_of_file   s    ""r/   N)	rc   rd   re   rl   ro   rs   rx   rz   r~   r4   r/   r-   ri   ri      sn        $ $ $$ $ $( ( (+ + +" " "# # # # #r/   ri   c                    d}|dk    r 	 |j         j        pd}nO# t          $ r Y nCw xY w|dk    r9	 |j         j        pt	          |j         j                  pd}n# t          $ r Y nw xY w|| d<   dt          |         i| d<   d S )Nr%   r!   r    transactionsourcetransaction_info)routeruleRuntimeErrornamer   callbackr   )eventr+   r   r   s       r-    _set_transaction_name_and_sourcer      s    DE!!	=%+DD 	 	 	D	 
j	(	(	" ,W]-CDD D
  	 	 	D	  E-!)+;<M+N OE
s    
&&'A 
A%$A%c                     fd}|S )Nc                     t          | j                   t                      5  t                                        |            d d d            n# 1 swxY w Y   | S r3   )r   r+   r   ri   extract_into_event)r   hintrH   r   s     r-   event_processorz6_make_request_event_processor.<locals>.event_processor   s    (0MwWWW(** 	F 	F"7++>>uEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F s   #AAAr4   )appr   rH   r   s    `` r-   rF   rF      s*          r/   c                     t          | t          j                    j        d|d          \  }}t          j        ||           d S )Nr$   )typerO   )client_options	mechanism)r   )r   r@   rA   optionscapture_event)rV   rO   r   r   s       r-   rQ   rQ      sU    &!,..6#88  KE4
 U......r/   )1r^   r@   sentry_sdk.tracingr   sentry_sdk.utilsr   r   r   r   r   sentry_sdk.integrationsr	   r
   r   r   sentry_sdk.integrations.wsgir   $sentry_sdk.integrations._wsgi_commonr   typingr   collections.abcr   r   r   r   r   r   r$   r   r   r   sentry_sdk._typesr   r   r   r   r   r   rG   r   r[   ImportErrorr)   r#   ri   r   rF   rQ   r4   r/   r-   <module>r      s           / / / / / /                         > = = = = = A A A A A A             
8######<<<<<<::::::::::77777777	/                / / /
,-
.
../ / [5 [5 [5 [5 [5 [5 [5 [5|# # # # #- # # #>P P P0  / / / / /s   4B B