
    lh                     j   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) dZ+ G d de      Z, G d de      Z-d Z.d Z/d Z0y# e*$ r	  ed      w xY w)    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                   >    e Zd ZdZde ZdZ	 deddZed        Z	y)	BottleIntegrationbottlez
auto.http. )failed_request_status_codesc                \    |t         vrt        d|dt         d      || _        || _        y )Nz%Invalid value for transaction_style: z (must be in ))TRANSACTION_STYLE_VALUES
ValueErrortransaction_styler&   )selfr+   r&   s      p/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/sentry_sdk/integrations/bottle.py__init__zBottleIntegration.__init__8   s8     $<<$&>@  "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        _        y )Nc                 V     t         fdt        j                        } |||      S )Nc                       g| i |S N )akwold_appr,   s     r-   <lambda>zOBottleIntegration.setup_once.<locals>.sentry_patched_wsgi_app.<locals>.<lambda>T   s    !8!8R!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   s*     .8-44J
 g~66r/   c                     t        j                         j                  t              }|	 | |      S t        j                         }d|_        |j                  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^   st     %//1AABSTK"!$00224E"EK%%-dNKP T7+CJr/   c                      | g|i |t        j                         j                  t              S fd}|S )Nc                      	  | i |}t        |t              r%|j                  j
                  v rt        |d       |S # t         $ r}t        |d       |d }~ww xY w)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{   se    $+T<V<C sL1;+R+RR&sD9
 ! $&y%@#O$s   A 	AAA)r@   rA   rB   r#   )r,   rT   rU   rX   rH   rW   old_make_callbacks       @@r-   patched_make_callbackz;BottleIntegration.setup_once.<locals>.patched_make_callbackr   sM     !2$ H H H$//1AABS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 2^^
		$	 
%	 )!00	*	+	$ 
,	$4  5r/   N)r    )
__name__
__module____qualname__
identifierr:   r+   r   r.   staticmethodrb   r4   r/   r-   r#   r#   2   sF    J*&F %G %I	G  D5 D5r/   r#   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)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                   j                  j                         S r3   )r   bodyreadrk   s    r-   raw_datazBottleRequestExtractor.raw_data   s    ||  %%''r/   c                 l    | j                         ry | j                  j                  j                         S r3   )is_jsonr   formsdecoderk   s    r-   formzBottleRequestExtractor.form   s'    <<>||!!((**r/   c                 P    | j                         ry | j                  j                  S r3   )ru   r   filesrk   s    r-   rz   zBottleRequestExtractor.files   s    <<>||!!!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      s     $$(+"#r/   ri   c                 .   d}|dk(  r	 |j                   j                  xs d}nA|dk(  r<	 |j                   j                  xs# t	        |j                   j
                        xs d}|| d<   dt        |   i| d<   y # t        $ r Y w xY w# t        $ r Y .w xY w)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!	==%%+D 
j	(	"" ,W]]-C-CD   E-!)+;<M+N OE
  		  		s"   A9 ;B 9	BB	BBc                     fd}|S )Nc                     t        | j                         t               5  t              j	                  |        d d d        | S # 1 sw Y   | S xY wr3   )r   r+   r   ri   extract_into_event)r   hintrH   r   s     r-   event_processorz6_make_request_event_processor.<locals>.event_processor   sO    (0M0MwW(* 	F"7+>>uE	F 	F s   AAr4   )appr   rH   r   s    `` r-   rF   rF      s     r/   c                     t        | t        j                         j                  d|d      \  }}t        j                  ||       y )Nr$   )typerO   )client_options	mechanism)r   )r   r@   rA   optionscapture_event)rV   rO   r   r   s       r-   rQ   rQ      s?    &!,,.66#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  #<::7	/  / [5 [5|#- #>P0/W  /
-
../s   4B$ $B2