File: //opt/alt/python27/lib/python2.7/site-packages/raven/utils/encoding.pyo
�
��Yc           @@ s�   d  Z  d d l m Z m Z d d l Z d d l m Z m Z m Z m	 Z	 m
 Z
 d �  Z d e d d � Z
 d	 �  Z d
 �  Z d �  Z d S(   u�   
raven.utils.encoding
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
i    (   t   absolute_importt   unicode_literalsN(   t
   integer_typest	   text_typet   binary_typet   string_typest   PY2c      	   C@ sJ   d d l  } d d l } t |  t t d � t | | j | j | j f � S(   u�   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).
    i    N(	   t   Decimalt   datetimet
   isinstanceR   t   typet   Nonet   floatt   datet   time(   t   objR   R   (    (    sE   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/encoding.pyt   is_protected_type   s    u   utf-8u   strictc         C@ s,  t  |  t � r |  S| r) t |  � r) |  Sy� t  |  t � s� t |  d � rY |  j �  }  q� t s� t  |  t � r� t |  | | � }  q� t |  � }  q� t t |  � | | � }  n |  j | | � }  Wne t	 k
 r'} t  |  t
 � s� t	 | j �  � q(d j g  |  D] } t
 | | | | � ^ q � }  n X|  S(   u�   
    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.
    u   __unicode__u    (   R	   R   R   R   t   hasattrt   __unicode__R   t   bytest   decodet   UnicodeDecodeErrort	   Exceptiont   argst   joint
   force_text(   t   st   encodingt   strings_onlyt   errorst   et   arg(    (    sE   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/encoding.pyR      s(    		,c         C@ s*   d d l  m } t j d t � | |  � S(   Ni    (   t	   transformu5   You should switch to raven.utils.serializer.transform(   t   raven.utils.serializerR    t   warningst   warnt   DeprecationWarning(   t   valueR    (    (    sE   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/encoding.pyR    H   s    	c         C@ s�   y t  t |  � � }  Wni t t f k
 r5 d }  nM t k
 r� y"