File: //lib/python3.12/__pycache__/quopri.cpython-312.pyc
�
    )!�h  �                   �   � d Z g d�ZdZdZdZdZ	 ddlmZmZ d	� Z
d
� Zdd�Zdd�Z
dd
�Zdd�Zd� Zd� Zd� Zedk(  r e�        yy# e	$ r dZdZY �8w xY w)zHConversions to/from quoted-printable transport encoding as per RFC 1521.)�encode�decode�encodestring�decodestring�   =�L   s   0123456789ABCDEF�    �    )�a2b_qp�b2a_qpNc                 �x   � t        | t        �      sJ �| dv r|S | dk(  r|S | t        k(  xs d| cxk  xr dk  nc  S )z�Decide whether a particular byte ordinal needs to be quoted.
    The 'quotetabs' flag indicates whether embedded tabs and spaces should be
    quoted.  Note that line-ending tabs and spaces are always encoded, as per
    RFC 1521.
    �    	�   _�    �   ~)�
isinstance�bytes�ESCAPE)�c�	quotetabs�headers      �/usr/lib/python3.12/quopri.py�needsquotingr      sI   � � �a������F�{����D�y��
���;�1�t�q�0�D�0�1�1r   c                 �   � t        | t        �      rt        | �      dk(  sJ �t        | �      } t        t        t
        | dz     t
        | dz     f�      z   S )zQuote a single character.�   �   )r   r   �len�ordr   �HEX�r   s    r   �quoter    $   sJ   � ��a���C��F�A�I�-�-��A��A��E�3�q�"�u�:�s�1�R�4�y�1�2�2�2r   c                 �  � t         �0| j                  �       }t        |||��      }|j                  |�       y|dfd�}d}| j                  �       x}r�g }	d}
|dd dk(  r|dd }d}
|D ]P  }t	        |f�      }t        |||�      rt
        |�      }|r|dk(  r|	j                  d�       �@|	j                  |�       �R |� ||�       t        j                  |	�      }t        |�      t        kD  r3 ||dt        d	z
   d
��       |t        d	z
  d }t        |�      t        kD  r�3|}| j                  �       x}r��|� ||
��       yy)av  Read 'input', apply quoted-printable encoding, and write to 'output'.
    'input' and 'output' are binary file objects. The 'quotetabs' flag
    indicates whether embedded tabs and spaces should be quoted. Note that
    line-ending tabs and spaces are always encoded, as per RFC 1521.
    The 'header' flag indicates whether we are encoding spaces as _ as per RFC
    1522.N�r   r   �   
c                 ��   � | r.| dd  dv r'|j                  | d d t        | dd  �      z   |z   �       y | dk(  r|j                  t        | �      |z   �       y |j                  | |z   �       y )N���r
   �   .)�writer    )�s�output�lineEnds      r   r'