§
    cÌcú   ã                   ó”   — d Z ddlm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	lmZ dd
lmZ ddlmZ  G d„ d¦  «        ZdS )zAA convenience class around email.Message and email.MIMEMultipart.é    )ÚMessage)ÚHeader)ÚMIMEMultipart)ÚMIMEText)Ú
formataddrÚ	parseaddré   )Ú__version__)ÚBzrBadParameterNotUnicode)Úsafe_unicode)ÚSMTPConnectionc                   óŠ   — e Zd ZdZdd„Zdd„Zdd„ZeZdd„Zd„ Z	d	„ Z
e	 	 dd
„¦   «         Zed„ ¦   «         Zed„ ¦   «         ZdS )ÚEmailMessageaf  An email message.

    The constructor needs an origin address, a destination address or addresses
    and a subject, and accepts a body as well. Add additional parts to the
    message with add_inline_attachment(). Retrieve the entire formatted message
    with as_string().

    Headers can be accessed with get() and msg[], and modified with msg[] =.
    Nc                 ó¬  — i | _         || _        g | _        t          |t          t
          f¦  «        r|g}g }|D ]*}|                     |                      |¦  «        ¦  «         Œ+d                     |¦  «        | j         d<   |                      |¦  «        | j         d<   t          t          |¦  «        ¦  «        | j         d<   dt          z  | j         d<   dS )a|  Create an email message.

        :param from_address: The origin address, to be put on the From header.
        :param to_address: The destination address of the message, to be put in
            the To header. Can also be a list of addresses.
        :param subject: The subject of the message.
        :param body: If given, the body of the message.

        All four parameters can be unicode strings or byte strings, but for the
        addresses and subject byte strings must be encoded in UTF-8. For the
        body any byte string will be accepted; if it's not ASCII or UTF-8,
        it'll be sent with charset=8-bit.
        z, ÚToÚFromÚSubjectzBazaar (%s)z
User-AgentN)Ú_headersÚ_bodyÚ_partsÚ
isinstanceÚbytesÚstrÚappendÚaddress_to_encoded_headerÚjoinr   r   Ú_breezy_version)ÚselfÚfrom_addressÚ
to_addressÚsubjectÚbodyÚto_addressesÚaddrs          ú6/usr/lib/python3/dist-packages/breezy/email_message.pyÚ__init__zEmailMessage.__init__)   sÖ   € ð ˆŒØˆŒ
ØˆŒå�j¥5­# ,Ñ/Ô/ð 	&Ø$˜ˆJàˆàð 	Fð 	FˆDØ×Ò × >Ò >¸tÑ DÔ DÑEÔEÐEÐEà"Ÿiši¨Ñ5Ô5ˆŒ�dÑØ $× >Ò >¸|Ñ LÔ LˆŒ�fÑÝ#)­,°wÑ*?Ô*?Ñ#@Ô#@ˆŒ�iÑ Ø&3µoÑ&EˆŒ�lÑ#Ð#Ð#ó    Úplainc                 ó    — | j         �)| j                             | j         ddf¦  «         d| _         | j                             |||f¦  «         dS )aV  Add an inline attachment to the message.

        :param body: A text to attach. Can be an unicode string or a byte
            string, and it'll be sent as ascii, utf-8, or 8-bit, in that
            preferred order.
        :param filename: The name for the attachment. This will give a default
            name for email programs to save the attachment.
        :param mime_subtype: MIME subtype of the attachment (eg. 'plain' for
            text/plain [default]).

        The attachment body will be displayed inline, so do not use this
        function to attach binary attachments.
        Nr(   )r   r   r   )r   r"   ÚfilenameÚmime_subtypes       r%   Úadd_inline_attachmentz"EmailMessage.add_inline_attachmentH   sU   € ð  Œ:Ð!ØŒK×Ò ¤
¨D°'Ð:Ñ;Ô;Ð;ØˆDŒJàŒ×Ò˜D (¨LÐ9Ñ:Ô:Ð:Ð:Ð:r'   c                 óh  — | j         sIt          ¦   «         }| j        �3|                      | j        ¦  «        \  }}|                     ||¦  «         nžt          ¦   «         }|�|                     |¦  «         | j         D ]q\  }}}|                      |¦  «        \  }}t          |||¦  «        }|�&|d         }|d|z  z  }|                     d|¦  «         d|d<   | 	                    |¦  «         Œrt          | j                             ¦   «         ¦  «        D ]
\  }	}
|
||	<   Œ|                     ¦   «         S )z¦Return the entire formatted message as a string.

        :param boundary: The boundary to use between MIME parts, if applicable.
            Used for tests.
        NzContent-Typez; name="%s"ÚinlinezContent-Disposition)r   r   r   Ústring_with_encodingÚset_payloadr   Úset_boundaryr   Úreplace_headerÚattachÚsortedr   ÚitemsÚ	as_string)r   ÚboundaryÚmsgobjr"   Úencodingr*   r+   ÚpayloadÚcontent_typeÚheaderÚvalues              r%   r6   zEmailMessage.as_string^   sO  € ð Œ{ð 	'Ý‘Y”YˆFØŒzÐ%Ø!%×!:Ò!:¸4¼:Ñ!FÔ!F‘��hØ×"Ò" 4¨Ñ2Ô2Ð2øå"‘_”_ˆFàÐ#Ø×#Ò# HÑ-Ô-Ð-à04´ð 
'ð 
'Ñ,��h Ø!%×!:Ò!:¸4Ñ!@Ô!@‘��hÝ" 4¨°xÑ@Ô@�àÐ'Ø#*¨>Ô#:�LØ  M°HÑ$<Ñ<�LØ×*Ò*¨>¸<ÑHÔHÐHà19�Ð-Ñ.Ø—’˜gÑ&Ô&Ð&Ð&õ $ D¤M×$7Ò$7Ñ$9Ô$9Ñ:Ô:ð 	#ð 	#‰MˆF�EØ"ˆF�6‰NˆNà×ÒÑ!Ô!Ð!r'   c                 ó8   — | j                              ||¦  «        S )z@Get a header from the message, returning failobj if not present.©r   Úget)r   r<   Úfailobjs      r%   r@   zEmailMessage.getƒ   s   € àŒ}× Ò  ¨Ñ1Ô1Ð1r'   c                 ó8   — | j                              |d¦  «        S )zÀGet a header from the message, returning None if not present.

        This method intentionally does not raise KeyError to mimic the behavior
        of __getitem__ in email.Message.
        Nr?   )r   r<   s     r%   Ú__getitem__zEmailMessage.__getitem__‡   s   € ð Œ}× Ò  ¨Ñ.Ô.Ð.r'   c                 ó8   — | j                              ||¦  «        S ©N)r   Ú__setitem__)r   r<   r=   s      r%   rF   zEmailMessage.__setitem__�   s   € ØŒ}×(Ò(¨°Ñ7Ô7Ð7r'   c                 ó    — t          ||||¦  «        }|�|                     |||¦  «         t          | ¦  «                             |¦  «         dS )a  Create an email message and send it with SMTPConnection.

        :param config: config object to pass to SMTPConnection constructor.

        See EmailMessage.__init__() and EmailMessage.add_inline_attachment()
        for an explanation of the rest of parameters.
        N)r   r,   r   Ú
send_email)	Úconfigr   r    r!   r"   Ú
attachmentÚattachment_filenameÚattachment_mime_subtypeÚmsgs	            r%   ÚsendzEmailMessage.send’   s_   € õ ˜<¨°W¸dÑCÔCˆØÐ!Ø×%Ò% jÐ2EØ&=ñ?ô ?ð ?å�vÑÔ×)Ò)¨#Ñ.Ô.Ð.Ð.Ð.r'   c           	      óæ   — t          | t          ¦  «        st          | ¦  «        ‚t          | ¦  «        \  }}|s|S t	          t          t          t          |¦  «        ¦  «        ¦  «        |f¦  «        S )z¦RFC2047-encode an address if necessary.

        :param address: An unicode string, or UTF-8 byte string.
        :return: A possibly RFC2047-encoded string.
        )r   r   r   r   r   r   r   )ÚaddressÚuserÚemails      r%   r   z&EmailMessage.address_to_encoded_header¢   sx   € õ ˜'¥3Ñ'Ô'ð 	5Ý+¨GÑ4Ô4Ð4õ   Ñ(Ô(‰ˆˆeØð 	'ØˆLå�s¥6­,°tÑ*<Ô*<Ñ#=Ô#=Ñ>Ô>Ø$ð&ñ 'ô 'ð 'r'   c                 ó^  — t          | t          ¦  «        r?	 |                      d¦  «        dfS # t          $ r |                      d¦  «        dfcY S w xY w	 |                      d¦  «         | dfS # t
          $ r3 	 |                      d¦  «         | dfcY S # t
          $ r	 | dfcY cY S w xY ww xY w)zðReturn a str object together with an encoding.

        :param string\_: A str or unicode object.
        :return: A tuple (str, encoding), where encoding is one of 'ascii',
            'utf-8', or '8-bit', in that preferred order.
        Úasciizutf-8z8-bit)r   r   ÚencodeÚUnicodeEncodeErrorÚdecodeÚUnicodeDecodeError)Ústring_s    r%   r/   z!EmailMessage.string_with_encoding´   s  € õ �g�sÑ#Ô#ð 	.ð:ØŸš wÑ/Ô/°Ð9Ð9øÝ%ð :ð :ð :ØŸš wÑ/Ô/°Ð9Ð9Ð9Ð9ð:øøøð.Ø—’˜wÑ'Ô'Ð'Ø Ð)Ð)øÝ%ð .ð .ð .ð.Ø—N’N 7Ñ+Ô+Ð+Ø# WÐ-Ð-Ð-Ð-øÝ)ð .ð .ð .Ø# WÐ-Ð-Ð-Ð-Ð-Ð-ð.øøøð	.øøøs?   —. ®!AÁAÁA/ Á/
B,Á:BÂB,ÂB(Â#B,Â'B(Â(B,rE   )Nr(   )NNr(   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r,   r6   Ú__str__r@   rC   rF   ÚstaticmethodrN   r   r/   © r'   r%   r   r      sô   € € € € € ðð ðFð Fð Fð Fð>;ð ;ð ;ð ;ð,!"ð !"ð !"ð !"ðF €Gð2ð 2ð 2ð 2ð/ð /ð /ð8ð 8ð 8ð ØIMØ?Fð/ð /ð /ñ „\ð/ð ð'ð 'ñ „\ð'ð" ð.ð .ñ „\ð.ð .ð .r'   r   N)r]   Úemail.messager   Úemail.headerr   Úemail.mime.multipartr   Úemail.mime.textr   Úemail.utilsr   r   Ú r
   r   Úerrorsr   Úosutilsr   Úsmtp_connectionr   r   r`   r'   r%   ú<module>rj      sò   ðð" HÐ Gà !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ø $Ð $Ð $Ð $Ð $Ð $Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø -Ð -Ð -Ð -Ð -Ð -Ø !Ð !Ð !Ð !Ð !Ð !Ø +Ð +Ð +Ð +Ð +Ð +ðq.ð q.ð q.ð q.ð q.ñ q.ô q.ð q.ð q.ð q.r'   