B ¿öYç ã@sfdZddlmZmZddlZddlmZmZmZm Z m Z dd„Z dd d „Z d d „Z dd„Zdd„ZdS)z­ raven.utils.encoding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. é)Úabsolute_importÚunicode_literalsN)Ú integer_typesÚ text_typeÚ binary_typeÚ string_typesÚPY2c Cs4ddl}ddl}t|ttdƒt||j|j|jfƒS)z£Determine if the object instance is of a protected type. Objects of protected types are preserved as-is when passed to force_text(strings_only=True). rN)ÚDecimalÚdatetimeÚ isinstancerÚtypeÚfloatÚdateÚtime)Úobjr r ©rúE/opt/alt/python37/lib/python3.7/site-packages/raven/utils/encoding.pyÚis_protected_typesrúutf-8FÚstrictc sÞt|tƒr|Sˆrt|ƒr|Syft|tƒsvt|dƒr>| ¡}q‚tsdt|tƒrZt|ˆˆƒ}qtt|ƒ}q‚tt|ƒˆˆƒ}n | ˆˆ¡}WnTt k rØ}z6t|t ƒs¬t |j Ž‚nd  ‡‡‡fdd„|Dƒ¡}Wdd}~XYnX|S)zÆ Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects. If strings_only is True, don't convert (some) non-string-like objects. Ú __unicode__ú csg|]}t|ˆˆˆƒ‘qSr)Ú force_text)Ú.0Úarg)ÚencodingÚerrorsÚ strings_onlyrrú Cszforce_text..N) r rrrÚhasattrrrÚbytesÚdecodeÚUnicodeDecodeErrorÚ ExceptionÚargsÚjoin)ÚsrrrÚer)rrrrrs(         rcCs ddlm}t dt¡||ƒS)Nr)Ú transformz5You should switch to raven.utils.serializer.transform)Zraven.utils.serializerr(ÚwarningsÚwarnÚDeprecationWarning)Úvaluer(rrrr(Hs r(c Csvytt|ƒƒ}Wn`ttfk r,d}YnFtk rpytttt|ƒƒƒƒ}Wntk rjd}YnXYnX|S)Nz(Error decoding value))rrÚUnicodeEncodeErrorr"r#Úreprr )r,rrrÚ to_unicodePsr/cCs8yt| d¡ d¡ƒStk r2t|ƒ d¡SXdS)Nzutf-8)rr!Úencoder#r/)r,rrrÚ to_string]sr1)rFr)Ú__doc__Ú __future__rrr)Zraven.utils.compatrrrrrrrr(r/r1rrrrÚs ,