bg<dZddlmZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZddlmZddlmZd Zd ZGd d eZGd deZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZ Gdd eZ!e rGd!d"eZ"ej#eej#eej#eej#eej#eej#eej#eej#eej#e ej#e!e rej#e"dSdS)#z raven.utils.serializer.base ~~~~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. )absolute_importN) text_type binary_type string_types iteritems class_typesPY2PY3) to_unicodemanager is_namedtuple) Serializercj t|dS#t$rYdSwxYw)N __sentry__F)callable__getattribute__ Exception)values R/opt/cloudlinux/venv/lib64/python3.11/site-packages/raven/utils/serializer/base.pyhas_sentry_metadatarsE..|<<=== uus !$ 22c,eZdZdZdZdZdZd dZdS) rc||_dSNr )selfrs r__init__zSerializer.__init__#s  c,t||jSz| Given ``value``, return a boolean describing whether this serializer can operate on the given type ) isinstancetypesrrs rcanzSerializer.can&s %,,,r c |S)z@ Given ``value``, coerce into a JSON-safe type. rrrkwargss r serializezSerializer.serialize-s  r rc |dd}|dz }||kr tt|d|}nj#t$r]}ddl}||jj|tt|cYd}~Sd}~wwxYw|jj |f||d|S)z| Given ``value``, recurse (using the parent serializer) to handle coercing of newly defined values. string_max_lengthNr r) max_depth_depth) getrreprr traceback print_excrlogger exceptiontype transform)rrr.r/r)r-er2s rrecursezSerializer.recurse3s #JJ':DAA!  Y   .!$u++../A0A/AB . . .    ##%%% #--a000 e--------  . &t|%e?y-3??7=?? ?s$A B/AB*$B/*B/N)r+r)__name__ __module__ __qualname__r$rr&r*r9rr rrr sZ E--- ??????r rc*eZdZejfZdZdZdS)NamedtupleSerializerc t|Sr"rr%s rr&zNamedtupleSerializer.canJs U###r c (dptdfd}|}tj}t fd||t|D}|S)Nlist_max_lengthinfc|dkSNrrxrAs rz0NamedtupleSerializer.serialize..Ssad_4r c<g|]\}\}}|j|fifSrr9.0nkvr)rs r z2NamedtupleSerializer.serialize..VsJ   6Aq  Q))&)) *   r )r0float_asdictitems itertools takewhiledict enumerate)rrr) less_thanrRrTrFrAs` ` @rr*zNamedtupleSerializer.serializeQs **%677G5<<4444  %%'''      &Yy)E2B2BCC     r N)r:r;r< collections namedtupler$r&r*rr rr>r>Gs=  # %E$$$     r r>c eZdZeeeefZdZdS)IterableSerializerc dptdtfdtjfdt |DS)NrArBc3:K|]\}}j|fiVdSrrI)rKrLor)rs r z/IterableSerializer.serialize..bsO  1 DL % %f % %      r c|dkSrDrrEs rrGz.IterableSerializer.serialize..eQqTO-Cr )r0rPtuplerSrTrVrrr)rAs` `@rr*zIterableSerializer.serialize`s **%677G5<<     "#C#C#C#C#,U#3#355      r N) r:r;r<rblistset frozensetr$r*rr rr[r[]s1 D#y )E     r r[c eZdZefZdZdZdS)DictSerializercNt|tst|S|Sr)r#rr )rkeys rmake_keyzDictSerializer.make_keyms%#|,, #c?? " r c dptdtfdtjfdt t |DS)NrArBc3K|]9\}\}}j|fij|fifV:dSr)rkr9rJs rr_z+DictSerializer.serialize..tsx  6Aq]]<4<44V44 5 5|t|A7P7P7P7P Q      r c|dkSrDrrEs rrGz*DictSerializer.serialize..wrar )r0rPrUrSrTrVrrcs` `@rr*zDictSerializer.serializers **%677G5<<     "#C#C#C#CY%  F"F"##      r N)r:r;r<rUr$rkr*rr rrhrhjs9 GE      r rhceZdZefZdZdS)UnicodeSerializerc ~|dd}ttd|d|fzS)Nr-z%s)r0r1rrrr)r-s rr*zUnicodeSerializer.serializesA #JJ':DAAIdOO$$.@/@.@(A'CCCr N)r:r;r<rr$r*rr rrprp|s/ LEDDDDDr rpceZdZefZdZdS)StringSerializerc &|dd}trt|d|S d|dd|dzdzS#t $rYnwxYwt|d|S)Nr-'utf8)r0r r1decodeencodeUnicodeDecodeErrorrrs rr*zStringSerializer.serializes"JJ':DAA  3000122 2 f--.@/@.@A "%& &!    D E,,,-...s5A,, A98A9N)r:r;r<rr$r*rr rrtrts* NE / / / / /r rtc(eZdZeZfdZdZxZS)TypeSerializercttt|| ot|Sr)superr|r&r)rr __class__s rr&zTypeSerializer.cans6..225999+#E** +r c B|j|fi|Sr)r9rr(s rr*zTypeSerializer.serializes(t|E,,..99&999r )r:r;r<rr$r&r* __classcell__)rs@rr|r|sL E+++++:::::::r r|ceZdZefZdZdS)BooleanSerializerc :tt|Sr)r1boolr(s rr*zBooleanSerializer.serializesDKK   r N)r:r;r<rr$r*rr rrrs* GE!!!!!r rceZdZefZdZdS)FloatSerializerc :tt|Sr)r1rPr(s rr*zFloatSerializer.serializesE%LL!!!r N)r:r;r<rPr$r*rr rrrs* HE"""""r rceZdZefZdZdS)IntegerSerializerc :tt|Sr)r1intr(s rr*zIntegerSerializer.serializesCJJr N)r:r;r<rr$r*rr rrrs* FE     r rc$eZdZejfZdZdS)FunctionSerializerc @d|j|jt|fzS)Nz)r:r;idr(s rr*zFunctionSerializer.serializes&. NE,bii299 9r N)r:r;r<r$ FunctionTyper*rr rrrs.   !E99999r rceZdZefZdZdS)LongSerializerc :tt|Sr)r1longr(s rr*zLongSerializer.serializesU $$ $r N)r:r;r<rr$r*rr rrrs* % % % % %r r)$__doc__ __future__rrXrSr$raven.utils.compatrrrrrr r raven.utils.encodingr rserialization_manager raven.utilsr__all__robjectrr>r[rhrprtr|rrrrrregisterrr rrs'&&&&& ++++++555555%%%%%% $?$?$?$?$?$?$?$?N:,               Z   $ D D D D D D D D/////z///&:::::Z:::!!!!! !!!"""""j"""        99999999%%%%%%%%%34441222~...0111/000~...0111///011112223"">2222233r