U
    W¨+d]  ã                   @   s,   d Z ddlmZ ddlZG dd„ deƒZdS )z´
This module was contributed by Chris Moyer.  It provides a subclass of the
SQS Message class that supports YAML as the body of the message.

This module requires the yaml module.
é    )ÚMessageNc                       s2   e Zd ZdZd
‡ fdd„	Zdd„ Zdd	„ Z‡  ZS )ÚYAMLMessagezû
    The YAMLMessage class provides a YAML compatible message. Encoding and
    decoding are handled automaticaly.

    Access this message data like such:

    m.data = [ 1, 2, 3]
    m.data[0] # Returns 1

    This depends on the PyYAML package
    NÚ c                    s   d | _ tt| ƒ ||¡ d S ©N)ÚdataÚsuperr   Ú__init__)ÚselfÚqueueÚbodyZ	xml_attrs©Ú	__class__© ú;/tmp/pip-unpacked-wheel-dlxw5sjy/boto/contrib/ymlmessage.pyr   -   s    zYAMLMessage.__init__c                 C   s   t  |¡| _d S r   )ÚyamlZ	safe_loadr   )r	   r   r   r   r   Úset_body1   s    zYAMLMessage.set_bodyc                 C   s   t  | j¡S r   )r   Údumpr   )r	   r   r   r   Úget_body4   s    zYAMLMessage.get_body)Nr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ú__classcell__r   r   r   r   r       s   r   )r   Zboto.sqs.messager   r   r   r   r   r   r   Ú<module>   s   