Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/raven/utils/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/raven/utils/__pycache__/encoding.cpython-35.pyc



��Y��@s�dZddlmZmZddlZddlmZmZmZm	Z	m
Z
dd�Zddd	d
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	CsJddl}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/python35/lib/python3.5/site-packages/raven/utils/encoding.py�is_protected_typesrzutf-8F�strictcs5t|t�r|S�r)t|�r)|Sy�t|t�s�t|d�rY|j�}q�ts�t|t�r�t|���}q�t|�}q�tt|����}n|j���}Wnnt	k
r0}zNt|t
�s�t	|j��n(dj���fdd�|D��}WYdd}~XnX|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__� cs%g|]}t|�����qSr)�
force_text)�.0�arg)�encoding�errors�strings_onlyrr�
<listcomp>Cs	zforce_text.<locals>.<listcomp>N)
rrrr�hasattrrr�bytes�decode�UnicodeDecodeError�	Exception�args�join)�srrr�er)rrrrrs(	 rcCs*ddlm}tjdt�||�S)Nr)�	transformz5You should switch to raven.utils.serializer.transform)Zraven.utils.serializerr'�warnings�warn�DeprecationWarning)�valuer'rrrr'Hs	r'cCs�ytt|��}Wnlttfk
r6d}YnOtk
r�y"tttt|����}Wntk
rd}YnXYnX|S)Nz(Error decoding value))rr�UnicodeEncodeErrorr!r"�reprr)r+rrr�
to_unicodePs

"
r.cCsLy t|jd�jd��SWn%tk
rGt|�jd�SYnXdS)Nzutf-8)rr �encoder"r.)r+rrr�	to_string]s 
r0)�__doc__�
__future__rrr(Zraven.utils.compatrrrrrrrr'r.r0rrrr�<module>s(,