Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/email/ |
| [Home] [System Details] [Kill Me] |
�
,�]c
@`sdZddlmZddlmZddlmZddlmZmZmZm Z m
Z
mZdddd d
ddd
ddg
Zddl
Z
ddlZddlmZmZmZdZdZdZed�e
d�D��Zej�Zx>edejd�ejd��D]Zee�ee<qWdeed�<x$ed�D]Zee�ee<qTWd�Zd�Zd�Zd�Zdd
�Z
d!�Z!d"�Z"d#d$�Z#d%ej$fd&��YZ%d'ed(�Z&ed)�Z'e'Z(e'Z)d*�Z*d+�Z+dS(,uFQuoted-printable
content transfer encoding per RFCs 2045-2047.
This module handles the content transfer encoding method defined in RFC
2045
to encode US ASCII-like 8-bit data called `quoted-printable'. It is
used to
safely encode text that is in a character set similar to the 7-bit US ASCII
character set, but that includes some 8-bit characters that are normally
not
allowed in email bodies or headers.
Quoted-printable is very space-inefficient for encoding binary files; use
the
email.base64mime module for that instead.
This module provides an interface to encode and decode both headers and
bodies
with quoted-printable encoding.
RFC 2045 defines a method for including character set information in an
`encoded-word' in a header. This method is commonly used for 8-bit
real names
in To:/From:/Cc: etc. fields, as well as Subject: lines.
This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding. To deal with the various line
wrapping issues, use the email.header module.
i(tunicode_literals(tdivision(tabsolute_import(tbytestchrtdicttinttrangetsuperubody_decodeubody_encodeubody_lengthudecodeudecodestringu
header_decodeu
header_encodeu
header_lengthuquoteuunquoteN(t
ascii_letterstdigitst hexdigitsu
u
ucc`s|]}|d|fVqdS(u=%02XN((t.0tc((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pys <genexpr><sis-!*+/uasciiu_u
s_
!"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ cC`st|�t|kS(u>Return
True if the octet should be escaped with header
quopri.(Rt_QUOPRI_HEADER_MAP(toctet((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytheader_checkNscC`st|�t|kS(u<Return
True if the octet should be escaped with body
quopri.(Rt_QUOPRI_BODY_MAP(R((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt
body_checkSscC`std�|D��S(u:Return a header
quoted-printable encoding length.
Note that this does not include any RFC 2047 chrome added by
`header_encode()`.
:param bytearray: An array of bytes (a.k.a. octets).
:return: The length in bytes of the byte array when it is encoded with
quoted-printable for headers.
cs`s|]}tt|�VqdS(N(tlenR(RR((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pys <genexpr>bs(tsum(t bytearray((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt
header_lengthXs
cC`std�|D��S(u�Return a body quoted-printable encoding
length.
:param bytearray: An array of bytes (a.k.a. octets).
:return: The length in bytes of the byte array when it is encoded with
quoted-printable for bodies.
cs`s|]}tt|�VqdS(N(RR(RR((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pys <genexpr>ls(R(R((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytbody_lengthescC`s�t|t�st|�}n|s:|j|j��nJt|d�t|�|krq|dc||7<n|j|j��dS(Ni����(t
isinstancetstrRtappendtlstripR(tLtstmaxlentextra((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt_max_appendos
cC`stt|dd!d��S(uDTurn a string in the form =AB to the
ASCII character with value
0xabiii(RR(R((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytunquotezscC`sdt|�S(Nu=%02X(tord(R
((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytquotesu
iso-8859-1cC`sI|s
dSg}x|D]}|jt|�qWd|tj|�fS(u�Encode a single
header line with quoted-printable (like) encoding.
Defined in RFC 2045, this `Q' encoding is similar to
quoted-printable, but
used specifically for email header fields to allow charsets with mostly
7
bit characters (and some 8 bit) to remain more or less readable in
non-RFC
2045 aware mail clients.
charset names the character set to use in the RFC 2046 header. It
defaults to iso-8859-1.
uu=?%s?q?%s?=(RRtEMPTYSTRINGtjoin(theader_bytestcharsettencodedR((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt
header_encode�s
t_body_accumulatorcB`sAeZd�Zd�Zd�Zd�Zdd�Zd�ZRS(cO`s0t�j||�||_||_|_dS(N(Rt__init__teolt
maxlinelentroom(tselfR-R,targstkw((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyR+�s cC`s&|j|�|jt|�8_dS(u%Add
string s to the accumulated
body.N(twriteR.R(R/R((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt write_str�s
cC`s
|j|j�|j|_dS(uWrite eol, then start new
line.N(R3R,R-R.(R/((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytnewline�scC`s|jd�|j�dS(u*Write
a soft break, then start a new
line.u=N(R3R4(R/((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytwrite_soft_break�s
icC`s7|jt|�|kr&|j�n|j|�dS(u.Add
a soft line break if needed, then write s.N(R.RR5R3(R/Rt
extra_room((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt
write_wrapped�s
cC`s�|s|j|dd�n�|dkr8|j|�nk|jdkr]|jt|��nF|jdkr�|j|�|j�n|j�|jt|��dS(NR6iu
ii(R7R.R2R#R5(R/R
tis_last_char((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt
write_char�s
(t__name__t
__module__R+R3R4R5R7R9(((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyR*�s iLcC`s
|dkrtd��n|s%|S|ddk}t||�}|j�}t|�d}x�t|�D]�\}}t|�d} xQt|�D]C\}
}tt|��r�t|�}n|j||
| k�q�W||ks�|rm|j �qmqmW|j
�S(u�Encode with quoted-printable, wrapping at maxlinelen characters.
Each line of encoded text will end with eol, which defaults to
"\n". Set
this to "\r\n" if you will be using the result of this
function directly
in an email.
Each line will be wrapped at, at most, maxlinelen characters before the
eol string (maxlinelen defaults to 76 characters, the maximum value
permitted by RFC 2045). Long lines will have the 'soft line
break'
quoted-printable character "=" appended to them, so the
decoded text will
be identical to the original text.
The minimum maxlinelen is 4 to have room for a quoted character
("=XX")
followed by a soft line break. Smaller values will generate a
ValueError.
iumaxlinelen must be at least 4i����u
i(t
ValueErrorR*t
splitlinesRt enumerateRR"R#R9R4tgetvalue(tbodyR-R,tlast_has_eoltencoded_bodytlinestlast_line_notline_notlinetlast_char_indextiR
((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytbody_encode�s"c C`sx|s
|Sd}x5|j�D]'}|j�}|sE||7}qnd}t|�}x�||krC||}|dkr�||7}|d7}n�|d|kr�|d7}qZnt|d|kr||dtkr||dtkr|t|||d!�7}|d7}n||7}|d7}||krZ||7}qZqZWqW|ddkrt|j|�rt|d
}n|S( u_Decode a quoted-printable string.
Lines are separated with eol, which defaults to \n.
uiu=iiii����u
(R=trstripRRR!tendswith(R(R,tdecodedRFRHtnR
((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pytdecodes8
8
cC`s|jd�}t|�S(uCTurn a match in the form =AB to
the ASCII character with value
0xabi(tgroupR!(tmatchR((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt_unquote_match7scC`s+|jdd�}tjdt|tj�S(uDecode
a string encoded with RFC 2045 MIME header `Q' encoding.
This function does not parse a full MIME header value encoded with
quoted-printable (like =?iso-8895-1?q?Hello_World?=) -- please use
the high level email.header class for that functionality.
u_u
u=[a-fA-F0-9]{2}(treplacetretsubRQtASCII(R((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt
header_decode>s(,t__doc__t
__future__RRRtfuture.builtinsRRRRRRt__all__RStiotstringR R
RtCRLFtNLR$RtcopyRtencodeR
R"RRRRR
R!R#R)tStringIOR*RIRNtbody_decodetdecodestringRQRV(((sE/usr/lib/python2.7/site-packages/future/backports/email/quoprimime.pyt<module>sT. -
610