/usr/lib/python3.10/email/__pycache__
Edit: /usr/lib/python3.10/email/__pycache__/header.cpython-310.pyc (16462B)
o
…9j&^ ã @ sì d Z g d¢ZddlZddlZddlZddlZddlmZ ddlm Z
e
jZdZdZ
dZd Zd
ZdZdZed
ƒZedƒZe dejejB ¡Ze d¡Ze d¡ZejjZdd„ Z ddd„ZG dd„ dƒZG dd„ dƒZ G dd„ de!ƒZ"dS )z+Header encoding and decoding functionality.)ÚHeaderÚ
decode_headerÚmake_headeré N)ÚHeaderParseError)ÚcharsetÚ
ú ó z Ú éN z úus-asciizutf-8ai
=\? # literal =?
(?P
[^?]*?) # non-greedy up to the next ? is the charset
\? # literal ?
(?P[qQbB]) # either a "q" or a "b", case insensitive
\? # literal ?
(?P.*?) # non-greedy up to the next ?= is the encoded string
\?= # literal ?=
z[\041-\176]+:$z
\n[^ \t]+:c C s‚ t | dƒr
dd„ | jD ƒS t | ¡s| dfgS g }| ¡ D ]A}t |¡}d}|r^| d¡}|r5| ¡ }d}|r?| |ddf¡ |r\| d¡ ¡ }| d¡ ¡ }| d¡}| |||f¡ |s(qg } t
|ƒD ]%\}
}|
dkrŠ|d rŠ||
d d rŠ||
d d ¡ rŠ| |
d ¡ qet| ƒD ]}||= qg }
|D ][\}}}|du rª|
||f¡ q™|d
kr¼t
j |¡}|
||f¡ q™|dkrït|ƒd }|rÒ|d
dd| … 7 }zt
j |¡}W n tjyæ tdƒ‚w |
||f¡ q™td| ƒ‚g }d }}|
D ]:\}}t|tƒrt|dƒ}|du r|}|}qý||kr'| ||f¡ |}|}qý|du r3|t| 7 }qý||7 }qý| ||f¡ |S )a; Decode a message header value without converting charset.
Returns a list of (string, charset) pairs containing each of the decoded
parts of the header. Charset is None for non-encoded parts of the header,
otherwise a lower-case string containing the name of the character set
specified in the encoded string.
header may be a string that may or may not contain RFC2047 encoded words,
or it may be a Header object.
An email.errors.HeaderParseError may be raised when certain decoding error
occurs (e.g. a base64 decoding exception).
Ú_chunksc S s( g | ]\}}t |t|ƒ¡t|ƒf‘qS © )Ú_charsetÚ_encodeÚstr)Ú.0Ústringr r r ú#/usr/lib/python3.10/email/header.pyÚ
M s ÿz!decode_header..NTr Fé é ÚqÚbé z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)Úhasattrr
ÚecreÚsearchÚ
splitlinesÚsplitÚpopÚlstripÚappendÚlowerÚ enumerateÚisspaceÚreversedÚemailÚ
quoprimimeÚ
header_decodeÚlenÚ
base64mimeÚdecodeÚbinasciiÚErrorr ÚAssertionErrorÚ
isinstancer ÚbytesÚBSPACE)ÚheaderÚwordsÚlineÚpartsÚfirstÚ unencodedr ÚencodingÚencodedÚdroplistÚnÚwÚdÚ
decoded_wordsÚencoded_stringÚwordÚpaderrÚ collapsedÚ last_wordÚlast_charsetr r r r = s„
ÿ
õ€4€ÿ
r c C sF t |||d}| D ]\}}|durt|tƒst|ƒ}| ||¡ q |S )a¼ Create a Header from a sequence of pairs as returned by decode_header()
decode_header() takes a header value string and returns a sequence of
pairs of the format (decoded_string, charset) where charset is the string
name of the character set.
This function takes one of those sequence of pairs and returns a Header
instance. Optional maxlinelen, header_name, and continuation_ws are as in
the Header constructor.
)Ú
maxlinelenÚheader_nameÚcontinuation_wsN)r r0 ÚCharsetr" )Údecoded_seqrF rG rH ÚhÚsr r r r r œ s ÿr c @ sP e Zd Z ddd„Zdd„ Zdd „ Zdd
d„Zdd
„ Zddd„Zdd„ Z dS )r Nr Ústrictc C s~ |du rt }n t|tƒst|ƒ}|| _|| _g | _|dur$| |||¡ |du r*t}|| _|du r6d| _ dS t
|ƒd | _ dS )aD Create a MIME-compliant header that can contain many character sets.
Optional s is the initial header value. If None, the initial header
value is not set. You can later append to the header with .append()
method calls. s may be a byte string or a Unicode string, but see the
.append() documentation for semantics.
Optional charset serves two purposes: it has the same meaning as the
charset argument to the .append() method. It also sets the default
character set for all subsequent .append() calls that omit the charset
argument. If charset is not provided in the constructor, the us-ascii
charset is used both as s's initial charset and as the default for
subsequent .append() calls.
The maximum line length can be specified explicitly via maxlinelen. For
splitting the first line to a shorter value (to account for the field
header which isn't included in s, e.g. `Subject') pass in the name of
the field in header_name. The default maxlinelen is 78 as recommended
by RFC 2822.
continuation_ws must be RFC 2822 compliant folding whitespace (usually
either a space or a hard tab) which will be prepended to continuation
lines.
errors is passed through to the .append() call.
Nr r )ÚUSASCIIr0 rI r Ú_continuation_wsr
r" Ú
MAXLINELENÚ_maxlinelenÚ
_headerlenr* )ÚselfrL r rF rG rH Úerrorsr r r Ú__init__´ s
zHeader.__init__c C sÄ | ¡ g }d}d}| jD ]O\}}|}|tjkr$| dd¡}| dd¡}|rL|o.| |d ¡}|dvrA|dv r@|s@| t¡ d}n|dvrL|sL| t¡ |oT| |d ¡}|}| |¡ q
t
|¡S )z&Return the string value of the header.NÚasciiÚsurrogateescapeÚreplacer ©Nr éÿÿÿÿ)Ú
_normalizer
r ÚUNKNOWN8BITÚencoder, Ú _nonctextr" ÚSPACEÚEMPTYSTRINGÚjoin) rS ÚuchunksÚlastcsÚ lastspacer r ÚnextcsÚoriginal_bytesÚhasspacer r r Ú__str__ã s,
€
zHeader.__str__c C s |t | ƒkS ©N)r )rS Úotherr r r Ú__eq__ s z
Header.__eq__c C s´ |du r| j }n t|tƒst|ƒ}t|tƒs-|jpd}|t jkr'| dd¡}n| ||¡}|jp1d}|t jkrPz| ||¡ W n t yO |dkrK‚ t
}Y nw | j ||f¡ dS )a. Append a string to the MIME header.
Optional charset, if given, should be a Charset instance or the name
of a character set (which will be converted to a Charset instance). A
value of None (the default) means that the charset given in the
constructor is used.
s may be a byte string or a Unicode string. If it is a byte string
(i.e. isinstance(s, str) is false), then charset is the encoding of
that byte string, and a UnicodeError will be raised if the string
cannot be decoded with that charset. If s is a Unicode string, then
charset is a hint specifying the character set of the characters in
the string. In either case, when producing an RFC 2822 compliant
header using RFC 2047 rules, the string will be encoded using the
output codec of the charset. If the string cannot be encoded to the
output codec, a UnicodeError will be raised.
Optional `errors' is passed as the errors argument to the decode
call if s is a byte string.
Nr rW )
r r0 rI r Úinput_codecr\ r, Úoutput_codecr] ÚUnicodeEncodeErrorÚUTF8r
r" )rS rL r rT Ú
input_charsetÚoutput_charsetr r r r" s&