AlkantarClanX12

Your IP : 3.133.137.10


Current Path : /proc/thread-self/root/opt/alt/python33/lib64/python3.3/email/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python33/lib64/python3.3/email/__pycache__/header.cpython-33.pyc

�
��f�^c@s^dZdddgZddlZddlZddlZddlZddlmZddlm	Z
e
jZdZd	Z
d
ZdZdZd
ZdZed�Zed�ZejdejejBejB�Zejd�Zejd�ZejjZdd�Zddd	dd�Z Gdd�d�Z!Gdd�d�Z"Gdd�de#�Z$dS(u+Header encoding and decoding functionality.uHeaderu
decode_headerumake_headeriN(uHeaderParseError(ucharsetu
u s iuiNu 	uus-asciiuutf-8ui
  =\?                   # 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 ?=
  u[\041-\176]+:$u
\n[^ \t]+:cCs�t|d�r#dd�|jD�Stj|�s?|dfgSg}x�|j�D]�}tj|�}d}x�|r|jd�}|r�|j	�}d}n|r�|j|ddf�n|rp|jd�j�}|jd�j�}|jd�}|j|||f�qpqpWqRWddl
}	g}
xnt|�D]`\}}|dkr>|dr>||ddr>||ddj�r>|
j|d�q>q>Wxt|
�D]
}
||
=q�Wg}x
|D]\}}}|dkr�|j||f�q�|dkr2tjj|�}|j||f�q�|d	kr�t|�d
}|ro|ddd
|�7}nytjj|�}Wn!tjk
r�td��Yq�X|j||f�q�td
|��q�Wg}d}}x�|D]�\}}t|t�rt|d�}n|dkr2|}|}q�||kr`|j||f�|}|}q�|dkr}|t|7}q�||7}q�W|j||f�|S(u;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).
    u_chunkscSs:g|]0\}}tj|t|��t|�f�qS((u_charsetu_encodeustr(u.0ustringucharset((u1/opt/alt/python33/lib64/python3.3/email/header.pyu
<listcomp>Ms	u!decode_header.<locals>.<listcomp>iNiiuqubiu===uBase64 decoding erroruUnexpected encoding: uraw-unicode-escapeTF(uhasattru_chunksuecreusearchuNoneu
splitlinesusplituTrueupopulstripuFalseuappendulowerusysu	enumerateuisspaceureverseduemailu
quoprimimeu
header_decodeulenu
base64mimeudecodeubinasciiuErroruHeaderParseErroruAssertionErroru
isinstanceustrubytesuBSPACE(uheaderuwordsulineupartsufirstu	unencodeducharsetuencodinguencodedusysudroplistunuwudu
decoded_wordsuencoded_stringuwordupaderru	collapsedu	last_wordulast_charset((u1/opt/alt/python33/lib64/python3.3/email/header.pyu
decode_header=s|	
		!@
		cCsqtd|d|d|�}xO|D]G\}}|dk	rYt|t�rYt|�}n|j||�q"W|S(u�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.
    u
maxlinelenuheader_nameucontinuation_wsN(uHeaderuNoneu
isinstanceuCharsetuappend(udecoded_sequ
maxlinelenuheader_nameucontinuation_wsuhusucharset((u1/opt/alt/python33/lib64/python3.3/email/header.pyumake_header�s	cBs�|EeZdZdddddddd�Zdd�Zdd�Zd	d
�Zdddd�Zd
d�Z	ddddd�Z
dd�ZdS(uHeaderu ustrictcCs�|dkrt}nt|t�s3t|�}n||_||_g|_|dk	rp|j|||�n|dkr�t}n||_	|dkr�d|_
nt|�d|_
dS(uDCreate 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.
        iiN(uNoneuUSASCIIu
isinstanceuCharsetu_charsetu_continuation_wsu_chunksuappendu
MAXLINELENu_maxlinelenu
_headerlenulen(uselfusucharsetu
maxlinelenuheader_nameucontinuation_wsuerrors((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__init__�s						uHeader.__init__c	Cs(|j�g}d}d}x�|jD]�\}}|}|tjkrn|jdd�}|jdd�}n|r�|o�|j|d�}|dkr�|d	kr�|r�|jt	�d}q�q�|d
kr�|r�|jt	�q�n|o|j|d�}|}|j|�q&Wt
j|�S(u&Return the string value of the header.uasciiusurrogateescapeureplaceiuus-asciiiN(Nuus-ascii(Nuus-ascii(Nuus-asciii����(u
_normalizeuNoneu_chunksu_charsetuUNKNOWN8BITuencodeudecodeu	_nonctextuappenduSPACEuEMPTYSTRINGujoin(	uselfuuchunksulastcsu	lastspaceustringucharsetunextcsuoriginal_bytesuhasspace((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__str__�s*

uHeader.__str__cCs|t|�kS(N(ustr(uselfuother((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__eq__su
Header.__eq__cCs||kS(N((uselfuother((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__ne__
su
Header.__ne__c
Cs	|dkr|j}nt|t�s6t|�}nt|t�s�|jpQd}|tjkrx|jdd�}q�|j||�}n|jp�d}|tjkr�y|j	||�Wq�t
k
r�|dkr��nt}Yq�Xn|jj
||f�dS(u.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.
        uus-asciiusurrogateescapeN(uNoneu_charsetu
isinstanceuCharsetustruinput_codecuUNKNOWN8BITudecodeuoutput_codecuencodeuUnicodeEncodeErroruUTF8u_chunksuappend(uselfusucharsetuerrorsu
input_charsetuoutput_charset((u1/opt/alt/python33/lib64/python3.3/email/header.pyuappend
s$
u
Header.appendcCs|j�p|dkS(u=True if string s is not a ctext character of RFC822.
        u(u)u\(u(u)u\(uisspace(uselfus((u1/opt/alt/python33/lib64/python3.3/email/header.pyu	_nonctext8suHeader._nonctextu;, 	u
c
Csh|j�|dkr"|j}n|dkr7d}nt|j||j|�}d}d}}x�|jD]�\}}	|dk	r�|o�|j|d�}ddl}
|d	kr�|s�|	d
kr�|j	�q�q�|	dkr�|r�|j	�q�n|o|j|d�}|	}d
}|j�}|rL|jd|d|	�n|jdd|	�x�|dd�D]�}|j
�|	jdk	r�|j|jd|j�|	�qp|j�}
|dt|�t|
��}|j||
|	�qpWt|�dkrl|j
�qlqlW|jr.|j	�n|j|�}tj|�rdtdj|���n|S(u�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.

        Optional maxlinelen specifies the maximum length of each generated
        line, exclusive of the linesep string.  Individual lines may be longer
        than maxlinelen if a folding point cannot be found.  The first line
        will be shorter by the length of the header name plus ": " if a header
        name was specified at Header construction time.  The default value for
        maxlinelen is determined at header construction time.

        Optional splitchars is a string containing characters which should be
        given extra weight by the splitting algorithm during normal header
        wrapping.  This is in very rough support of RFC 2822's `higher level
        syntactic breaks':  split points preceded by a splitchar are preferred
        during line splitting, with the characters preferred in the order in
        which they appear in the string.  Space and tab may be included in the
        string to indicate whether preference should be given to one over the
        other as a split point when other split chars do not appear in the line
        being split.  Splitchars does not affect RFC 2047 encoded lines.

        Optional linesep is a string to be used to separate the lines of
        the value.  The default value is the most useful for typical
        Python applications, but it can be set to \r\n to produce RFC-compliant
        line separators when needed.
        ii@BNuus-asciiiuu u8header value appears to contain an embedded header: {!r}(Nuus-ascii(Nuus-ascii(Nuus-asciii����F(u
_normalizeuNoneu_maxlinelenu_ValueFormatteru
_headerlenu_continuation_wsu_chunksu	_nonctextusysuadd_transitionuFalseu
splitlinesufeedunewlineuheader_encodingulstripulenu_stru_embeded_headerusearchuHeaderParseErroruformat(uselfu
splitcharsu
maxlinelenulinesepu	formatterulastcsuhasspaceu	lastspaceustringucharsetusysulinesulineuslineufwsuvalue((u1/opt/alt/python33/lib64/python3.3/email/header.pyuencode=sT!
	


 	
	u
Header.encodecCs�g}d}g}xm|jD]b\}}||krD|j|�q|dk	ro|jtj|�|f�n|g}|}qW|r�|jtj|�|f�n||_dS(N(uNoneu_chunksuappenduSPACEujoin(uselfuchunksulast_charsetu
last_chunkustringucharset((u1/opt/alt/python33/lib64/python3.3/email/header.pyu
_normalize�s	
uHeader._normalizeN(u__name__u
__module__u__qualname__uNoneu__init__u__str__u__eq__u__ne__uappendu	_nonctextuencodeu
_normalize(u
__locals__((u1/opt/alt/python33/lib64/python3.3/email/header.pyuHeader�s- +QcBs�|EeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS(u_ValueFormattercCsF||_||_t|�|_||_g|_t|�|_dS(N(u_maxlenu_continuation_wsulenu_continuation_ws_lenu_splitcharsu_linesu_Accumulatoru
_current_line(uselfu	headerlenumaxlenucontinuation_wsu
splitchars((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__init__�s				u_ValueFormatter.__init__cCs|j�|j|j�S(N(unewlineujoinu_lines(uselfulinesep((u1/opt/alt/python33/lib64/python3.3/email/header.pyu_str�s
u_ValueFormatter._strcCs
|jt�S(N(u_struNL(uself((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__str__�su_ValueFormatter.__str__cCs�|jj�}|dkr.|jj|�nt|j�dkr�|jj�ro|jdt|j�7<q�|jjt|j��n|jj�dS(Nu uii(u ui����(	u
_current_lineupopupushulenu	is_onlywsu_linesustruappendureset(uselfuend_of_line((u1/opt/alt/python33/lib64/python3.3/email/header.pyunewline�su_ValueFormatter.newlinecCs|jjdd�dS(Nu u(u
_current_lineupush(uself((u1/opt/alt/python33/lib64/python3.3/email/header.pyuadd_transition�su_ValueFormatter.add_transitioncCs|jdkr)|j|||j�dS|j||j��}y|jd�}Wntk
rldSYnX|dk	r�|j||�ny|j�}Wntk
r�dSYnX|j	�|j
j|j|�x%|D]}|j
j|j|�q�WdS(Ni(uheader_encodinguNoneu_ascii_splitu_splitcharsuheader_encode_linesu_maxlengthsupopu
IndexErroru
_append_chunkunewlineu
_current_lineupushu_continuation_wsu_linesuappend(uselfufwsustringucharsetu
encoded_linesu
first_lineu	last_lineuline((u1/opt/alt/python33/lib64/python3.3/email/header.pyufeed�s$
	
	

u_ValueFormatter.feedccs.|jt|j�Vx|j|jVqdS(N(u_maxlenulenu
_current_lineu_continuation_ws_len(uself((u1/opt/alt/python33/lib64/python3.3/email/header.pyu_maxlengths�su_ValueFormatter._maxlengthscCs�tjdtd||�}|dr>dg|dd�<n
|jd�x7tt|�gd�D]\}}|j||�qeWdS(Nu([u]+)iui(ureusplituFWSupopuzipuiteru
_append_chunk(uselfufwsustringu
splitcharsupartsupart((u1/opt/alt/python33/lib64/python3.3/email/header.pyu_ascii_split�s

&u_ValueFormatter._ascii_splitcCsr|jj||�t|j�|jkrnx|jD]�}x�t|jj�ddd�D]o}|j�r�|j|d}|r�|d|kr�Pq�n|j|dd}|r[|d|kr[Pq[q[Wq5Pq5W|jj�\}}|jj	dkr|j
�|sd}qn|jj||�dS|jj|�}|jj
t|j��|jj|�ndS(Niiu i����i����(u
_current_lineupushulenu_maxlenu_splitcharsurangeu
part_countuisspaceupopu
_initial_sizeunewlineupop_fromu_linesuappendustrureset(uselfufwsustringuchuiuprevpartupartu	remainder((u1/opt/alt/python33/lib64/python3.3/email/header.pyu
_append_chunks.&
u_ValueFormatter._append_chunkN(u__name__u
__module__u__qualname__u__init__u_stru__str__unewlineuadd_transitionufeedu_maxlengthsu_ascii_splitu
_append_chunk(u
__locals__((u1/opt/alt/python33/lib64/python3.3/email/header.pyu_ValueFormatter�s%u_ValueFormattercs�|EeZdZd�fdd�Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z
dd�Z�fdd�Z�S(u_Accumulatorics||_t�j�dS(N(u
_initial_sizeusuperu__init__(uselfuinitial_size(u	__class__(u1/opt/alt/python33/lib64/python3.3/email/header.pyu__init__$s	u_Accumulator.__init__cCs|j||f�dS(N(uappend(uselfufwsustring((u1/opt/alt/python33/lib64/python3.3/email/header.pyupush(su_Accumulator.pushcCs$||d�}g||d�<|S(N((uselfuiupopped((u1/opt/alt/python33/lib64/python3.3/email/header.pyupop_from+su_Accumulator.pop_fromcs#|j�dkrdSt�j�S(Niu(uu(u
part_countusuperupop(uself(u	__class__(u1/opt/alt/python33/lib64/python3.3/email/header.pyupop0su_Accumulator.popcCstdd�|D�|j�S(Ncss+|]!\}}t|�t|�VqdS(N(ulen(u.0ufwsupart((u1/opt/alt/python33/lib64/python3.3/email/header.pyu	<genexpr>6su'_Accumulator.__len__.<locals>.<genexpr>(usumu
_initial_size(uself((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__len__5su_Accumulator.__len__cCstjdd�|D��S(Ncss*|] \}}tj||f�VqdS(N(uEMPTYSTRINGujoin(u.0ufwsupart((u1/opt/alt/python33/lib64/python3.3/email/header.pyu	<genexpr>:su'_Accumulator.__str__.<locals>.<genexpr>(uEMPTYSTRINGujoin(uself((u1/opt/alt/python33/lib64/python3.3/email/header.pyu__str__9su_Accumulator.__str__cCs2|dkrg}n||dd�<d|_dS(Ni(uNoneu
_initial_size(uselfustartval((u1/opt/alt/python33/lib64/python3.3/email/header.pyureset=s	u_Accumulator.resetcCs&|jdko%|p%t|�j�S(Ni(u
_initial_sizeustruisspace(uself((u1/opt/alt/python33/lib64/python3.3/email/header.pyu	is_onlywsCsu_Accumulator.is_onlywscs
t�j�S(N(usuperu__len__(uself(u	__class__(u1/opt/alt/python33/lib64/python3.3/email/header.pyu
part_countFsu_Accumulator.part_countN(
u__name__u
__module__u__qualname__u__init__upushupop_fromupopu__len__u__str__uNoneuresetu	is_onlywsu
part_count(u
__locals__((u	__class__u1/opt/alt/python33/lib64/python3.3/email/header.pyu_Accumulator"su_Accumulatoru        (%u__doc__u__all__ureubinasciiuemail.quoprimimeuemailuemail.base64mimeuemail.errorsuHeaderParseErrorucharsetu_charsetuCharsetuNLuSPACEuBSPACEuSPACE8uEMPTYSTRINGu
MAXLINELENuFWSuUSASCIIuUTF8ucompileuVERBOSEu
IGNORECASEu	MULTILINEuecreufcreu_embeded_headeru
quoprimimeu_max_appendu
decode_headeruNoneumake_headeruHeaderu_ValueFormatterulistu_Accumulator(((u1/opt/alt/python33/lib64/python3.3/email/header.pyu<module>s<		`��