3
‡Œðið
  ã               @   sª   d Z ddlmZ ddlmZ ddlmZ ddlmZ dddd	gZydd
lm	Z
 W n  ek
rp   ddlmZ
 Y nX ddlmZ dd„ Zdd„ Zdd	„ Zdd„ Zdd„ ZdS )z Encodings and related functions.é    )Úunicode_literals)Údivision)Úabsolute_import)ÚstrÚencode_7or8bitÚencode_base64Úencode_noopÚencode_quopri)Úencodebytes)Úencodestringc             C   s   t | dd�}|jddƒS )NT)Ú	quotetabsú z=20)Ú_encodestringÚreplace)ÚsÚenc© r   úA/tmp/pip-build-6m2fasei/future/future/backports/email/encoders.pyÚ_qencode   s    r   c             C   s,   | j ƒ }tt|ƒdƒ}| j|ƒ d| d< dS )zlEncode the message's payload in Base64.

    Also, add an appropriate Content-Transfer-Encoding header.
    ÚasciiÚbase64zContent-Transfer-EncodingN)Úget_payloadr   Ú_bencodeÚset_payload)ÚmsgÚorigÚencdatar   r   r   r   !   s    
c             C   s&   | j ƒ }t|ƒ}| j|ƒ d| d< dS )zvEncode the message's payload in quoted-printable.

    Also, add an appropriate Content-Transfer-Encoding header.
    zquoted-printablezContent-Transfer-EncodingN)r   r   r   )r   r   r   r   r   r   r	   ,   s    
c             C   s´   | j ƒ }|dkrd| d< dS y$t|tƒr4|jdƒ n
|jdƒ W nJ tk
rŠ   | jƒ }|o`|j}|r~|jƒ j	dƒr~d| d< nd| d< Y n
X d| d< t|tƒs°| j
|jddƒƒ dS )z9Set the Content-Transfer-Encoding header to 7bit or 8bit.NÚ7bitzContent-Transfer-Encodingr   z	iso-2022-Ú8bitÚsurrogateescape)r   Ú
isinstancer   ÚencodeÚdecodeÚUnicodeErrorÚget_charsetÚoutput_charsetÚlowerÚ
startswithr   )r   r   ÚcharsetZoutput_csetr   r   r   r   7   s"    



c             C   s(   | j ƒ }t|tƒs$| j|jddƒƒ dS )zDo nothing.r   r   N)r   r    r   r   r"   )r   r   r   r   r   r   S   s    
N)Ú__doc__Ú
__future__r   r   r   Zfuture.builtinsr   Ú__all__r   r
   r   ÚImportErrorr   Úquoprir   r   r   r	   r   r   r   r   r   r   Ú<module>   s$   