σ
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	 d d l
 m Z d	 Z d
 Z d e j f d     YZ d e j e j f d     YZ d e j f d     YZ d e j f d     YZ d S(   sM   
kombu.transport.pyamqp
======================

pure python amqp transport.

i    (   t   absolute_importN(   t   items(   t   get_manager(   t   version_string_as_tuplei   (   t   basei(  i'  t   Messagec           B@  s   e  Z d    Z RS(   c         K@  s}   | j  } t t |   j | d | j d | j d | j d  d | j d  d | j d | j  d | j d  pr i  | d  S(	   Nt   bodyt   delivery_tagt   content_typet   content_encodingt   delivery_infot
   propertiest   headerst   application_headers(   R   t   superR   t   __init__R   R   t   getR
   (   t   selft   channelt   msgt   kwargst   props(    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR      s    					(   t   __name__t
   __module__R   (    (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR      s   t   Channelc           B@  s5   e  Z e Z d d d d d e j d   Z d   Z RS(   c         C@  s+   | | d | d | d | d | | p' i  S(   s=   Prepares message so that it can be sent using this transport.t   priorityR   R	   R   (    (   R   R   R   R   R	   R   R   t   _Message(    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   prepare_message)   s    c         C@  s   |  j  |  |  S(   s4   Convert encoded message body back to a Python value.(   R   (   R   t   raw_message(    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   message_to_python6   s    N(   R   R   R   t   Nonet   amqpR   R   (    (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR   &   s
   t
   Connectionc           B@  s   e  Z e Z RS(    (   R   R   R   (    (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR    ;   s   t	   Transportc           B@  sζ   e  Z e Z e Z e Z e j j Z e j j	 Z	 e j j
 Z
 e j j Z d  Z d Z e Z e Z d d d  Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z d d  Z d   Z e d    Z d   Z RS(   s   py-amqpR   c         K@  s1   | |  _  | p |  j |  _ | p' |  j |  _ d  S(   N(   t   clientt   default_portt   default_ssl_port(   R   R"   R#   R$   R   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR   R   s    	c         C@  s   t  j S(   N(   R   t   __version__(   R   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   driver_versionX   s    c         C@  s
   | j    S(   N(   R   (   R   t
   connection(    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   create_channel[   s    c         K@  s   | j  |   S(   N(   t   drain_events(   R   R'   R   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR)   ^   s    c         C@  sϊ   |  j  } xB t |  j  D]1 \ } } t | | d  s t | | |  q q W| j d k ri d | _ n  t i	 | j d 6| j	 d 6| j
 d 6| j d 6| j d 6| j d 6| j d	 6| j d
 6| j d 6| j pΥ i   } |  j |   } |  j  | _  | S(   s(   Establish connection to the AMQP broker.t	   localhosts	   127.0.0.1t   hostt   useridt   passwordt   login_methodt   virtual_hostt   insistt   sslt   connect_timeoutt	   heartbeatN(   R"   R   t   default_connection_paramst   getattrR   t   setattrt   hostnamet   dictR+   R,   R-   R.   R/   R0   R1   R2   R3   t   transport_optionsR    (   R   t   conninfot   namet   default_valuet   optst   conn(    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   establish_connectiona   s(    	








c         C@  s   | j  S(   N(   t	   connected(   R   R'   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   verify_connectionx   s    c         C@  s   d | _ | j   d S(   s!   Close the AMQP broker connection.N(   R   R"   t   close(   R   R'   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   close_connection{   s    	c         C@  s   | j  S(   N(   R3   (   R   R'   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   get_heartbeat_interval   s    c         C@  s    | j  | j |  j | |  d  S(   N(   t
   add_readert   sockt   on_readable(   R   R'   t   loop(    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   register_with_event_loop   s    i   c         C@  s   | j  d |  S(   Nt   rate(   t   heartbeat_tick(   R   R'   RJ   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   heartbeat_check   s    c         C@  s6   | j  } | j d  d k r2 t | d  d k  St S(   Nt   productt   RabbitMQt   versioni   (   i   i   (   t   server_propertiesR   R   t   True(   R   R'   R   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   qos_semantics_matches_spec   s    	c         C@  s?   i d d 6d d 6|  j  j r& |  j n |  j d 6d d 6d d 6S(	   Nt   guestR,   R-   t   portR*   R7   t   AMQPLAINR.   (   R"   R1   R$   R#   (   R   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR4      s    
c         O@  s   t  |  j | |  S(   N(   R   R"   (   R   t   argsR   (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR      s    N(    R   R   R    t   DEFAULT_PORTR#   t   DEFAULT_SSL_PORTR$   R   t   connection_errorst   channel_errorst   recoverable_connection_errorst   recoverable_channel_errorst   driver_namet   driver_typeRQ   t   supports_heartbeatst   supports_evR   R   R&   R(   R)   R?   RA   RC   RD   RI   RL   RR   t   propertyR4   R   (    (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyR!   ?   s0   									(   t   __doc__t
   __future__R    R   t
   kombu.fiveR   t   kombu.utils.amq_managerR   t   kombu.utils.textR   t    R   RW   RX   R   R   t
   StdChannelR    R!   (    (    (    s8   /tmp/pip-unpacked-wheel-UAnTfW/kombu/transport/pyamqp.pyt   <module>   s   