ž qyMaj!c@sัdZddlmZmZmZmZddlmZddlm Z ddddd d d d gZ eGd d„deƒƒZ e ƒZ e ` e jddƒZe jddƒZe jddddƒZdS(ucThis will be the home for the policy that hooks in the new code that adds all the email6 features. i(uPolicyuCompat32ucompat32u_extend_docstrings(u_has_surrogates(uHeaderRegistryuCompat32ucompat32uPolicyu EmailPolicyudefaultustrictuSMTPuHTTPcs’|EeZdZdZdZeƒZ‡fdd†Zdd„Zdd„Z d d „Z d d „Z d d„Z dd„Z ddd„Z‡S(u EmailPolicyu+ PROVISIONAL The API extensions enabled by this policy are currently provisional. Refer to the documentation for details. This policy adds new header parsing and folding algorithms. Instead of simple strings, headers are custom objects with custom attributes depending on the type of the field. The folding algorithm fully implements RFCs 2047 and 5322. In addition to the settable attributes listed above that apply to all Policies, this policy adds the following additional attributes: refold_source -- if the value for a header in the Message object came from the parsing of some source, this attribute indicates whether or not a generator should refold that value when transforming the message back into stream form. The possible values are: none -- all source values use original folding long -- source values that have any line that is longer than max_line_length will be refolded all -- all values are refolded. The default is 'long'. header_factory -- a callable that takes two arguments, 'name' and 'value', where 'name' is a header field name and 'value' is an unfolded header field value, and returns a string-like object that represents that header. A default header_factory is provided that understands some of the RFC5322 header field types. (Currently address fields and date fields have special treatment, while all other fields are treated as unstructured. This list will be completed before the extension is marked stable.) ulongc s9d|kr%tj|dtƒƒntƒj|dS(Nuheader_factory(uobjectu __setattr__uHeaderRegistryusuperu__init__(uselfukw(u __class__(u1/opt/alt/python33/lib64/python3.3/email/policy.pyu__init__Bs uEmailPolicy.__init__cCs|j|jS(uฟ+ The implementation for this class returns the max_count attribute from the specialized header class that would be used to construct a header of type 'name'. (uheader_factoryu max_count(uselfuname((u1/opt/alt/python33/lib64/python3.3/email/policy.pyuheader_max_countIsuEmailPolicy.header_max_countcCsU|djddƒ\}}|jdƒdj|dd…ƒ}||jdƒfS(uc+ The name is parsed as everything up to the ':' and returned unmodified. The value is determined by stripping leading whitespace off the remainder of the first line, joining all subsequent lines together, and stripping any trailing carriage return or linefeed characters. (This is the same as Compat32). iu:iu uNu (usplitulstripujoinurstrip(uselfu sourcelinesunameuvalue((u1/opt/alt/python33/lib64/python3.3/email/policy.pyuheader_source_parse[s &uEmailPolicy.header_source_parsecCs€t|dƒr4|jjƒ|jƒkr4||fSt|tƒrjt|jƒƒdkrjtdƒ‚n||j||ƒfS(uจ+ The name is returned unchanged. If the input value has a 'name' attribute and it matches the name ignoring case, the value is returned unchanged. Otherwise the name and value are passed to header_factory method, and the resulting custom header object is returned as the value. In this case a ValueError is raised if the input value contains CR or LF characters. unameiuDHeader values may not contain linefeed or carriage return characters( uhasattrunameuloweru isinstanceustrulenu splitlinesu ValueErroruheader_factory(uselfunameuvalue((u1/opt/alt/python33/lib64/python3.3/email/policy.pyuheader_store_parsehs * 'uEmailPolicy.header_store_parsecCs2t|dƒr|S|j|dj|jƒƒƒS(ui+ If the value has a 'name' attribute, it is returned to unmodified. Otherwise the name and the value with any linesep characters removed are passed to the header_factory method, and the resulting custom header object is returned. Any surrogateescaped bytes get turned into the unicode unknown-character glyph. unameu(uhasattruheader_factoryujoinu splitlines(uselfunameuvalue((u1/opt/alt/python33/lib64/python3.3/email/policy.pyuheader_fetch_parseys uEmailPolicy.header_fetch_parsecCs|j||ddƒS(u + Header folding is controlled by the refold_source policy setting. A value is considered to be a 'source value' if and only if it does not have a 'name' attribute (having a 'name' attribute means it is a header object of some sort). If a source value needs to be refolded according to the policy, it is converted into a custom header object by passing the name and the value with any linesep characters removed to the header_factory method. Folding of a custom header object is done by calling its fold method with the current policy. Source values are split into lines using splitlines. If the value is not to be refolded, the lines are rejoined using the linesep from the policy and returned. The exception is lines containing non-ascii binary data. In that case the value is refolded regardless of the refold_source setting, which causes the binary data to be CTE encoded using the unknown-8bit charset. u refold_binaryT(u_folduTrue(uselfunameuvalue((u1/opt/alt/python33/lib64/python3.3/email/policy.pyufold†suEmailPolicy.foldcCs1|j||d|jdkƒ}|jddƒS(u›+ The same as fold if cte_type is 7bit, except that the returned value is bytes. If cte_type is 8bit, non-ASCII binary data is converted back into bytes. Headers with binary data are not refolded, regardless of the refold_header setting, since there is no way to know whether the binary data consists of single byte characters or multibyte characters. u refold_binaryu7bituasciiusurrogateescape(u_folducte_typeuencode(uselfunameuvalueufolded((u1/opt/alt/python33/lib64/python3.3/email/policy.pyu fold_binary›s !uEmailPolicy.fold_binaryc st|dƒr|jd|ƒS|jr1|jn tdƒ‰|jƒ}|jdkpท|jdkoท|r‘t|dƒt|ƒdˆkpทt‡fdd †|d d…Dƒƒ}|sา|r๗t|ƒr๗|j |d j |ƒƒjd|ƒS|d |j j |ƒ|j S( Nunameupolicyuinfuallulongiic3s!|]}t|ƒˆkVqdS(N(ulen(u.0ux(umaxlen(u1/opt/alt/python33/lib64/python3.3/email/policy.pyu ฑsu$EmailPolicy._fold..iuu: ( uhasattrufoldumax_line_lengthufloatu splitlinesu refold_sourceulenuanyu_has_surrogatesuheader_factoryujoinulinesep(uselfunameuvalueu refold_binaryulinesurefold((umaxlenu1/opt/alt/python33/lib64/python3.3/email/policy.pyu_foldฉs *)%uEmailPolicy._foldF(u__name__u __module__u __qualname__u__doc__u refold_sourceuHeaderRegistryuheader_factoryu__init__uheader_max_countuheader_source_parseuheader_store_parseuheader_fetch_parseufoldu fold_binaryuFalseu_fold(u __locals__((u __class__u1/opt/alt/python33/lib64/python3.3/email/policy.pyu EmailPolicys)     uraise_on_defectulinesepu umax_line_lengthNT(u__doc__uemail._policybaseuPolicyuCompat32ucompat32u_extend_docstringsu email.utilsu_has_surrogatesuemail.headerregistryuHeaderRegistryu__all__u EmailPolicyudefaultuheader_factoryucloneuTrueustrictuSMTPuNoneuHTTP(((u1/opt/alt/python33/lib64/python3.3/email/policy.pyus$"  ข