ž ¦ÿfÑ•c@sødZddlZddlZddlmZddlmZmZddlm Z ddlm Z ddlm Z e dƒZee d ƒBZe d ƒZeeBZee d ƒZee d ƒZee d ƒBe d ƒZeeBZee dƒBZeeBZee dƒZdd„ZGdd„dƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZ Gdd„deƒZ!Gd d!„d!eƒZ"Gd"d#„d#eƒZ#Gd$d%„d%eƒZ$Gd&d'„d'eƒZ%Gd(d)„d)e%ƒZ&Gd*d+„d+eƒZ'Gd,d-„d-eƒZ(Gd.d/„d/eƒZ)Gd0d1„d1eƒZ*Gd2d3„d3eƒZ+Gd4d5„d5eƒZ,Gd6d7„d7eƒZ-Gd8d9„d9eƒZ.Gd:d;„d;eƒZ/Gd<d=„d=eƒZ0Gd>d?„d?eƒZ1Gd@dA„dAeƒZ2GdBdC„dCeƒZ3GdDdE„dEeƒZ4GdFdG„dGeƒZ5GdHdI„dIeƒZ6GdJdK„dKeƒZ7GdLdM„dMeƒZ8GdNdO„dOeƒZ9GdPdQ„dQeƒZ:GdRdS„dSeƒZ;GdTdU„dUe;ƒZ<GdVdW„dWeƒZ=GdXdY„dYeƒZ>GdZd[„d[eƒZ?Gd\d]„d]eƒZ@Gd^d_„d_eƒZAGd`da„daeAƒZBGdbdc„dceAƒZCGddde„deeƒZDGdfdg„dgeƒZEGdhdi„dieƒZFGdjdk„dkeGƒZHGdldm„dmeHƒZIGdndo„doeHƒZJGdpdq„dqeIƒZKeJd drƒZLeJdsdtƒZMeJdudvƒZNejOdwjPdxjQeƒƒƒjRZSejOdyjPdxjQeƒjTdzd{ƒjTd|d}ƒƒƒjUZVejOd~ƒjWZXejOdyjPdxjQeƒjTdzd{ƒjTd|d}ƒƒƒjUZYejOdyjPdxjQeƒjTdzd{ƒjTd|d}ƒƒƒjUZZejOdyjPdxjQeƒjTdzd{ƒjTd|d}ƒƒƒjUZ[dd€„Z\dd‚„Z]dƒd„„Z^d…d†„Z_d‡dˆ„Z`d‰dŠ„Zad‹dŒ„ZbddŽ„Zcdd„Zdd‘d’„Zed“d”„Zfd•d–„Zgd—d˜„Zhd™dš„Zid›dœ„Zjddž„ZkdŸd „Zld¡d¢„Zmd£d¤„Znd¥d¦„Zod§d¨„Zpd©dª„Zqd«d¬„Zrd­d®„Zsd¯d°„Ztd±d²„Zud³d´„Zvdµd¶„Zwd·d¸„Zxd¹dº„Zyd»d¼„Zzd½d¾„Z{d¿dÀ„Z|dÁd„Z}dÃdÄ„Z~dÅdÆ„ZdÇdÈ„Z€dÉdÊ„ZdËdÌ„Z‚dÍd΄ZƒdÏdЄZ„dÑdÒ„Z…dÓdÔ„Z†dÕdÖ„Z‡d×dØ„ZˆdÙdÚ„Z‰dÛdÜ„ZŠdÝdÞ„Z‹dßdà„ZŒdádâ„Zdãdä„ZŽdS(åulHeader value parser implementing various email-related RFC parsing rules. The parsing methods defined in this module implement various email related parsing rules. Principal among them is RFC 5322, which is the followon to RFC 2822 and primarily a clarification of the former. It also implements RFC 2047 encoded word decoding. RFC 5322 goes to considerable trouble to maintain backward compatibility with RFC 822 in the parse phase, while cleaning up the structure on the generation phase. This parser supports correct RFC 5322 generation by tagging white space as folding white space only when folding is allowed in the non-obsolete rule sets. Actually, the parser is even more generous when accepting input than RFC 5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages. Where possible deviations from the standard are annotated on the 'defects' attribute of tokens that deviate. The general structure of the parser follows RFC 5322, and uses its terminology where there is a direct correspondence. Where the implementation requires a somewhat different structure than that used by the formal grammar, new terms that mimic the closest existing terms are used. Thus, it really helps to have a copy of RFC 5322 handy when studying this code. Input to the parser is a string that has already been unfolded according to RFC 5322 rules. According to the RFC this unfolding is the very first step, and this parser leaves the unfolding step to a higher level message parser, which will have already detected the line breaks that need unfolding while determining the beginning and end of each header. The output of the parser is a TokenList object, which is a list subclass. A TokenList is a recursive data structure. The terminal nodes of the structure are Terminal objects, which are subclasses of str. These do not correspond directly to terminal objects in the formal grammar, but are instead more practical higher level combinations of true terminals. All TokenList and Terminal objects have a 'value' attribute, which produces the semantically meaningful value of that part of the parse subtree. The value of all whitespace tokens (no matter how many sub-tokens they may contain) is a single space, as per the RFC rules. This includes 'CFWS', which is herein included in the general class of whitespace tokens. There is one exception to the rule that whitespace tokens are collapsed into single spaces in values: in the value of a 'bare-quoted-string' (a quoted-string with no leading or trailing whitespace), any whitespace that appeared between the quotation marks is preserved in the returned value. Note that in all Terminal strings quoted pairs are turned into their unquoted values. All TokenList and Terminal objects also have a string value, which attempts to be a "canonical" representation of the RFC-compliant form of the substring that produced the parsed subtree, including minimal use of quoted pair quoting. Whitespace runs are not collapsed. Comment tokens also have a 'content' attribute providing the string found between the parens (including any nested comments) with whitespace preserved. All TokenList and Terminal objects have a 'defects' attribute which is a possibly empty list all of the defects found while creating the token. Defects may appear on any token in the tree, and a composite list of all defects in the subtree is available through the 'all_defects' attribute of any node. (For Terminal notes x.defects == x.all_defects.) Each object in a parse tree is called a 'token', and each has a 'token_type' attribute that gives the name from the RFC 5322 grammar that it represents. Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that may be produced: 'ptext'. A 'ptext' is a string of printable ascii characters. It is returned in place of lists of (ctext/quoted-pair) and (qtext/quoted-pair). XXX: provide complete list of token types. iN(u hexdigits(u namedtupleu OrderedDict(u_encoded_words(uerrors(uutilsu u(u ()<>@,:;.\"[]u.u."(u/?=u*'%u%cCs*dt|ƒjddƒjddƒdS(Nu"u\u\\u\"(ustrureplace(uvalue((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu quote_string_su quote_stringcBs_|EeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d d „Z d S(u_FoldedcCsC||_||_d|_d|_d|_g|_g|_dS(NiT( umaxlenupolicyulastlenuNoneu stickyspaceuTrueu firstlineudoneucurrent(uselfumaxlenupolicy((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__init__hs      u_Folded.__init__cCsC|jj|jƒ|jj|jjƒ|jjƒd|_dS(Ni(udoneuextenducurrentuappendupolicyulinesepuclearulastlen(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyunewlineqs u_Folded.newlinecCs|jr|jƒndS(N(ucurrentunewline(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyufinalizews u_Folded.finalizecCsdj|jƒS(Nu(ujoinudone(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__str__{su_Folded.__str__cCs|jj|ƒdS(N(ucurrentuappend(uselfustoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuappend~su_Folded.appendcCsª|dkrt|ƒ}nt|ƒ}|jdk r7t|jƒ}|j|||jkr¶|jj|jƒ|j|7_|jj|ƒ|j|7_d|_d|_ dS|j r|j ƒ}|dk rÿ|jt|ƒ7_|t|ƒ7}n|j |ƒdS|rè|d|jkrè|j|}d|koM|knr˜||}|jj|jd|…ƒ|j|d…|_|}n|jƒ|jj|jƒ|jj|ƒ|||_d|_d|_ dS|j sþ|jƒn|jj|jƒ|jj|ƒd|_d|_ dS|j||jkrp|jj|ƒ|j|7_dS||jkr¦|jƒ|jj|ƒ||_dSdS(NiiFT(uNoneustrulenu stickyspaceulastlenumaxlenucurrentuappenduFalseu firstlineuTrueuhas_fwsupop_leading_fwsu_foldunewline(uselfutokenustokenulustickyspace_lenuwsumarginutrim((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuappend_if_fitssf                     u_Folded.append_if_fitsN( u__name__u __module__u __qualname__u__init__unewlineufinalizeu__str__uappenduNoneuappend_if_fits(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu_Foldedfs     u_Foldedcs1|EeZdZd(Z‡fdd†Zdd„Z‡fdd†Zedd„ƒZ ed d „ƒZ ed d „ƒZ d d„Z dd„Z dd„Zedd„ƒZdd„Zedd„ƒZdd„Zdd„Zdd„Zdd „Zd!d"d#„Zd!d$d%„Zd!d&d'„Z‡S()u TokenListcs tƒj||Žg|_dS(N(usuperu__init__udefects(uselfuargsukw(u __class__(u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__init__¾suTokenList.__init__cCsdjdd„|DƒƒS(Nucss|]}t|ƒVqdS(N(ustr(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu Ãsu$TokenList.__str__..(ujoin(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__str__ÂsuTokenList.__str__csdj|jjtƒjƒƒS(Nu{}({})(uformatu __class__u__name__usuperu__repr__(uself(u __class__(u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__repr__ÅsuTokenList.__repr__cCsdjdd„|DƒƒS(Nucss!|]}|jr|jVqdS(N(uvalue(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu Ësu"TokenList.value..(ujoin(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuvalueÉsuTokenList.valuecCstdd„|Dƒ|jƒS(Ncss|]}|jVqdS(N(u all_defects(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu Ïsu(TokenList.all_defects..(usumudefects(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu all_defectsÍsuTokenList.all_defectsccsÓ|j}g}x|D]…}|jƒre|ret|ƒdkrJ|dn ||ƒV|jƒqen|jƒ}|j|ƒ|r||ƒV|g}qqW|rÏt|ƒdkrÁ|dn ||ƒVndS(Nii(u __class__ustartswith_fwsulenuclearupop_trailing_wsuappend(uselfuklassuthisutokenuend_ws((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyupartsøs   '   uTokenList.partscCs|djƒS(Ni(ustartswith_fws(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyustartswith_fws suTokenList.startswith_fwscCs.|djdkr |jdƒS|djƒS(Niufws(u token_typeupopupop_leading_fws(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyupop_leading_fws s uTokenList.pop_leading_fwscCs.|djdkr |jdƒS|djƒS(Niucfwsiÿÿÿÿiÿÿÿÿiÿÿÿÿ(u token_typeupopupop_trailing_ws(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyupop_trailing_wss uTokenList.pop_trailing_wscCs"x|D]}|jrdSqWdS(NTF(uhas_fwsuTrueuFalse(uselfupart((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuhas_fwss  uTokenList.has_fwscCs|djƒS(Ni(uhas_leading_comment(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuhas_leading_commentsuTokenList.has_leading_commentcCs+g}x|D]}|j|jƒq W|S(N(uextenducomments(uselfucommentsutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyucomments s uTokenList.commentscCsE|jptdƒ}t||ƒ}|j|ƒ|jƒt|ƒS(Nu+inf(umax_line_lengthufloatu_Foldedu_foldufinalizeustr(uselfupolicyumaxlenufolded((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyufold's   uTokenList.foldcCs‰g}|jƒ}|r(|j|ƒn|djdkrJ|jdƒnd}|jtjt|ƒ|ƒƒ|j|ƒdj|ƒS(Niufwsuiÿÿÿÿiÿÿÿÿ(upop_leading_fwsuappendu token_typeupopu_ewuencodeustrujoin(uselfucharseturesuwsutrailer((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuas_encoded_word/s ( uTokenList.as_encoded_wordcCs=g}x'|D]}|j|j||ƒƒq Wdj|ƒS(Nu(uappendu cte_encodeujoin(uselfucharsetupolicyuresupart((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu cte_encode;s uTokenList.cte_encodec Cs;x4|jD])}t|ƒ}t|ƒ}yt|ƒjdƒWn^tk rŸtdd„|jDƒƒrtd}nd}|j||jƒ}t|ƒ}YnX|j ||ƒr¸q n|j ƒ}|dk rt|j dƒƒ|_ |j |ƒrq qn|jr|j|ƒq n|j|ƒ|jƒq WdS(Nuus-asciicss!|]}t|tjƒVqdS(N(u isinstanceuerrorsuUndecodableBytesDefect(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu Hsu"TokenList._fold..u unknown-8bituutf-8i(upartsustrulenuencodeuUnicodeEncodeErroruanyu all_defectsu cte_encodeupolicyuappend_if_fitsupop_leading_fwsuNoneupopu stickyspaceuhas_fwsu_folduappendunewline(uselfufoldedupartutstrutlenucharsetuws((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu_foldAs0           uTokenList._folducCs#tdj|jddƒƒƒdS(Nu uindentu(uprintujoinu_pp(uselfuindent((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyupprintcsuTokenList.pprintcCsdj|jddƒƒS(Nu uindentu(ujoinu_pp(uselfuindent((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuppstrfsuTokenList.ppstrccs®dj||jj|jƒVxU|D]M}t|dƒsN|dj|ƒVq$x |j|dƒD] }|VqbWq$W|jr“dj|jƒ}nd}dj||ƒVdS(Nu{}{}/{}(u_ppu* !! invalid element in token list: {!r}u u Defects: {}uu{}){}(uformatu __class__u__name__u token_typeuhasattru_ppudefects(uselfuindentutokenulineuextra((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu_ppis       u TokenList._ppN(u__name__u __module__u __qualname__uNoneu token_typeu__init__u__str__u__repr__upropertyuvalueu all_defectsupartsustartswith_fwsupop_leading_fwsupop_trailing_wsuhas_fwsuhas_leading_commentucommentsufolduas_encoded_wordu cte_encodeu_foldupprintuppstru_pp(u __locals__((u __class__u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu TokenListºs( +       "u TokenListcBs8|EeZdZedd„ƒZedd„ƒZdS(uWhiteSpaceTokenListcCsdS(Nu ((uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuvalue~suWhiteSpaceTokenList.valuecCsdd„|DƒS(NcSs(g|]}|jdkr|j‘qS(ucomment(u token_typeucontent(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu „s u0WhiteSpaceTokenList.comments..((uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyucomments‚suWhiteSpaceTokenList.commentsN(u__name__u __module__u __qualname__upropertyuvalueucomments(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuWhiteSpaceTokenList|suWhiteSpaceTokenListcBs2|EeZdZdZdd„Zdd„ZdS(uUnstructuredTokenListu unstructuredc Cs)d}x|jD]}t|ƒ}d }yt|ƒjdƒWntk rUtdd„|jDƒƒrtd}nd}|dk r<tdj |j |d…|gƒƒj |ƒ}t dd„|j d|…Dƒƒ}t|ƒ} t | ƒ} || |jkr<|j |d…=|j| ƒ|| |_wq<n|j |ƒ}d }YnX|j||ƒrŠ|rt |j ƒd}qqn|s–|r©|j|ƒqn|jƒ} | dk rèt| ƒ|_|j|ƒrèqqèn|jr|j|ƒqn|j|ƒ|jƒd}qWdS( Nuus-asciicss!|]}t|tjƒVqdS(N(u isinstanceuerrorsuUndecodableBytesDefect(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu “su.UnstructuredTokenList._fold..u unknown-8bituutf-8ucss|]}t|ƒVqdS(N(ulen(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu siFT(uNoneupartsustruFalseuencodeuUnicodeEncodeErroruanyu all_defectsuget_unstructuredujoinucurrentuas_encoded_wordusumulenumaxlenuappendulastlenuTrueuappend_if_fitsu _fold_as_ewupop_leading_fwsu stickyspaceuhas_fwsufoldunewline( uselfufoldedulast_ewupartutstruis_ewucharsetuchunku oldlastlenuschunkulchunkuws((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu_fold‹sT     /&               uUnstructuredTokenList._foldc CsÖg}d}xº|D]²}t|ƒ}y|jdƒ|j|ƒWqtk rÄ|dkr‡|j|j||ƒƒt|ƒ}n9tdj||d…|gƒƒ}|j|j ƒƒYqXqWdj|ƒS(Nuus-asciiu( uNoneustruencodeuappenduUnicodeEncodeErroru cte_encodeulenuget_unstructuredujoinuas_encoded_word(uselfucharsetupolicyuresulast_ewupartuspartutl((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu cte_encode¿s     &u UnstructuredTokenList.cte_encodeN(u__name__u __module__u __qualname__u token_typeu_foldu cte_encode(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuUnstructuredTokenList‡s 4uUnstructuredTokenListcBs2|EeZdZdZdd„Zdd„ZdS(uPhraseuphrasecCsXd}xK|jD]@}t|ƒ}t|ƒ}d }yt|ƒjdƒWn–tk rãtdd„|jDƒƒr€d}nd}|dk r¾|j ƒ r¾|d j dkrÍ|j rÍ|j dƒ}nd}xFt |ƒD]8\} } | j d kràt| dd…ƒ|| åsuPhrase._fold..u unknown-8bituutf-8iucfwsuubare-quoted-stringcss|]}t|ƒVqdS(N(ulen(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu su quoted-stringFiÿÿÿÿiÿÿÿÿT(uNoneupartsustrulenuFalseuencodeuUnicodeEncodeErroruanyu all_defectsuhas_leading_commentu token_typeucommentsupopu enumerateuUnstructuredTokenListuget_unstructuredujoinucurrentuas_encoded_wordumaxlenuappendusumulastlenuTrueuappend_if_fitsu_fold(uselfufoldedulast_ewupartutstrutlenuhas_ewucharsetu remainderuiutokenuchunkuschunkulchunk((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu_foldÕsL      !/       u Phrase._foldc Cs«g}d}d}x‰|D]}t|ƒ}y|jdƒ|j|ƒWn&tk rqd}|dkrŸ|jsƒt|ƒ}n|j|j ||ƒƒnÎ|j ƒsm|d j dkrÙ|jrÙ|j d ƒ}nd}xFt |ƒD]8\} } | j dkrìt| dd…ƒ|| uPhrasecBs|EeZdZdZdS(uWorduwordN(u__name__u __module__u __qualname__u token_type(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuWord0suWordcBs&|EeZdZdZdd„ZdS(uCFWSListucfwscCs t|jƒS(N(uboolucomments(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuhas_leading_comment9suCFWSList.has_leading_commentN(u__name__u __module__u __qualname__u token_typeuhas_leading_comment(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuCFWSList5suCFWSListcBs|EeZdZdZdS(uAtomuatomN(u__name__u __module__u __qualname__u token_type(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuAtom=suAtomcBs|EeZdZdZdS(uTokenutokenN(u__name__u __module__u __qualname__u token_type(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuTokenBsuTokencBs>|EeZdZdZdZdZdZedd„ƒZ dS(u EncodedWordu encoded-wordcCs3|jdk r|jStjt|ƒ|jƒdS(N(ucteuNoneu_ewuencodeustrucharset(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuencodedNsuEncodedWord.encodedN( u__name__u __module__u __qualname__u token_typeuNoneucteucharsetulangupropertyuencoded(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu EncodedWordGs u EncodedWordcBsP|EeZdZdZedd„ƒZedd„ƒZedd„ƒZdS( u QuotedStringu quoted-stringcCs+x$|D]}|jdkr|jSqWdS(Nubare-quoted-string(u token_typeuvalue(uselfux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyucontentZs uQuotedString.contentcCsYg}xC|D];}|jdkr8|jt|ƒƒq |j|jƒq Wdj|ƒS(Nubare-quoted-stringu(u token_typeuappendustruvalueujoin(uselfuresux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu quoted_value`s  uQuotedString.quoted_valuecCs+x$|D]}|jdkr|jSqWdS(Nubare-quoted-string(u token_typeuvalue(uselfutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyustripped_valuejs uQuotedString.stripped_valueN(u__name__u __module__u __qualname__u token_typeupropertyucontentu quoted_valueustripped_value(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu QuotedStringVs u QuotedStringcBs8|EeZdZdZdd„Zedd„ƒZdS(uBareQuotedStringubare-quoted-stringcCs tdjdd„|DƒƒƒS(Nucss|]}t|ƒVqdS(N(ustr(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu vsu+BareQuotedString.__str__..(u quote_stringujoin(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__str__usuBareQuotedString.__str__cCsdjdd„|DƒƒS(Nucss|]}t|ƒVqdS(N(ustr(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu zsu)BareQuotedString.value..(ujoin(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuvaluexsuBareQuotedString.valueN(u__name__u __module__u __qualname__u token_typeu__str__upropertyuvalue(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuBareQuotedStringqs uBareQuotedStringcBsV|EeZdZdZdd„Zdd„Zedd„ƒZedd „ƒZd S( uCommentucommentcs8djtdg‡fdd†ˆDƒdgggƒƒS(Nuu(csg|]}ˆj|ƒ‘qS((uquote(u.0ux(uself(u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu „s u#Comment.__str__..u)(ujoinusum(uself((uselfu?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu__str__s   uComment.__str__cCsG|jdkrt|ƒSt|ƒjddƒjddƒjddƒS(Nucommentu\u\\u(u\(u)u\)(u token_typeustrureplace(uselfuvalue((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuquoteˆs   u Comment.quotecCsdjdd„|DƒƒS(Nucss|]}t|ƒVqdS(N(ustr(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu ‘su"Comment.content..(ujoin(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyucontentsuComment.contentcCs |jgS(N(ucontent(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyucomments“suComment.commentsN( u__name__u __module__u __qualname__u token_typeu__str__uquoteupropertyucontentucomments(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuComment}s   uCommentcBsP|EeZdZdZedd„ƒZedd„ƒZedd„ƒZdS( u AddressListu address-listcCsdd„|DƒS(NcSs%g|]}|jdkr|‘qS(uaddress(u token_type(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu s u)AddressList.addresses..((uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu addresses›suAddressList.addressescCstdd„|DƒgƒS(Ncss'|]}|jdkr|jVqdS(uaddressN(u token_typeu mailboxes(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu ¡su(AddressList.mailboxes..(usum(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu mailboxesŸs uAddressList.mailboxescCstdd„|DƒgƒS(Ncss'|]}|jdkr|jVqdS(uaddressN(u token_typeu all_mailboxes(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu ¦su,AddressList.all_mailboxes..(usum(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu all_mailboxes¤s uAddressList.all_mailboxesN(u__name__u __module__u __qualname__u token_typeupropertyu addressesu mailboxesu all_mailboxes(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu AddressList—su AddressListcBsP|EeZdZdZedd„ƒZedd„ƒZedd„ƒZdS( uAddressuaddresscCs"|djdkr|djSdS(Niugroup(u token_typeu display_name(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu display_name®suAddress.display_namecCs@|djdkr|dgS|djdkr5gS|djS(Niumailboxuinvalid-mailbox(u token_typeu mailboxes(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu mailboxes³s  uAddress.mailboxescCsG|djdkr|dgS|djdkr<|dgS|djS(Niumailboxuinvalid-mailbox(u token_typeu all_mailboxes(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu all_mailboxes»s   uAddress.all_mailboxesN(u__name__u __module__u __qualname__u token_typeupropertyu display_nameu mailboxesu all_mailboxes(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuAddressªsuAddresscBs>|EeZdZdZedd„ƒZedd„ƒZdS(u MailboxListu mailbox-listcCsdd„|DƒS(NcSs%g|]}|jdkr|‘qS(umailbox(u token_type(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu És u)MailboxList.mailboxes..((uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu mailboxesÇsuMailboxList.mailboxescCsdd„|DƒS(NcSs%g|]}|jdkr|‘qS(umailboxuinvalid-mailbox(umailboxuinvalid-mailbox(u token_type(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu Ís u-MailboxList.all_mailboxes..((uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu all_mailboxesËsuMailboxList.all_mailboxesN(u__name__u __module__u __qualname__u token_typeupropertyu mailboxesu all_mailboxes(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu MailboxListÃsu MailboxListcBs>|EeZdZdZedd„ƒZedd„ƒZdS(u GroupListu group-listcCs)| s|djdkrgS|djS(Niu mailbox-list(u token_typeu mailboxes(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu mailboxesÕsuGroupList.mailboxescCs)| s|djdkrgS|djS(Niu mailbox-list(u token_typeu all_mailboxes(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu all_mailboxesÛsuGroupList.all_mailboxesN(u__name__u __module__u __qualname__u token_typeupropertyu mailboxesu all_mailboxes(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu GroupListÑsu GroupListcBsP|EeZdZdZedd„ƒZedd„ƒZedd„ƒZdS( uGroupugroupcCs"|djdkrgS|djS(Niu group-list(u token_typeu mailboxes(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu mailboxesæsuGroup.mailboxescCs"|djdkrgS|djS(Niu group-list(u token_typeu all_mailboxes(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu all_mailboxesìsuGroup.all_mailboxescCs |djS(Ni(u display_name(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu display_nameòsuGroup.display_nameN(u__name__u __module__u __qualname__u token_typeupropertyu mailboxesu all_mailboxesu display_name(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuGroupâsuGroupcBst|EeZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZed d „ƒZ d S( uNameAddru name-addrcCs!t|ƒdkrdS|djS(Nii(ulenuNoneu display_name(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu display_nameûsuNameAddr.display_namecCs |djS(Niiÿÿÿÿ(u local_part(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu local_partsuNameAddr.local_partcCs |djS(Niiÿÿÿÿ(udomain(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyudomainsuNameAddr.domaincCs |djS(Niiÿÿÿÿ(uroute(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuroute suNameAddr.routecCs |djS(Niiÿÿÿÿ(u addr_spec(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu addr_spec suNameAddr.addr_specN( u__name__u __module__u __qualname__u token_typeupropertyu display_nameu local_partudomainurouteu addr_spec(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuNameAddr÷s uNameAddrcBsb|EeZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZd S( u AngleAddru angle-addrcCs+x$|D]}|jdkr|jSqWdS(Nu addr-spec(u token_typeu local_part(uselfux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu local_parts uAngleAddr.local_partcCs+x$|D]}|jdkr|jSqWdS(Nu addr-spec(u token_typeudomain(uselfux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyudomains uAngleAddr.domaincCs+x$|D]}|jdkr|jSqWdS(Nu obs-route(u token_typeudomains(uselfux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuroute"s uAngleAddr.routecCs/x(|D]}|jdkr|jSqWdSdS(Nu addr-specu<>(u token_typeu addr_spec(uselfux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu addr_spec(s  uAngleAddr.addr_specN( u__name__u __module__u __qualname__u token_typeupropertyu local_partudomainurouteu addr_spec(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu AngleAddrs u AngleAddrcBs,|EeZdZdZedd„ƒZdS(uObsRouteu obs-routecCsdd„|DƒS(NcSs(g|]}|jdkr|j‘qS(udomain(u token_typeudomain(u.0ux((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu 7s u$ObsRoute.domains..((uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyudomains5suObsRoute.domainsN(u__name__u __module__u __qualname__u token_typeupropertyudomains(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuObsRoute1suObsRoutecBst|EeZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZed d „ƒZ d S( uMailboxumailboxcCs"|djdkr|djSdS(Niu name-addr(u token_typeu display_name(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu display_name>suMailbox.display_namecCs |djS(Ni(u local_part(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu local_partCsuMailbox.local_partcCs |djS(Ni(udomain(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyudomainGsuMailbox.domaincCs"|djdkr|djSdS(Niu name-addr(u token_typeuroute(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyurouteKsu Mailbox.routecCs |djS(Ni(u addr_spec(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu addr_specPsuMailbox.addr_specN( u__name__u __module__u __qualname__u token_typeupropertyu display_nameu local_partudomainurouteu addr_spec(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuMailbox:s uMailboxcBs>|EeZdZdZedd„ƒZeZZZZ dS(uInvalidMailboxuinvalid-mailboxcCsdS(N(uNone(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu display_nameYsuInvalidMailbox.display_nameN( u__name__u __module__u __qualname__u token_typeupropertyu display_nameu local_partudomainurouteu addr_spec(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuInvalidMailboxUsuInvalidMailboxcs2|EeZdZdZe‡fdd†ƒZ‡S(uDomainudomaincsdjtƒjjƒƒS(Nu(ujoinusuperuvalueusplit(uself(u __class__(u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyudomaindsu Domain.domain(u__name__u __module__u __qualname__u token_typeupropertyudomain(u __locals__((u __class__u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuDomain`suDomaincBs|EeZdZdZdS(uDotAtomudot-atomN(u__name__u __module__u __qualname__u token_type(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuDotAtomisuDotAtomcBs|EeZdZdZdS(u DotAtomTextu dot-atom-textN(u__name__u __module__u __qualname__u token_type(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu DotAtomTextnsu DotAtomTextcBsb|EeZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZd S( uAddrSpecu addr-speccCs |djS(Ni(u local_part(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu local_partwsuAddrSpec.local_partcCs!t|ƒdkrdS|djS(Niiiÿÿÿÿ(ulenuNoneudomain(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyudomain{suAddrSpec.domaincCsJt|ƒdkr|djS|djjƒ|dj|djjƒS(Niiii(ulenuvalueurstripulstrip(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuvalues uAddrSpec.valuecCsht|jƒ}t|ƒt|tƒkr=t|jƒ}n |j}|jdk rd|d|jS|S(Nu@(usetu local_partulenu DOT_ATOM_ENDSu quote_stringudomainuNone(uselfunamesetulp((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu addr_spec‡s uAddrSpec.addr_specN( u__name__u __module__u __qualname__u token_typeupropertyu local_partudomainuvalueu addr_spec(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuAddrSpecss uAddrSpeccBs|EeZdZdZdS(u ObsLocalPartuobs-local-partN(u__name__u __module__u __qualname__u token_type(u __locals__((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu ObsLocalPart“su ObsLocalPartcsD|EeZdZdZedd„ƒZe‡fdd†ƒZ‡S(u DisplayNameu display-namecCsÆt|ƒ}|djdkr/|jdƒn8|ddjdkrgt|ddd…ƒ|d|EeZdZdZedd„ƒZedd„ƒZdS(u LocalPartu local-partcCs-|djdkr|djS|djSdS(Niu quoted-string(u token_typeu quoted_valueuvalue(uself((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuvalueÃs uLocalPart.valuec Cstg}t}d}xç|dtgD]Ô}|jdkrBq'n|r‡|jdkr‡|djdkr‡t|dd…ƒ|d This is not the RFC ctext, since we are handling nested comments in comment and unquoting quoted-pairs here. We allow anything except the '()' characters, but if we find any ASCII other than the RFC defined printable ASCII an NonPrintableDefect is added to the token's defects list. Since quoted pairs are converted to their unquoted values, what is returned is a 'ptext' token. In this case it is a WhiteSpaceTerminal, so it's value is ' '. u()uptext(u_get_ptext_to_endcharsuWhiteSpaceTerminalu_validate_xtext(uvalueuptextu_((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_qp_ctextÛs  u get_qp_ctextcCs;t|dƒ\}}}t|dƒ}t|ƒ||fS(uoqcontent = qtext / quoted-pair We allow anything except the DQUOTE character, but if we find any ASCII other than the RFC defined printable ASCII an NonPrintableDefect is added to the token's defects list. Any quoted pairs are converted to their unquoted values, so what is returned is a 'ptext' token. In this case it is a ValueTerminal. u"uptext(u_get_ptext_to_endcharsu ValueTerminalu_validate_xtext(uvalueuptextu_((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_qcontentìs  u get_qcontentcCsrt|ƒ}|s-tjdj|ƒƒ‚n|jƒ}|t|ƒd…}t|dƒ}t|ƒ||fS(u®atext = We allow any non-ATOM_ENDS in atext, but add an InvalidATextDefect to the token's defects list if we find non-atext characters. uexpected atext but found '{}'Nuatext(u_non_atom_end_matcheruerrorsuHeaderParseErroruformatugroupulenu ValueTerminalu_validate_xtext(uvalueumuatext((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_atextûs   u get_atextc CsT|ddkr+tjdj|ƒƒ‚ntƒ}|dd…}xÐ|r|ddkr|dtkr‚t|ƒ\}}n„|dd…dkrôy/t|ƒ\}}|jjtj dƒƒWqtjk rðt |ƒ\}}YqXnt |ƒ\}}|j|ƒqGW|s@|jjtj d ƒƒ||fS||dd…fS( uíbare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE A quoted-string without the leading or trailing white space. Its value is the text between the quote marks, with whitespace preserved and quoted pairs decoded. iu"uexpected '"' but found '{}'iNiu=?u!encoded word inside quoted stringu"end of header inside quoted string( uerrorsuHeaderParseErroruformatuBareQuotedStringuWSPuget_fwsuget_encoded_wordudefectsuappenduInvalidHeaderDefectu get_qcontent(uvalueubare_quoted_stringutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_bare_quoted_string s,   uget_bare_quoted_stringcCs |r1|ddkr1tjdj|ƒƒ‚ntƒ}|dd…}xƒ|rÏ|ddkrÏ|dtkrˆt|ƒ\}}n7|ddkr­t|ƒ\}}nt|ƒ\}}|j|ƒqMW|sù|j jtj dƒƒ||fS||dd…fS(u¬comment = "(" *([FWS] ccontent) [FWS] ")" ccontent = ctext / quoted-pair / comment We handle nested comments here, and quoted-pair in our qp-ctext routine. iu(uexpected '(' but found '{}'iNu)uend of header inside comment( uerrorsuHeaderParseErroruformatuCommentuWSPuget_fwsu get_commentu get_qp_ctextuappendudefectsuInvalidHeaderDefect(uvalueucommentutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_comment*s"   u get_commentcCsttƒ}x^|ri|dtkri|dtkrGt|ƒ\}}nt|ƒ\}}|j|ƒq W||fS(u,CFWS = (1*([FWS] comment) [FWS]) / FWS i(uCFWSListu CFWS_LEADERuWSPuget_fwsu get_commentuappend(uvalueucfwsutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_cfwsCs uget_cfwscCs¢tƒ}|rA|dtkrAt|ƒ\}}|j|ƒnt|ƒ\}}|j|ƒ|r˜|dtkr˜t|ƒ\}}|j|ƒn||fS(uÙquoted-string = [CFWS] [CFWS] 'bare-quoted-string' is an intermediate class defined by this parser and not by the RFC grammar. It is the quoted string without any attached CFWS. i(u QuotedStringu CFWS_LEADERuget_cfwsuappenduget_bare_quoted_string(uvalueu quoted_stringutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_quoted_stringPs  uget_quoted_stringc Cs%tƒ}|rA|dtkrAt|ƒ\}}|j|ƒn|rr|dtkrrtjdj|ƒƒ‚n|jdƒrÄyt |ƒ\}}WqÖtjk rÀt |ƒ\}}YqÖXnt |ƒ\}}|j|ƒ|r|dtkrt|ƒ\}}|j|ƒn||fS(uPatom = [CFWS] 1*atext [CFWS] An atom could be an rfc2047 encoded word. iuexpected atom but found '{}'u=?( uAtomu CFWS_LEADERuget_cfwsuappendu ATOM_ENDSuerrorsuHeaderParseErroruformatu startswithuget_encoded_wordu get_atext(uvalueuatomutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_atombs$  uget_atomcCsætƒ}| s |dtkr;tjdj|ƒƒ‚nxo|r¬|dtkr¬t|ƒ\}}|j|ƒ|r>|ddkr>|jtƒ|dd…}q>q>W|dtkrÜtjdjd|ƒƒ‚n||fS(u( dot-text = 1*atext *("." 1*atext) iu8expected atom at a start of dot-atom-text but found '{}'u.iNu4expected atom at end of dot-atom-text but found '{}'iÿÿÿÿ(u DotAtomTextu ATOM_ENDSuerrorsuHeaderParseErroruformatu get_atextuappenduDOT(uvalueu dot_atom_textutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_dot_atom_text}s     uget_dot_atom_textc Csîtƒ}|dtkr;t|ƒ\}}|j|ƒn|jdƒryt|ƒ\}}WqŸtjk r‰t|ƒ\}}YqŸXnt|ƒ\}}|j|ƒ|rä|dtkrät|ƒ\}}|j|ƒn||fS(u† dot-atom = [CFWS] dot-atom-text [CFWS] Any place we can have a dot atom, we could instead have an rfc2047 encoded word. iu=?( uDotAtomu CFWS_LEADERuget_cfwsuappendu startswithuget_encoded_worduerrorsuHeaderParseErroruget_dot_atom_text(uvalueudot_atomutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_dot_atoms  u get_dot_atomcCs¹|dtkr%t|ƒ\}}nd}|ddkrPt|ƒ\}}n=|dtkr{tjdj|ƒƒ‚nt|ƒ\}}|dk r¯|g|dd…|dtkr>|ddkr¿|jtƒ|jjtj dƒƒ|dd…}q`yt|ƒ\}}WnVtjk r-|dt kr&t |ƒ\}}|jjtj dƒƒn‚YnX|j|ƒq`W||fS(u÷ phrase = 1*word / obs-phrase obs-phrase = word *(word / "." / CFWS) This means a phrase can be a sequence of words, periods, and CFWS in any order as long as it starts with at least one word. If anything other than words is detected, an ObsoleteHeaderDefect is added to the token's defect list. We also accept a phrase that starts with CFWS followed by a dot; this is registered as an InvalidHeaderDefect, since it is not supported by even the obsolete grammar. uphrase does not start with wordiu.uperiod in 'phrase'iNucomment found without atom( uPhraseuget_worduappenduerrorsuHeaderParseErrorudefectsuInvalidHeaderDefectu PHRASE_ENDSuDOTuObsoleteHeaderDefectu CFWS_LEADERuget_cfws(uvalueuphraseutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_phraseÈs.    u get_phrasecCsîtƒ}d}|dtkr4t|ƒ\}}n|sUtjdj|ƒƒ‚nyt|ƒ\}}Wnrtjk rßyt|ƒ\}}WnDtjk rÚ|ddkrÍ|dt krÍ‚nt ƒ}YnXYnX|dk r|g|dd…|dj d kr>|jjtjdƒƒn|jrSd|_ n||fS(u' obs-local-part = word *("." word) iu\u.uinvalid repeated '.'iNumisplaced-specialu/'\' character outside of quoted-string/ccontentudotumissing '.' between wordsucfwsu!Invalid leading '.' in local partiu"Invalid trailing '.' in local partuinvalid-obs-local-partFTiÿÿÿÿiÿÿÿÿiÿÿÿÿiþÿÿÿ(u ObsLocalPartuFalseu PHRASE_ENDSudefectsuappenduerrorsuInvalidHeaderDefectuDOTuTrueu ValueTerminalu token_typeuget_worduHeaderParseErroru CFWS_LEADERuget_cfws(uvalueuobs_local_partulast_non_ws_was_dotutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_obs_local_partsV )          uget_obs_local_partcCs]t|dƒ\}}}t|dƒ}|rI|jjtjdƒƒnt|ƒ||fS(u dtext = / obs-dtext obs-dtext = obs-NO-WS-CTL / quoted-pair We allow anything except the excluded characters, but if we find any ASCII other than the RFC defined printable ASCII an NonPrintableDefect is added to the token's defects list. Quoted pairs are converted to their unquoted values, so what is returned is a ptext token, in this case a ValueTerminal. If there were quoted-printables, an ObsoleteHeaderDefect is added to the returned token's defect list. u[]uptextu(quoted printable found in domain-literal(u_get_ptext_to_endcharsu ValueTerminaludefectsuappenduerrorsuObsoleteHeaderDefectu_validate_xtext(uvalueuptextuhad_qp((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_dtextDs   u get_dtextcCs:|r dS|jtjdƒƒ|jtddƒƒdS(Nu"end of input inside domain-literalu]udomain-literal-endFT(uFalseuappenduerrorsuInvalidHeaderDefectu ValueTerminaluTrue(uvalueudomain_literal((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu_check_for_early_dl_endXs   u_check_for_early_dl_endcCstƒ}|dtkr;t|ƒ\}}|j|ƒn|sStjdƒ‚n|ddkr~tjdj|ƒƒ‚n|dd…}t||ƒr§||fS|jtddƒƒ|dt krït |ƒ\}}|j|ƒnt |ƒ\}}|j|ƒt||ƒr'||fS|dt krYt |ƒ\}}|j|ƒnt||ƒrr||fS|ddkrtjd j|ƒƒ‚n|jtdd ƒƒ|dd…}|rû|dtkrût|ƒ\}}|j|ƒn||fS( uB domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS] iuexpected domain-literalu[u6expected '[' at start of domain-literal but found '{}'iNudomain-literal-startu]u4expected ']' at end of domain-literal but found '{}'udomain-literal-end( u DomainLiteralu CFWS_LEADERuget_cfwsuappenduerrorsuHeaderParseErroruformatu_check_for_early_dl_endu ValueTerminaluWSPuget_fwsu get_dtext(uvalueudomain_literalutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_domain_literal`sD       uget_domain_literalcCsØtƒ}d}|dtkr4t|ƒ\}}n|sUtjdj|ƒƒ‚n|ddkr°t|ƒ\}}|dk r™|g|dd…" [CFWS] / obs-angle-addr obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS] iuuangle-addr-endunull addr-spec in angle-addru*obsolete route specification in angle-addru.expected addr-spec or obs-route but found '{}'u"missing trailing '>' on angle-addr( u AngleAddru CFWS_LEADERuget_cfwsuappenduerrorsuHeaderParseErroruformatu ValueTerminaludefectsuInvalidHeaderDefectu get_addr_specu get_obs_routeuObsoleteHeaderDefect(uvalueu angle_addrutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_angle_addräsJ      uget_angle_addrcCsRtƒ}t|ƒ\}}|j|dd…ƒ|jdd…|_||fS(uÇ display-name = phrase Because this is simply a name-rule, we don't return a display-name token containing a phrase, but rather a display-name token with the content of the phrase. N(u DisplayNameu get_phraseuextendudefects(uvalueu display_nameutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_display_names  uget_display_namecCsJtƒ}d}|dtkrUt|ƒ\}}|sUtjdj|ƒƒ‚qUn|ddkrÿ|dtkrtjdj|ƒƒ‚nt|ƒ\}}|sÃtjdj|ƒƒ‚n|dk rï|g|ddd…Nsuget_mailbox..uinvalid-mailbox( uMailboxu get_name_addruerrorsuHeaderParseErroru get_addr_specuformatuanyu all_defectsu token_typeuappend(uvalueumailboxutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_mailbox?s    u get_mailboxcCsŒtƒ}xv|r|d|kr|dtkr_|jt|ddƒƒ|dd…}q t|ƒ\}}|j|ƒq W||fS(uÍ Read everything up to one of the chars in endchars. This is outside the formal grammar. The InvalidMailbox TokenList that is returned acts like a Mailbox, but the data attributes are None. iumisplaced-specialiN(uInvalidMailboxu PHRASE_ENDSuappendu ValueTerminalu get_phrase(uvalueuendcharsuinvalid_mailboxutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_invalid_mailboxTs  uget_invalid_mailboxcCsYtƒ}xC|rN|ddkrNy#t|ƒ\}}|j|ƒWnftjk r­d}|dtkr t|ƒ\}}| s—|ddkrÀ|j|ƒ|jjtj dƒƒq©t |dƒ\}}|dk r÷|g|dd… We allow any non-TOKEN_ENDS in ttext, but add defects to the token's defects list if we find non-ttext characters. We also register defects for *any* non-printables even though the RFC doesn't exclude all of them, because we follow the spirit of RFC 5322. uexpected ttext but found '{}'Nuttext(u_non_token_end_matcheruerrorsuHeaderParseErroruformatugroupulenu ValueTerminalu_validate_xtext(uvalueumuttext((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_ttext“ s   u get_ttextcCsÓtƒ}|rA|dtkrAt|ƒ\}}|j|ƒn|rr|dtkrrtjdj|ƒƒ‚nt|ƒ\}}|j|ƒ|rÉ|dtkrÉt|ƒ\}}|j|ƒn||fS(uútoken = [CFWS] 1*ttext [CFWS] The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or tspecials. We also exclude tabs even though the RFC doesn't. The RFC implies the CFWS but is not explicit about it in the BNF. iuexpected token but found '{}'( uTokenu CFWS_LEADERuget_cfwsuappendu TOKEN_ENDSuerrorsuHeaderParseErroruformatu get_ttext(uvalueumtokenutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_token¦ s  u get_tokencCsrt|ƒ}|s-tjdj|ƒƒ‚n|jƒ}|t|ƒd…}t|dƒ}t|ƒ||fS(uQattrtext = 1*(any non-ATTRIBUTE_ENDS character) We allow any non-ATTRIBUTE_ENDS in attrtext, but add defects to the token's defects list if we find non-attrtext characters. We also register defects for *any* non-printables even though the RFC doesn't exclude all of them, because we follow the spirit of RFC 5322. u expected attrtext but found {!r}Nuattrtext(u_non_attribute_end_matcheruerrorsuHeaderParseErroruformatugroupulenu ValueTerminalu_validate_xtext(uvalueumuattrtext((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_attrtext½ s   u get_attrtextcCsÓtƒ}|rA|dtkrAt|ƒ\}}|j|ƒn|rr|dtkrrtjdj|ƒƒ‚nt|ƒ\}}|j|ƒ|rÉ|dtkrÉt|ƒ\}}|j|ƒn||fS(uH [CFWS] 1*attrtext [CFWS] This version of the BNF makes the CFWS explicit, and as usual we use a value terminal for the actual run of characters. The RFC equivalent of attrtext is the token characters, with the subtraction of '*', "'", and '%'. We include tab in the excluded set just as we do for token. iuexpected token but found '{}'( u Attributeu CFWS_LEADERuget_cfwsuappenduATTRIBUTE_ENDSuerrorsuHeaderParseErroruformatu get_attrtext(uvalueu attributeutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_attributeÐ s  u get_attributecCsrt|ƒ}|s-tjdj|ƒƒ‚n|jƒ}|t|ƒd…}t|dƒ}t|ƒ||fS(uÛattrtext = 1*(any non-ATTRIBUTE_ENDS character plus '%') This is a special parsing routine so that we get a value that includes % escapes as a single string (which we decode as a single string later). u)expected extended attrtext but found {!r}Nuextended-attrtext(u#_non_extended_attribute_end_matcheruerrorsuHeaderParseErroruformatugroupulenu ValueTerminalu_validate_xtext(uvalueumuattrtext((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_extended_attrtextç s   uget_extended_attrtextcCsÓtƒ}|rA|dtkrAt|ƒ\}}|j|ƒn|rr|dtkrrtjdj|ƒƒ‚nt|ƒ\}}|j|ƒ|rÉ|dtkrÉt|ƒ\}}|j|ƒn||fS(u± [CFWS] 1*extended_attrtext [CFWS] This is like the non-extended version except we allow % characters, so that we can pick up an encoded value as a single string. iuexpected token but found '{}'( u Attributeu CFWS_LEADERuget_cfwsuappenduEXTENDED_ATTRIBUTE_ENDSuerrorsuHeaderParseErroruformatuget_extended_attrtext(uvalueu attributeutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuget_extended_attributeù s  uget_extended_attributecCs<tƒ}| s |ddkr;tjdj|ƒƒ‚n|jtddƒƒ|dd…}| sy|djƒ r”tjdj|ƒƒ‚nd}x8|rÔ|djƒrÔ||d7}|dd…}qW|dd kr |d kr |jjtjd ƒƒnt |ƒ|_ |jt|d ƒƒ||fS( u6 '*' digits The formal BNF is more complicated because leading 0s are not allowed. We check for that and add a defect. We also assume no CFWS is allowed between the '*' and the digits, though the RFC is not crystal clear on that. The caller should already have dealt with leading CFWS. iu*uExpected section but found {}usection-markeriNu$Expected section number but found {}uu0u&section numberhas an invalid leading 0udigits( uSectionuerrorsuHeaderParseErroruformatuappendu ValueTerminaluisdigitudefectsuInvalidHeaderErroruintunumber(uvalueusectionudigits((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_section s$   u get_sectioncCsÝtƒ}|s!tjdƒ‚nd}|dtkrLt|ƒ\}}n|smtjdj|ƒƒ‚n|ddkr’t|ƒ\}}nt|ƒ\}}|dk rÆ|g|dd…tj d ƒ‚n|jt d d ƒƒ|dd…}d}|r¢|dtkr¢t|ƒ\}}|j|ƒnd}|}|j r|r|dd krt|ƒ\}}|j}d}|jdkrP|r|dd krd}q€t|ƒ\}} | r€| dd kr€d}q€n0yt|ƒ\}} WnYnX| s€d}n|rï|jjtjdƒƒ|j|ƒx7|D]/} | jdkr³g| dd…<| }Pq³q³W|}qd}|jjtjdƒƒn|r0|dd kr0d}nt|ƒ\}}|j s[|jdkrº| sr|dd krž|j|ƒ|dk r”|}n||fS|jjtjdƒƒn|sÿ|jjtjdƒƒ|j|ƒ|dkrE||fSnF|dk rXx!|D]} | jdkrPqqW| jdk|j| ƒ| j|_n|dd krƒtj dj|ƒƒ‚n|jt d dƒƒ|dd…}|r|dd krt|ƒ\}}|j|ƒ|j|_| s|dd krtj dj|ƒƒ‚qn|jt d dƒƒ|dd…}|dk r´tƒ} xN|rª|dtkrˆt|ƒ\}}nt|ƒ\}}| j|ƒq]W| }nt|ƒ\}}|j|ƒ|dk rè|}n||fS(uY attribute [section] ["*"] [CFWS] "=" value The CFWS is implied by the RFC but not made explicit in the BNF. This simplified form of the BNF from the RFC is made to conform with the RFC BNF through some extra checks. We do it this way because it makes both error recovery and working with the resulting parse tree easier. iu;u)Parameter contains name ({}) but no valueu*uIncomplete parameteruextended-parameter-markeriNu=uParameter not followed by '='uparameter-separatoru"u'u5Quoted string value for extended parameter is invalidubare-quoted-stringuZParameter marked as extended but appears to have a quoted string value that is non-encodeducApparent initial-extended-value but attribute was not marked as extended or was not initial sectionu(Missing required charset/lang delimitersuextended-attrtextuattrtextu=Expected RFC2231 char/lang encoding delimiter, but found {!r}uRFC2231 delimiteru;Expected RFC2231 char/lang encoding delimiter, but found {}TF(u Parameteru get_attributeuappendudefectsuerrorsuInvalidHeaderDefectuformatu get_sectionuTrueu sectioneduHeaderParseErroru ValueTerminaluextendeduNoneu CFWS_LEADERuget_cfwsuget_quoted_stringustripped_valueuFalseusection_numberu get_attrtextuget_extended_attrtextu token_typeu get_valueuvalueucharsetulanguValueuWSPuget_fwsu get_qcontent( uvalueuparamutokenuleaderu remainderuappendtouqstringu inner_valueu semi_validurestutuv((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu get_parameterC sÜ                                       u get_parametercCsëtƒ}xÛ|ræy#t|ƒ\}}|j|ƒWntjk rF}zìd}|dtkrxt|ƒ\}}n|s|j|ƒ|S|ddkr×|dk r»|j|ƒn|jjtj dƒƒn]t |ƒ\}}|r|g|dd…tƒ}d }|s2|jjtjdƒƒ|Syt|ƒ\}}WnHtjk r’|jjtjdj |ƒƒƒt ||ƒ|SYnX|j|ƒ| s·|ddkrê|jjtjdƒƒ|ræt ||ƒn|S|j j ƒj ƒ|_|jtddƒƒ|dd…}yt|ƒ\}}WnHtjk rˆ|jjtjd j |ƒƒƒt ||ƒ|SYnX|j|ƒ|j j ƒj ƒ|_|s¸|S|dd kr|jjtjd j |ƒƒƒ|`|`t ||ƒ|S|jtd d ƒƒ|jt|dd…ƒƒ|S(uÅ maintype "/" subtype *( ";" parameter ) The maintype and substype are tokens. Theoretically they could be checked against the official IANA list + x-token, but we don't do that. u"Missing content type specificationu(Expected content maintype but found {!r}iu/uInvalid content typeucontent-type-separatoriNu'Expected content subtype but found {!r}u;u<Only parameters are valid after content type, but found {!r}uparameter-separatorF(u ContentTypeuFalseudefectsuappenduerrorsuHeaderMissingRequiredValueu get_tokenuHeaderParseErroruInvalidHeaderDefectuformatu_find_mime_parametersuvalueustripulowerumaintypeu ValueTerminalusubtypeuparse_mime_parameters(uvalueuctypeurecoverutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuparse_content_type_header sX            uparse_content_type_headerc Cs6tƒ}|s,|jjtjdƒƒ|Syt|ƒ\}}WnHtjk rŒtjjtjdj |ƒƒƒt ||ƒ|SYnX|j|ƒ|j j ƒj ƒ|_|s¼|S|ddkrÿ|jjtjdj |ƒƒƒt ||ƒ|S|jtddƒƒ|jt|dd…ƒƒ|S( u* disposition-type *( ";" parameter ) uMissing content dispositionu+Expected content disposition but found {!r}iu;uCOnly parameters are valid after content disposition, but found {!r}uparameter-separatoriN(uContentDispositionudefectsuappenduerrorsuHeaderMissingRequiredValueu get_tokenuHeaderParseErroructypeuInvalidHeaderDefectuformatu_find_mime_parametersuvalueustripulowerucontent_dispositionu ValueTerminaluparse_mime_parameters(uvalueu disp_headerutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu parse_content_disposition_headerK s2       u parse_content_disposition_headerc Cs1tƒ}|s,|jjtjdƒƒ|Syt|ƒ\}}Wn7tjk r{tjjtjdj |ƒƒƒYn&X|j|ƒ|j j ƒj ƒ|_ |s«|Sx|r,|jjtjdƒƒ|dtkr |jt|ddƒƒ|dd…}q®t|ƒ\}}|j|ƒq®W|S(u mechanism u!Missing content transfer encodingu1Expected content trnasfer encoding but found {!r}u*Extra text after content transfer encodingiumisplaced-specialiN(uContentTransferEncodingudefectsuappenduerrorsuHeaderMissingRequiredValueu get_tokenuHeaderParseErroructypeuInvalidHeaderDefectuformatuvalueustripuloweructeu PHRASE_ENDSu ValueTerminalu get_phrase(uvalueu cte_headerutoken((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyu&parse_content_transfer_encoding_headeri s.     u&parse_content_transfer_encoding_header(u__doc__ureuurllibustringu hexdigitsu collectionsu namedtupleu OrderedDictuemailu_encoded_wordsu_ewuerrorsuutilsusetuWSPu CFWS_LEADERuSPECIALSu ATOM_ENDSu DOT_ATOM_ENDSu PHRASE_ENDSu TSPECIALSu TOKEN_ENDSu ASPECIALSuATTRIBUTE_ENDSuEXTENDED_ATTRIBUTE_ENDSu quote_stringu_Foldedulistu TokenListuWhiteSpaceTokenListuUnstructuredTokenListuPhraseuWorduCFWSListuAtomuTokenu EncodedWordu QuotedStringuBareQuotedStringuCommentu AddressListuAddressu MailboxListu GroupListuGroupuNameAddru AngleAddruObsRouteuMailboxuInvalidMailboxuDomainuDotAtomu DotAtomTextuAddrSpecu ObsLocalPartu DisplayNameu LocalPartu DomainLiteralu MIMEVersionu ParameteruInvalidParameteru AttributeuSectionuValueuMimeParametersuParameterizedHeaderValueu ContentTypeuContentDispositionuContentTransferEncodingu HeaderLabeluHeaderustruTerminaluWhiteSpaceTerminalu ValueTerminaluEWWhiteSpaceTerminaluDOTu ListSeparatoruRouteComponentMarkerucompileuformatujoinusplitu _wsp_splitterureplaceumatchu_non_atom_end_matcherufindallu_non_printable_finderu_non_token_end_matcheru_non_attribute_end_matcheru#_non_extended_attribute_end_matcheru_validate_xtextu_get_ptext_to_endcharsuget_fwsuget_encoded_worduget_unstructuredu get_qp_ctextu get_qcontentu get_atextuget_bare_quoted_stringu get_commentuget_cfwsuget_quoted_stringuget_atomuget_dot_atom_textu get_dot_atomuget_wordu get_phraseuget_local_partuget_obs_local_partu get_dtextu_check_for_early_dl_enduget_domain_literalu get_domainu get_addr_specu get_obs_routeuget_angle_addruget_display_nameu get_name_addru get_mailboxuget_invalid_mailboxuget_mailbox_listuget_group_listu get_groupu get_addressuget_address_listuparse_mime_versionuget_invalid_parameteru get_ttextu get_tokenu get_attrtextu get_attributeuget_extended_attrtextuget_extended_attributeu get_sectionu get_valueu get_parameteruparse_mime_parametersu_find_mime_parametersuparse_content_type_headeru parse_content_disposition_headeru&parse_content_transfer_encoding_header(((u?/opt/alt/python33/lib64/python3.3/email/_header_value_parser.pyuDs        T J_     '# B3 $ 0 0 0 !  * 8           & ' /   ' $  ) .     9 %   > D          ‹ 4  9