o
0iq @ s d Z g dZdZdZdZdZz
ddlmZmZ W n
e y% dZdZY nw d d
Z
dd ZdddZdddZ
dddZdddZdd Zdd Zdd ZedkrWe dS dS )zHConversions to/from quoted-printable transport encoding as per RFC 1521.)encodedecodeencodestringdecodestring =L s 0123456789ABCDEF )a2b_qpb2a_qpNc C sH t | tsJ | dv r
|S | dkr|S | tkp#d| ko dkn S )zDecide 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.
_ ~)
isinstancebytesESCAPE)c quotetabsheader r -/opt/alt/python310/lib64/python3.10/quopri.pyneedsquoting s "r c C sB t | trt| dks
J t| } ttt| d t| d f S )zQuote a single character. )r r lenordr HEXr r r r quote$ s r Fc
C s< t dur| }t |||d}|| dS |dfdd}d} | }|s'nig } d}
|dd dkr;|dd }d}
|D ]"}t|f}t|||rNt|}|rZ|d krZ| d
q=| | q=|durh|| t | }t
|tkr||dtd dd |td d }t
|tkss|}q |dur|||
d dS dS )
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.Nr r
c S sn | r| dd dv r| | d d t| dd | d S | dkr.| t| | d S | | | d S )Nr .)writer )soutputlineEndr r r r# ; s
*zencode.