ó oBú]c@seddlZddlmZddlmZddlmZejeƒZ de fd„ƒYZ dS(iÿÿÿÿN(tlog(t user_data(tutiltFiltercBs/eZed„Zd„Zd„Zd„ZRS(cCs||_||_dS(N(t wanted_idxt allow_none(tselfRR((sB/usr/lib/python2.7/site-packages/cloudinit/filters/launch_index.pyt__init__s cCsQ|jddƒ}|jr+|dkr+tStj|ƒ}||jkrMtStS(Ns Launch-Index(tgettNoneRtTrueRtsafe_intRtFalse(Rtmessagetmsg_idx((sB/usr/lib/python2.7/site-packages/cloudinit/filters/launch_index.pyt_selectscCsã|j|ƒsdS|jƒrÒ|jdtƒ}g}d}xC|D];}|j|ƒ}|dk ru|j|ƒqD|d7}qDWtjd||j ƒt j |ƒ}|j |ƒt t |ƒƒ|tj<|St j |ƒSdS(NtdecodeiisCDiscarding %s multipart messages which do not match launch index %s(RR t is_multipartt get_payloadR t _do_filtertappendtLOGtdebugRtcopyt set_payloadtstrtlentudtATTACHMENT_FIELD(RR t prev_msgstnew_msgst discardedtmt new_message((sB/usr/lib/python2.7/site-packages/cloudinit/filters/launch_index.pyR"s$      cCs |jdkr|S|j|ƒS(N(RR R(Rt root_message((sB/usr/lib/python2.7/site-packages/cloudinit/filters/launch_index.pytapply<s(t__name__t __module__R RRRR#(((sB/usr/lib/python2.7/site-packages/cloudinit/filters/launch_index.pyRs  ( Rt cloudinitRtloggingRRRt getLoggerR$RtobjectR(((sB/usr/lib/python2.7/site-packages/cloudinit/filters/launch_index.pyt s