Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/thread-self/root/lib64/python2.7/email/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/lib64/python2.7/email/header.pyo

�
{fc@s6dZdddgZddlZddlZddlZddlZddlmZddl	m
Z
dZd	Zd
Z
d	dZdZd
Ze
d�Ze
d�ZejdejejBejB�Zejd�Zejd�ZejjZd�Zeed	d�Zdfd��YZd�Z d�Z!dS(s+Header encoding and decoding functionality.tHeadert
decode_headertmake_headeri����N(tHeaderParseError(tCharsets
t u iuiLsus-asciisutf-8s�
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  (?=[ \t]|$)           # whitespace or the end of the string
  s[\041-\176]+:$s
\n[^ \t]+:cCsGt|�}tj|�s(|dfgSg}d}x|j�D]�}tj|�so|j|df�qAntj|�}x�|r>|jd�j�}|r�|r�|dddkr�|ddt	|df|d<q�|j|df�n|r1g|dd!D]}|j
�^q	\}}|d}	d}|dkrXtjj
|	�}nm|dkr�t|	�d}
|
r�|	d	d|
 7}	nytjj|	�}Wq�tjk
r�t�q�Xn|dkr�|	}n|r|dd|kr|dd||ddf|d<q1|j||f�n|dd
5q�WqAW|S(s�Decode a message header value without converting charset.

    Returns a list of (decoded_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.

    An email.errors.HeaderParseError may be raised when certain decoding error
    occurs (e.g. a base64 decoding exception).
    tii����iitqtbis===iN(tstrtecretsearchtNonet
splitlinestappendtsplittpoptstriptSPACEtlowertemailt
quoprimimet
header_decodetlent
base64mimetdecodetbinasciitErrorR(theadertdecodedtdectlinetpartstunenctstcharsettencodingtencodedtpaderr((s$/usr/lib64/python2.7/email/header.pyR=sJ
	#,

	'cCsqtd|d|d|�}xO|D]G\}}|dk	rYt|t�rYt|�}n|j||�q"W|S(s�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.
    t
maxlinelentheader_nametcontinuation_wsN(RRt
isinstanceRR(tdecoded_seqR'R(R)thR"R#((s$/usr/lib64/python2.7/email/header.pyRys	cBs}eZd
d
d
d
ddd�Zd�Zd�Zd�Zd�Zd
dd�Zd�Z	d	�Z
d
�Zdd�ZRS(RtstrictcCs�|dkrt}nt|t�s3t|�}n||_||_t|jdt��}g|_	|dk	r�|j
|||�n|dkr�t}n|dkr�||_n|t|�d|_|||_
dS(s 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 explicit 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 76.

        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.
        s	iN(RtUSASCIIR*Rt_charsett_continuation_wsRtreplacetSPACE8t_chunksRt
MAXLINELENt
_firstlinelent_maxlinelen(tselfR"R#R'R(R)terrorstcws_expanded_len((s$/usr/lib64/python2.7/email/header.pyt__init__�s 					cCs
|j�S(sA synonym for self.encode().(tencode(R7((s$/usr/lib64/python2.7/email/header.pyt__str__�scCs�g}d}x�|jD]�\}}|}|r~|dkr_|dkr{|jt�d}q{q~|dkr~|jt�q~n|}|jt|t|���qWtj|�S(s)Helper for the built-in unicode function.sus-asciiN(Nsus-ascii(Nsus-ascii(Nsus-ascii(RR3RtUSPACEtunicodeR	tUEMPTYSTRINGtjoin(R7tuchunkstlastcsR"R#tnextcs((s$/usr/lib64/python2.7/email/header.pyt__unicode__�s
 cCs||j�kS(N(R;(R7tother((s$/usr/lib64/python2.7/email/header.pyt__eq__�scCs||kS(N((R7RE((s$/usr/lib64/python2.7/email/header.pyt__ne__�scCs|dkr|j}nt|t�s6t|�}n|dkr�t|t�r�|jp]d}t|||�}|jp~d}|j||�q�t|t�r�xTt	|t
fD]@}y&|jp�d}|j||�}PWq�tk
r�q�Xq�Wq�n|jj
||f�dS(s>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 true), 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 this case, when producing an RFC 2822 compliant header
        using RFC 2047 rules, the Unicode string will be encoded using the
        following charsets in order: us-ascii, the charset hint, utf-8.  The
        first character set not to provoke a UnicodeError is used.

        Optional `errors' is passed as the third argument to any unicode() or
        ustr.encode() call.
        t8bitsus-asciiN(RR/R*RR	tinput_codecR>toutput_codecR;R.tUTF8tUnicodeErrorR3R(R7R"R#R8tincodectustrtoutcodec((s$/usr/lib64/python2.7/email/header.pyR�s(
cCs0|j|�}|j|t�}|j|�}||krI||fgS|dkrb||fgS|dkr�|j||||�S|t|�kr�|}|j|| t�}	|j||t�}
nt|||�\}	}
|j|	�}|j|t�}||fg}
|
|j|
||j	|�S(NRHsus-ascii(
t
to_splittabletfrom_splittabletTruetencoded_header_lent_split_asciiRtFalset	_binsplitt_splitR6(R7R"R#R't
splitcharst
splittableR%telentsplitpnttfirsttlasttfsplittabletfencodedtchunk((s$/usr/lib64/python2.7/email/header.pyRW s$

cCs8t|||j|j|�}t||gt|��S(N(RTR6R0tzipR(R7R"R#tfirstlenRXtchunks((s$/usr/lib64/python2.7/email/header.pyRTNsc	Cs�g}x�|D]�\}}|s%q
n|dks@|jdkrI|}n|j|�}|rz|djd�rzd}nd}t||||�q
Wt|j}|j|�S(Ni����RR(Rtheader_encodingt
header_encodetendswitht_max_appendtNLR0R@(	R7t	newchunksR'RcRR#R"textratjoiner((s$/usr/lib64/python2.7/email/header.pyt_encode_chunksSs		
s;, cCs�g}|j}d}x~|jD]s\}}||d}||jd�krW|}n||j||||�7}|d\}}	|	j|�}qW|j||�}
tj|
�r�tdj|
���n|
S(s�Encode a message header into an RFC-compliant format.

        There are many issues involved in converting a given string for use in
        an email header.  Only certain character sets are readable in most
        email clients, and as header strings can only contain a subset of
        7-bit ASCII, care must be taken to properly convert and encode (with
        Base64 or quoted-printable) header strings.  In addition, there is a
        75-character length limit on any given encoded header field, so
        line-wrapping must be performed, even with double-byte character sets.

        This method will do its best to convert the string to the correct
        character set used in email, and encode and line wrap it safely with
        the appropriate scheme for that character set.

        If the given charset is not known or an error occurs during
        conversion, this function will return the header untouched.

        Optional splitchars is a string containing characters to split long
        ASCII lines on, in rough support of RFC 2822's `highest level
        syntactic breaks'.  This doesn't affect RFC 2047 encoded lines.
        iiRi����s8header value appears to contain an embedded header: {!r}(	R5R3RSRWRlt_embeded_headerRRtformat(R7RXRiR'tlastlenR"R#t	targetlent	lastchunktlastcharsettvalue((s$/usr/lib64/python2.7/email/header.pyR;vs			N(
t__name__t
__module__RR:R<RDRFRGRRWRTRlR;(((s$/usr/lib64/python2.7/email/header.pyR�s3				7	.		#cCs|g}|}xi|j�D][}|j�}t|�|krV|j|�|}qnx4|D]}||kr]Pq]q]W|j|�|}qtjd|�}	|dkr�|}
nd}
|
d}t|�}t|jdt��}
g}d}x]|	j|�D]L}|t	dt|�d�|}t|�}|}|dkr�|r�t|�dkr�t
j|d�r�|j|�||7}q|||kr:|r�|j|j|�|
�n||kr|dkrt
||||d�}|j|d �|dg}n	|g}|
t|d�}|}q|j|�||7}qW|r|j|j|��qqW|S(	Ns%s\s*s;,RRs	iii����(R
tlstripRRtretcompileR1R2RtmaxtfcretmatchR@RTtextend(R"RbtrestlenR)RXtlinestmaxlenRtchtcreteolRktjoinlentwslentthistlinelentparttcurlentpartlentonfirstlinetsubl((s$/usr/lib64/python2.7/email/header.pyRT�s^


	
!%

		
c
Cs�d}t|�}xf||krz||dd?}|j|| t�}|j|�}||krm|}q|d}qW|j|| t�}|j||t�}	||	fS(Nii(RRQRRRSRU(
RYR#R'titjtmR`tchunklenR\R]((s$/usr/lib64/python2.7/email/header.pyRV�s		("t__doc__t__all__RwRtemail.quoprimimeRtemail.base64mimetemail.errorsRt
email.charsetRRhRR=R2R?R4R.RKRxtVERBOSEt
IGNORECASEt	MULTILINER
RzRmRRgRRRRRTRV(((s$/usr/lib64/python2.7/email/header.pyt<module>s:	
		<�	F

Hacked By AnonymousFox1.0, Coded By AnonymousFox