σ
O'^c           @@  s   d  Z  d d l m Z d d l Z d d l m Z d d l m Z d d l m	 Z	 m
 Z
 d d l m Z e d	 d
 d g  Z d e f d     YZ d S(   sB   
kombu.transport.message
=======================

Message class.

i    (   t   absolute_importNi   (   t
   decompress(   t   MessageStateError(   t   reraiset   text_t(   t   loadst   ACKt   REJECTEDt   REQUEUEDt   Messagec           B@  sͺ   e  Z d  Z d Z e Z d Z d d d d i  d d d d d 	 Z d d  Z d   Z	 d   Z
 e d  Z e d  Z d   Z d   Z e d    Z e d    Z RS(   s!   Base class for received messages.t   _statet   channelt   delivery_tagt   content_typet   content_encodingt   delivery_infot   headerst
   propertiest   bodyt   _decoded_cachet   acceptt   __dict__c         K@  sU  |  j  d  k r g  n |  j  |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | pW i  |  _ | pf i  |  _ d  |  _	 d |  _
 |
 |  _ |  j j d  } |  j  rι | rι y t | |  } Wqι t k
 rε |  j  j t j    qι Xn  |  j  rH|	 rHt | t  rHy | j |	  } WqHt k
 rD|  j  j t j    qHXn  | |  _ d  S(   Nt   RECEIVEDt   compression(   t   errorst   NoneR   R   R   R   R   R   R   R   R
   R   t   getR   t	   Exceptiont   appendt   syst   exc_infot
   isinstanceR   t   encodeR   (   t   selfR   R   R   R   R   R   R   R   t
   postencodeR   t   kwargsR   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   __init__   s.    !								c         C@  sH   y t  |  j d   Wn, t k
 rC } | s3   n  | |  |  n Xd  S(   Ni    (   R   R   R   (   R!   t   callbackt   exc(    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   _reraise_error<   s    c         C@  s   |  j  j d k	 rP y |  j d } Wn t k
 r6 qP X| |  j  j k rP d Sn  |  j rt |  j d j |     n  |  j  j |  j	  d |  _
 d S(   sά   Acknowledge this message as being processed.,
        This will remove the message from the queue.

        :raises MessageStateError: If the message has already been
            acknowledged/requeued/rejected.

        t   consumer_tagNs3   Message already acknowledged with state: {0._state}R   (   R   t   no_ack_consumersR   R   t   KeyErrort   acknowledgedR   t   formatt	   basic_ackR   R
   (   R!   R(   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   ackD   s    	c         C@  sD   y |  j    Wn/ | k
 r? } | j d |  j | d t n Xd  S(   Ns   Couldn't ack %r, reason:%rR   (   R.   t   criticalR   t   True(   R!   t   loggerR   R&   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   ack_log_error[   s
    	c         C@  sJ   y |  j  d |  Wn/ | k
 rE } | j d |  j | d t n Xd  S(   Nt   requeues   Couldn't reject %r, reason: %rR   (   t   rejectR/   R   R0   (   R!   R1   R   R3   R&   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   reject_log_errorb   s
    	c         C@  sJ   |  j  r$ |  j d j |     n  |  j j |  j d | d |  _ d S(   sΔ   Reject this message.

        The message will be discarded by the server.

        :raises MessageStateError: If the message has already been
            acknowledged/requeued/rejected.

        s3   Message already acknowledged with state: {0._state}R3   R   N(   R+   R   R,   R   t   basic_rejectR   R
   (   R!   R3   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyR4   i   s    		c         C@  sJ   |  j  r$ |  j d j |     n  |  j j |  j d t d |  _ d S(   s  Reject this message and put it back on the queue.

        You must not use this method as a means of selecting messages
        to process.

        :raises MessageStateError: If the message has already been
            acknowledged/requeued/rejected.

        s3   Message already acknowledged with state: {0._state}R3   R   N(   R+   R   R,   R   R6   R   R0   R
   (   R!   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyR3   y   s    
	c         C@  s"   t  |  j |  j |  j d |  j S(   sd   Deserialize the message body, returning the original
        python structure sent by the publisher.R   (   R   R   R   R   R   (   R!   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   decode   s    c         C@  s   |  j  t k S(   s1   Set to true if the message has been acknowledged.(   R
   t
   ACK_STATES(   R!   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyR+      s    c         C@  s"   |  j  s |  j   |  _  n  |  j  S(   s   The decoded message body.(   R   R7   (   R!   (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   payload   s    	(   R
   R   R   R   R   R   R   R   R   R   R   R   N(   t   __name__t
   __module__t   __doc__t	   __slots__R   R   R   R$   R'   R.   R2   t   FalseR5   R4   R3   R7   t   propertyR+   R9   (    (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyR	      s(      						(   R<   t
   __future__R    R   R   R   t
   exceptionsR   t   fiveR   R   t   serializationR   t	   frozensetR8   t   objectR	   (    (    (    s/   /tmp/pip-unpacked-wheel-UAnTfW/kombu/message.pyt   <module>   s   