HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/__pycache__/scope.cpython-37.pyc
B

Tav>�@sFddlmZddlmZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZe�rdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZmZmZmZmZmZmZddlmZddl m!Z!ededefd�Z"ed�Z#gZ$dd�Z%dd�Z&dd�Z'Gdd�de(�Z)dS) �)�copy)�deque)�chain)�wraps)�MYPY)�logger�capture_internal_exceptions)�Transaction)�
Attachment)�Any)�Dict)�Optional)�Deque)�List)�Callable)�TypeVar)�
Breadcrumb�Event�EventProcessor�ErrorProcessor�ExcInfo�Hint�Type)�Span)�Session�F.)�bound�TcCst�|�dS)N)�global_event_processors�append)�	processor�r!�A/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/scope.py�add_global_event_processor(sr#cCst||jd�S)N)�fset�doc)�property�__doc__)�fnr!r!r"�_attr_setter-sr)cst���fdd��}|S)Ncs.|js
dSzd|_�|f|�|�Sd|_XdS)NFT)�_should_capture)�self�args�kwargs)r(r!r"�wrapper4sz!_disable_capture.<locals>.wrapper)r)r(r.r!)r(r"�_disable_capture2sr/c@seZdZdZdZdd�Zdd�Zedd��Zd	d
�Z	edd��Z
ed
d��Zej
dd��Zedd��Zdd�Zedd��Zej
dd��Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd7d'd(�Zd)d*�Zd8d+d,�Zed-d.��Zd/d0�Zd9d1d2�Zd3d4�Zd5d6�Z d%S):�ScopezaThe scope holds extra information that should be sent with all
    events that belong to it.
    )�_level�_name�_fingerprint�_transaction�_user�_tags�	_contexts�_extras�_breadcrumbs�_event_processors�_error_processorsr*�_span�_session�_attachments�_force_auto_session_trackingcCsg|_g|_d|_|��dS)N)r:r;r2�clear)r+r!r!r"�__init__bszScope.__init__cCsTd|_d|_d|_d|_i|_i|_i|_g|_|��d|_	d|_
d|_d|_dS)zClears the entire scope.NT)
r1r3r4r5r6r7r8r>�clear_breadcrumbsr*r<r=r?)r+r!r!r"r@jszScope.clearcCs
||_dS)zDWhen set this overrides the level. Deprecated in favor of set_level.N)r1)r+�valuer!r!r"�level~szScope.levelcCs
||_dS)zSets the level for the scope.N)r1)r+rCr!r!r"�	set_level�szScope.set_levelcCs
||_dS)z0When set this overrides the default fingerprint.N)r3)r+rCr!r!r"�fingerprint�szScope.fingerprintcCs4|jdkrdSt|jt�r |jS|jjr0|jjSdS)z8Return the transaction (root span) in the scope, if any.N)r<�
isinstancer	Z_containing_transaction)r+r!r!r"�transaction�s
zScope.transactioncCs$||_|j}|r t|t�r ||_dS)z;When set this forces a specific transaction name to be set.N)r4r<rGr	�name)r+rC�spanr!r!r"rH�scCs|�|�dS)zPWhen set a specific user is bound to the scope. Deprecated in favor of set_user.N)�set_user)r+rCr!r!r"�user�sz
Scope.usercCs"||_|jdk	r|jj|d�dS)zSets a user for the scope.N)rL)r5r=�update)r+rCr!r!r"rK�s
zScope.set_usercCs|jS)z,Get/set current tracing span or transaction.)r<)r+r!r!r"rJ�sz
Scope.spancCs&||_t|t�r"|}|jr"|j|_dS)N)r<rGr	rIr4)r+rJrHr!r!r"rJ�s

cCs||j|<dS)z)Sets a tag for a key to a specific value.N)r6)r+�keyrCr!r!r"�set_tag�sz
Scope.set_tagcCs|j�|d�dS)zRemoves a specific tag.N)r6�pop)r+rNr!r!r"�
remove_tag�szScope.remove_tagcCs||j|<dS)z5Binds a context at a certain key to a specific value.N)r7)r+rNrCr!r!r"�set_context�szScope.set_contextcCs|j�|d�dS)zRemoves a context.N)r7rP)r+rNr!r!r"�remove_context�szScope.remove_contextcCs||j|<dS)z&Sets an extra key to a specific value.N)r8)r+rNrCr!r!r"�	set_extra�szScope.set_extracCs|j�|d�dS)zRemoves a specific extra key.N)r8rP)r+rNr!r!r"�remove_extraszScope.remove_extracCst�|_dS)zClears breadcrumb buffer.N)rr9)r+r!r!r"rBszScope.clear_breadcrumbsNFc	Cs|j�t|||||d��dS)z)Adds an attachment to future events sent.)�bytes�path�filename�content_type�add_to_transactionsN)r>rr
)r+rVrXrWrYrZr!r!r"�add_attachment
s
zScope.add_attachmentcCs8t|j�dkr(t�d|j�|jdd�=|j�|�dS)z}Register a scope local event processor on the scope.

        :param func: This function behaves like `before_send.`
        �zLToo many event processors on scope! Clearing list to free up some memory: %rN)�lenr:r�warningr)r+�funcr!r!r"�add_event_processor!szScope.add_event_processorcs.|dk	r|�|���fdd�}|j�|�dS)aRegister a scope local error processor on the scope.

        :param func: A callback that works similar to an event processor but is invoked with the original exception info triple as second argument.

        :param cls: Optionally, only process exceptions of this type.
        Ncs>yt|d��}Wntk
r*d}YnX|r:�||�S|S)N�F)rG�	Exception)�event�exc_infoZis_inst)�cls_�	real_funcr!r"r_Bs

z'Scope.add_error_processor.<locals>.func)r;r)r+r_�clsr!)rerfr"�add_error_processor2s

zScope.add_error_processorc
Csdd�}|�d�dk}|�d�p"g}x"|jD]}|r:|jr,|�|�q,W||d<|jdk	rd|j|d<|s�|�di��d	g��|j�|�d
�dkr�|jdk	r�|j|d
<|�d�dkr�|j	dk	r�|j	|d<|�d�dkr�|j
dk	r�|j
|d<|j�r|�di��|j�|j
�r"|�d
i��|j
�|j�r>|�di��|j�|jdk	�rp|�di�}|�d��sp|j��|d<|�d�}|dk	�r�x4|jD]*}	|	||�}
|
dk�r�|||	d�S|
}�q�WxPtt|j�D]@}|}
t��|||�}
WdQRX|
dk�r|||d�S|
}�q�W|S)zBApplies the information contained on the scope to the given event.cSst�d|||�dS)Nz%s (%s) dropped event (%s))r�info)rc�cause�tyr!r!r"�_dropWsz#Scope.apply_to_event.<locals>._drop�typerH�attachmentsNrDZbreadcrumbs�valuesrLrF�extra�tags�contexts�tracerdzerror processorzevent processor)�getr>rZrr1�
setdefault�extendr9r5r4r3r8rMr6r7r<Zget_trace_contextr;rrr:r)r+rc�hintrlZis_transactionZattachments_to_send�
attachmentrrrdZerror_processorZ	new_eventZevent_processorr!r!r"�apply_to_eventNsV	












zScope.apply_to_eventcCs�|jdk	r|j|_|jdk	r$|j|_|jdk	r6|j|_|jdk	rH|j|_|jr\|j�|j�|jrp|j�|j�|jr�|j�|j�|jr�|j�	|j�|j
r�|j
|_
|jr�|j�	|j�dS)N)r1r3r4r5r6rMr7r8r9rvr<r>)r+Zscoper!r!r"�update_from_scope�s(



zScope.update_from_scopecCsj|dk	r||_|dk	r||_|dk	r0|j�|�|dk	rD|j�|�|dk	rX|j�|�|dk	rf||_dS)N)r1r5r8rMr7r6r3)r+rLrD�extrasrrrqrFr!r!r"�update_from_kwargs�s
zScope.update_from_kwargscCs�t�|j�}|j|_|j|_|j|_|j|_|j|_t|j	�|_	t|j
�|_
t|j�|_t|j
�|_
t|j�|_t|j�|_|j|_|j|_|j|_|j|_t|j�|_|S)N)�object�__new__�	__class__r1r2r3r4r5�dictr6r7r8rr9�listr:r;r*r<r=r?r>)r+�rvr!r!r"�__copy__�s$zScope.__copy__cCsd|jjtt|��|jfS)Nz<%s id=%s name=%s>)r�__name__�hex�idr2)r+r!r!r"�__repr__�s
zScope.__repr__)NNNNF)N)NNNNNN)!r��
__module__�__qualname__r'�	__slots__rAr@r)rDrErFr&rH�setterrLrKrJrOrQrRrSrTrUrBr[r`rhr/ryrzr|r�r�r!r!r!r"r0BsJ				

J
r0N)*r�collectionsr�	itertoolsrZsentry_sdk._functoolsrZsentry_sdk._typesrZsentry_sdk.utilsrrZsentry_sdk.tracingr	Zsentry_sdk.attachmentsr
�typingrrr
rrrrrrrrrrrrZsentry_sdk.sessionrrrrr#r)r/r}r0r!r!r!r"�<module>s2$