ó IÀSc@sôdZddlZddlZddlmZddlmZddlmZejeƒZ dej fd„ƒYZ de fd „ƒYZ d e fd „ƒYZ d e fd „ƒYZde fd„ƒYZdej fd„ƒYZd„ZdS(s<Frame objects that do the frame demarshaling and marshaling.iÿÿÿÿN(t amqp_object(t exceptions(tspectFramecBs/eZdZdZd„Zd„Zd„ZRS(sÝBase Frame object mapping. Defines a behavior for all child classes for assignment of core attributes and implementation of the a core _marshal method which child classes use to create the binary AMQP frame. RcCs||_||_dS(sCreate a new instance of a frame :param int frame_type: The frame type :param int channel_number: The channel number for the frame N(t frame_typetchannel_number(tselfRR((s./usr/lib/python2.7/site-packages/pika/frame.pyt__init__s cCsBdj|ƒ}tjd|j|jt|ƒƒ|ttjƒS(s[Create the full AMQP wire protocol frame data representation :rtype: str ts>BHI( tjointstructtpackRRtlentchrRt FRAME_END(Rtpiecestpayload((s./usr/lib/python2.7/site-packages/pika/frame.pyt_marshalscCs t‚dS(sKTo be ended by child classes :raises NotImplementedError N(tNotImplementedError(R((s./usr/lib/python2.7/site-packages/pika/frame.pytmarshal*s(t__name__t __module__t__doc__tNAMERRR(((s./usr/lib/python2.7/site-packages/pika/frame.pyR s  tMethodcBs&eZdZdZd„Zd„ZRS(s“Base Method frame object mapping. AMQP method frames are mapped on top of this class for creating or accessing their data and attributes. tMETHODcCs#tj|tj|ƒ||_dS(s¡Create a new instance of a frame :param int channel_number: The frame type :param pika.Spec.Class.Method method: The AMQP Class.Method N(RRRt FRAME_METHODtmethod(RRR((s./usr/lib/python2.7/site-packages/pika/frame.pyR:scCs>|jjƒ}|jdtjd|jjƒƒ|j|ƒS(sPReturn the AMQP binary encoded value of the frame :rtype: str is>I(RtencodetinsertR R tINDEXR(RR((s./usr/lib/python2.7/site-packages/pika/frame.pyRDs"(RRRRRR(((s./usr/lib/python2.7/site-packages/pika/frame.pyR3s tHeadercBs&eZdZdZd„Zd„ZRS(s–Header frame object mapping. AMQP content header frames are mapped on top of this class for creating or accessing their data and attributes. RcCs,tj|tj|ƒ||_||_dS(s Create a new instance of a AMQP ContentHeader object :param int channel_number: The channel number for the frame :param int body_size: The number of bytes for the body :param pika.spec.BasicProperties props: Basic.Properties object N(RRRt FRAME_HEADERt body_sizet properties(RRR!tprops((s./usr/lib/python2.7/site-packages/pika/frame.pyRVs cCsD|jjƒ}|jdtjd|jj|jƒƒ|j|ƒS(sPReturn the AMQP binary encoded value of the frame :rtype: str is>HxxQ(R"RRR R RR!R(RR((s./usr/lib/python2.7/site-packages/pika/frame.pyRbs   (RRRRRR(((s./usr/lib/python2.7/site-packages/pika/frame.pyROs tBodycBs&eZdZdZd„Zd„ZRS(sŒBody frame object mapping class. AMQP content body frames are mapped on to this base class for getting/setting of attributes/data. R$cCs#tj|tj|ƒ||_dS(s_ Parameters: - channel_number: int - fragment: unicode or str N(RRRt FRAME_BODYtfragment(RRR&((s./usr/lib/python2.7/site-packages/pika/frame.pyRvscCs|j|jgƒS(sPReturn the AMQP binary encoded value of the frame :rtype: str (RR&(R((s./usr/lib/python2.7/site-packages/pika/frame.pyR€s(RRRRRR(((s./usr/lib/python2.7/site-packages/pika/frame.pyR$os t HeartbeatcBs&eZdZdZd„Zd„ZRS(s¢Heartbeat frame object mapping class. AMQP Heartbeat frames are mapped on to this class for a common access structure to the attributes/data values. R'cCstj|tjdƒdS(s,Create a new instance of the Heartbeat frameiN(RRRtFRAME_HEARTBEAT(R((s./usr/lib/python2.7/site-packages/pika/frame.pyR‘scCs|jtƒƒS(sPReturn the AMQP binary encoded value of the frame :rtype: str (Rtlist(R((s./usr/lib/python2.7/site-packages/pika/frame.pyR•s(RRRRRR(((s./usr/lib/python2.7/site-packages/pika/frame.pyR'‰s tProtocolHeadercBs/eZdZdZdddd„Zd„ZRS(sqAMQP Protocol header frame class which provides a pythonic interface for creating AMQP Protocol headers R*cCsOd|_|ptjd|_|p/tjd|_|pEtjd|_dS(sÞConstruct a Protocol Header frame object for the specified AMQP version :param int major: Major version number :param int minor: Minor version number :param int revision: Revision iÿÿÿÿiiiN(RRtPROTOCOL_VERSIONtmajortminortrevision(RR,R-R.((s./usr/lib/python2.7/site-packages/pika/frame.pyR¥s cCs&dtjdd|j|j|jƒS(sReturn the full AMQP wire protocol frame data representation of the ProtocolHeader frame :rtype: str tAMQPtBBBBi(R R R,R-R.(R((s./usr/lib/python2.7/site-packages/pika/frame.pyR³sN(RRRRtNoneRR(((s./usr/lib/python2.7/site-packages/pika/frame.pyR*žscCs$yK|dd!dkrJtjd|dƒ\}}}dt|||ƒfSWnttjfk rhdSXy&tjd|dd!ƒ\}}}Wntjk r¦dSXtj|tj }|t |ƒkrÑdS||d t tj ƒkrt jd ƒ‚n|tj|d !}|tjkrltjd |ƒd} tj| ƒ} | j|dƒ|t|| ƒfS|tjkrÏtjd |ƒ\} } } tj| ƒ}|j|d ƒ}|t|| |ƒfS|tjkrñ|t||ƒfS|tjkr |tƒfSt jd|ƒ‚dS(sReceives raw socket data and attempts to turn it into a frame. Returns bytes used to make the frame and the frame :param str data_in: The raw data stream :rtype: tuple(bytes consumed, frame) :raises: pika.exceptions.InvalidFrameError iiR/tBBBiis>BHLiisInvalid FRAME_END markers>Is>HHQi sUnknown frame type: %iN(iN(iN(iN(R t unpack_fromR*t IndexErrorterrorR1tunpackRtFRAME_HEADER_SIZEtFRAME_END_SIZER R RRtInvalidFrameErrorRtmethodstdecodeRR R#RR%R$R(R'(tdata_inR,R-R.RRt frame_sizet frame_endt frame_datat method_idRtclass_idtweightR!R"tout((s./usr/lib/python2.7/site-packages/pika/frame.pyt decode_frameÀs> & (RtloggingR tpikaRRRt getLoggerRtLOGGERt AMQPObjectRRRR$R'R*RD(((s./usr/lib/python2.7/site-packages/pika/frame.pyts  ' "