๓
O'^c           @@  sฯ   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 d d l
 m Z d d	 g Z e	 j Z e d d
  Z d e j f d     YZ d	 e j f d     YZ d e j f d     YZ d S(   sฆ   
kombu.compat
============

Carrot compatible interface for :class:`Publisher` and :class:`Producer`.

See http://packages.python.org/pypi/carrot for documentation.

i    (   t   absolute_import(   t   counti   (   t	   messaging(   t   Exchanget   Queue(   t   itemst	   Publishert   Consumerc         c@  sQ   | j  d |  x: t d  D], } | r> | | k r> t  n  |  j   Vq Wd  S(   Nt   no_acki    (   t   consumeR   t   StopIterationt   drain_events(   t
   connectiont   consumerR   t   limitt	   iteration(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   _iterconsume   s
    	c           B@  sz   e  Z d  Z d Z d  Z e Z e Z e Z	 d d d d d d d  Z d   Z d   Z d   Z d   Z e d    Z RS(	   t    t   directc   	      K@  sๆ   | r | } n  | p |  j  |  _  | p- |  j |  _ | p? |  j |  _ | d  k	 r] | |  _ n  | d  k	 ru | |  _ n  t |  j  t  sร t d |  j  d |  j d |  j d |  j d |  j  |  _  n  t t	 |   j
 | |  j  |  d  S(   Nt   namet   typet   routing_keyt   auto_deletet   durable(   t   exchanget   exchange_typeR   t   NoneR   R   t
   isinstanceR   t   superR   t   __init__(	   t   selfR   R   R   R   R   R   t   channelt   kwargs(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR   (   s     				c         O@  s   |  j  | |   S(   N(   t   publish(   R   t   argsR    (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   send?   s    c         C@  s    t  t |   j   t |  _ d  S(   N(   R   R   t   closet   Truet   _closed(   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR$   B   s    c         C@  s   |  S(   N(    (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt	   __enter__F   s    c         G@  s   |  j    d  S(   N(   R$   (   R   t   exc_info(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   __exit__I   s    c         C@  s   |  j  S(   N(   R   (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   backendL   s    N(   t   __name__t
   __module__R   R   R   R%   R   t   FalseR   R&   R   R   R#   R$   R'   R)   t   propertyR*   (    (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR       s   					c           B@  sื   e  Z d  Z d  Z d  Z d Z e Z e Z	 e Z
 d Z e Z d d d d d d d d  Z d   Z d   Z d   Z d   Z d   Z d e d  Z d	   Z d d
  Z d d d  Z d d  Z d e d  Z RS(   R   R   c	   
      K@  s.  | j    |  _ | d  k	 r' | |  _ n  | d  k	 r? | |  _ n  | d  k	 rW | |  _ n  | pc |  j |  _ | pu |  j |  _ | p |  j |  _ | p |  j	 |  _	 t
 |  j d |  j d |  j	 d |  j d |  j } t |  j d | d |  j	 d |  j d |  j d |  j } t t |   j |  j | |	  d  S(   NR   R   R   R   R   t	   exclusive(   R   R*   R   R   R/   R   t   queueR   R   R   R   R   R   R   R   (
   R   R   R0   R   R   R   R   R/   R   R    (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR   \   s.    						c         C@  s#   | |  _  t t |   j |  d  S(   N(   R*   R   R   t   revive(   R   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR1   z   s    	c         C@  s$   |  j    |  j j   t |  _ d  S(   N(   t   cancelR*   R$   R%   R&   (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR$   ~   s    
c         C@  s   |  S(   N(    (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR'      s    c         G@  s   |  j    d  S(   N(   R$   (   R   R(   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR)      s    c         C@  s   |  j  d t  S(   Nt   infinite(   t	   iterqueueR%   (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   __iter__   s    c         C@  sW   | d  k r |  j } n  |  j d j |  } | rS | rS |  j | j |  qS n  | S(   Ni    (   R   R   t   queuest   gett   receivet   payload(   R   R   t   enable_callbackst   message(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   fetch   s    c         C@  s   t  d   d  S(   Ns    Use fetch(enable_callbacks=True)(   t   NotImplementedError(   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   process_next   s    c         C@  s%   | d  k	 r t d   n  |  j   S(   Ns&   discard_all does not implement filters(   R   R=   t   purge(   R   t
   filterfunc(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   discard_all   s    c         C@  s   t  |  j |  | |  S(   N(   R   R   (   R   R   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   iterconsume   s    c         C@  s   |  j  |  } t |  S(   N(   RB   t   list(   R   R   t   it(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   waitก   s    c         c@  sW   xP t    D]E } |  j   } | r/ | d  k sA | rJ | | k rJ t  n  | Vq
 Wd  S(   N(   R   R<   R   R
   (   R   R   R3   t   items_since_startt   item(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR4   ฅ   s    	N(   R+   R,   R0   R   R   R   R%   R   R-   R/   R   R&   R   R   R1   R$   R'   R)   R5   R<   R>   RA   RB   RE   R4   (    (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR   Q   s.   								t   ConsumerSetc           B@  sV   e  Z d d d d   Z d e d  Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   c   
      K@  sล   | r t  |  _ | |  _ n t |  _ | j   |  _ g  } | rc x! | D] } | j | j  qF Wn  | rข x6 t |  D]% \ } }	 | j t	 j
 | |	   qv Wn  t t |   j |  j | |  d  S(   N(   R%   t   _provided_channelR*   R-   R   t   extendR6   R   t   appendR   t	   from_dictR   RH   R   (
   R   R   RL   t	   consumersR   R    R6   R   t
   queue_namet   queue_options(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR   ฐ   s    		 c         C@  s   t  |  j |  | |  S(   N(   R   R   (   R   R   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyRB   ร   s    c         C@  s
   |  j    S(   N(   R?   (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyRA   ฦ   s    c         K@  s   |  j  | |  S(   N(   t   add_queue_from_dict(   R   R0   t   options(    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   add_consumer_from_dictษ   s    c         C@  s%   x | j  D] } |  j |  q
 Wd  S(   N(   R6   t	   add_queue(   R   R   R0   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   add_consumerฬ   s    c         C@  s#   | |  _  t t |   j |  d  S(   N(   R*   R   RH   R1   (   R   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR1   ะ   s    	c         C@  s'   |  j    |  j s# |  j j   n  d  S(   N(   R2   RI   R   R$   (   R   (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyR$   ิ   s    
	N(   R+   R,   R   R   R-   RB   RA   RR   RT   R1   R$   (    (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyRH   ฎ   s   				N(   t   __doc__t
   __future__R    t	   itertoolsR   R   R   t   entityR   R   t   fiveR   t   __all__RL   t   entry_to_queueR-   R   R   t   ProducerR   R   RH   (    (    (    s.   /tmp/pip-unpacked-wheel-UAnTfW/kombu/compat.pyt   <module>	   s   	1]