ó
O'^c           @@  sh  d  Z  d d l m Z d d l Z d d l Z d d l m Z e j d k Z d a
 d   Z d   Z e j j d  r d d	  Z n d d
  Z e rĪ d   Z d   Z d   Z d   Z d   Z e Z n3 d   Z d   Z d   Z d d  Z e Z e Z y
 e Z Wn e k
 r$e Z n Xd d  Z e rId d d  Z n d d d  Z d d  Z d S(   sĀ   
kombu.utils.encoding
~~~~~~~~~~~~~~~~~~~~~

Utilities to encode text, and to safely emit text from running
applications without crashing with the infamous :exc:`UnicodeDecodeError`
exception.

i    (   t   absolute_importN(   t   text_ti   c         C@  s
   |  a  d  S(   N(   t   default_encoding_file(   t   file(    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   set_default_encoding_file   s    c           C@  s   t  S(   N(   R   (    (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   get_default_encoding_file   s    t   javac         C@  s   d S(   Ns   utf-8(    (   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   default_encoding%   s    c         C@  s+   |  p t    }  t |  d d   p* t j   S(   Nt   encoding(   R   t   getattrt   Nonet   syst   getfilesystemencoding(   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   )   s    c         C@  s   t  |  t  r |  j   S|  S(   N(   t
   isinstancet   strt   encode(   t   s(    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   str_to_bytes/   s    
c         C@  s   t  |  t  r |  j   S|  S(   N(   R   t   bytest   decode(   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   bytes_to_str4   s    
c         O@  s   |  S(   N(    (   R   t   argst   kwargs(    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt	   from_utf89   s    c         C@  s   t  |  t  s t |   S|  S(   N(   R   R   R   (   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   ensure_bytes<   s    
c         C@  s   |  S(   N(    (   t   obj(    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   default_encodeA   s    c         C@  s   t  |  t  r |  j   S|  S(   N(   R   t   unicodeR   (   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   H   s    
c         C@  s   |  S(   N(    (   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   M   s    c         O@  s   |  j  d | |  S(   Ns   utf-8(   R   (   R   R   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   P   s    c         C@  s   t  |  t |   S(   N(   R   R   (   R   R   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   S   s    t   replacec         C@  s;   t  |   }  t |  t t f  s. t |  |  St |  |  S(   N(   R   R   R   R   t	   safe_reprt	   _safe_str(   R   t   errors(    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   safe_str`   s    c         C@  s`   t  |  t  r |  Sy t |   SWn8 t k
 r[ } d j t |   | d j t j     SXd  S(   Ns$   <Unrepresentable {0!r}: {1!r} {2!r}>s   
(   R   R   t	   Exceptiont   formatt   typet   joint	   tracebackt   format_stack(   R   R   R   t   exc(    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   i   s    c         C@  s~   t  |  } y3 t |  t  r. |  j | |  St |  | |  SWn8 t k
 ry } d j t |   | d j t j	     SXd  S(   Ns$   <Unrepresentable {0!r}: {1!r} {2!r}>s   
(
   R   R   R   R   R!   R"   R#   R$   R%   R&   (   R   R   R   R   R'   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   r   s    c         C@  s0   y t  |   SWn t k
 r+ t |  |  SXd  S(   N(   t   reprR!   R   (   t   oR   (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyR   }   s    (   i   i    (   t   __doc__t
   __future__R    R   R%   t
   kombu.fiveR   t   version_infot   is_py3kR
   R   R   R   t   platformt
   startswithR   R   R   R   R   R   R   t   str_tR   R   t   bytes_tt	   NameErrorR    R   R   (    (    (    s6   /tmp/pip-unpacked-wheel-UAnTfW/kombu/utils/encoding.pyt   <module>
   sB   											

	