Viewing File: /opt/alt/python35/lib/python3.5/site-packages/sentry_sdk/__pycache__/scope.cpython-35.opt-1.pyc



\@sddlmZddlmZddlmZddlmZddlmZm	Z	m
Z
gZddZdd	Z
d
dZGdd
d
eZdS))copy)deque)wraps)chain)loggercapture_internal_exceptionsobject_to_jsoncCstj|dS)N)global_event_processorsappend)	processorr	/scope.pyadd_global_event_processorsrcCstd|d|jS)Nfsetdoc)property__doc__)fnrrr
_attr_settersrcs"tfdd}|S)Ncs;|js
dSzd|_|||SWdd|_XdS)NFT)_should_capture)selfargskwargs)rrr
wrappers		z!_disable_capture.<locals>.wrapper)r)rrr)rr
_disable_capturesrc@seZdZdZd3ZddZeddZeddZeddZ	eddZ
ddZddZddZ
ddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+d,Zed*d-d.Zd/d0Zd1d2Zd*S)4ScopezaThe 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_processorsrcCs)g|_g|_d|_|jdS)N)r%r&rclear)rrrr
__init__@s			zScope.__init__cCs
||_dS)z"When set this overrides the level.N)r)rvaluerrr
levelGszScope.levelcCs
||_dS)z0When set this overrides the default fingerprint.N)r)rr)rrr
fingerprintLszScope.fingerprintcCs
||_dS)z;When set this forces a specific transaction name to be set.N)r)rr)rrr
transactionQszScope.transactioncCs
||_dS)z/When set a specific user is bound to the scope.N)r )rr)rrr
userVsz
Scope.usercCs||j|<dS)z)Sets a tag for a key to a specific value.N)r!)rkeyr)rrr
set_tag[sz
Scope.set_tagcCs|jj|ddS)zRemoves a specific tag.N)r!pop)rr.rrr

remove_tag_szScope.remove_tagcCs||j|<dS)z5Binds a context at a certain key to a specific value.N)r")rr.r)rrr
set_contextcszScope.set_contextcCs|jj|ddS)zRemoves a context.N)r"r0)rr.rrr
remove_contextgszScope.remove_contextcCs||j|<dS)z&Sets an extra key to a specific value.N)r#)rr.r)rrr
	set_extrakszScope.set_extracCs|jj|ddS)zRemoves a specific extra key.N)r#r0)rr.rrr
remove_extraoszScope.remove_extracCsVd|_d|_d|_d|_i|_i|_i|_|jd|_dS)zClears the entire scope.NT)	rrrr r!r"r#clear_breadcrumbsr)rrrr
r'ss							
zScope.clearcCst|_dS)zClears breadcrumb buffer.N)rr$)rrrr
r6szScope.clear_breadcrumbscCs|jj|dS)zq"Register a scope local event processor on the scope.

        This function behaves like `before_send.`
        N)r%r
)rfuncrrr
add_event_processorszScope.add_event_processorNcs;dk	r'|fdd}|jj|dS)z"Register a scope local error processor on the scope.

        The error processor works similar to an event processor but is
        invoked with the original exception info triple as second argument.
        NcsIyt|d}Wntk
r1d}YnX|rE||S|S)NF)
isinstance	Exception)eventexc_infoZis_inst)cls	real_funcrr
r7s

z'Scope.add_error_processor.<locals>.func)r&r
)rr7r>r)r>r?r
add_error_processors	zScope.add_error_processorcCs'dd}|jdk	r(|j|d<|jdgj|j|jddkru|jdk	ru|j|d<|jddkr|jdk	r|j|d<|jddkr|jdk	r|j|d<|jr|jd	ij	t
|j|jr'|jd
ij	|j|jrL|jdij	|j|dk	rg|jdnd}|dk	rxB|j
D]7}|||}|dkr|||d
S|}qWxbtt|jD]N}|}t|||}WdQRX|dkr|||dS|}qW|S)zBApplies the information contained on the scope to the given event.cSstjd|||dS)Nz%s (%s) dropped event (%s))rinfo)r<causeZtyrrr
_dropsz#Scope.apply_to_event.<locals>._dropNr*Zbreadcrumbsr-r,r+extraZtagsZcontextsr=zerror processorzevent processor)r
setdefaultextendr$getr rrr#updaterr!r"r&rr	r%r)rr<ZhintrCr=rZ	new_eventrrr
apply_to_events>
$
$
$
	"		!


zScope.apply_to_eventcCstj|j}|j|_|j|_|j|_|j|_|j|_t|j	|_	t|j
|_
t|j|_t|j
|_
t|j|_t|j|_|j|_|S)N)object__new__	__class__rrrrr dictr!r"r#rr$listr%r&r)rrvrrr
__copy__szScope.__copy__cCs&d|jjtt||jfS)Nz<%s id=%s name=%s>)rL__name__hexidr)rrrr
__repr__s	zScope.__repr__)rrrrr r!r"r#r$r%r&r)rQ
__module____qualname__r	__slots__r(rr*r+r,r-r/r1r2r3r4r5r'r6r8r@rrIrPrTrrrr
r,s@1rN)rcollectionsr	functoolsr	itertoolsrZsentry_sdk.utilsrrrr	rrrrJrrrrr
<module>s
Back to Directory File Manager