lJc@sdZddkZdddddgZdd fZdfd YZd Zd Zd ZdfdYZdefdYZ dZ ddddddddddddddd d!dd"d#d$d%d&d'd(gZ d)d*d+d,d-d.d/gZ hd0d1<d0d2<d0d3<d0d4<d5d6<d7d8<d9d:<d5d;<d<d=<d9d><d?d@<d<dA<dBdC<d?dDDelete all occurrences of a specific header, if it is present.NR'ii(R)RR trangeRR-Rtreversed(RR.R/R!R0R*R%((s/sys/lib/python/rfc822.pyt __delitem__s(        RcCs||i}||ijo|i|SnN|d|}x+|idD]}|ii|dqIW||i|<|SdS(Ns: s (R)RRLRR(RR.R6t lowernameRNR%((s/sys/lib/python/rfc822.pyt setdefaults  cCs|i|ijS(s6Determine whether a message contains the named header.(R)R(RR.((s/sys/lib/python/rfc822.pythas_keyscCs|i|ijS(s6Determine whether a message contains the named header.(R)R(RR.((s/sys/lib/python/rfc822.pyt __contains__scCs t|iS(N(titerR(R((s/sys/lib/python/rfc822.pyt__iter__scCs |iiS(s*Get all of a message's header field names.(Rtkeys(R((s/sys/lib/python/rfc822.pyRYscCs |iiS(s+Get all of a message's header field values.(Rtvalues(R((s/sys/lib/python/rfc822.pyRZscCs |iiS(sWGet all of a message's headers. Returns a list of name, value tuples. (Rtitems(R((s/sys/lib/python/rfc822.pyR[scCsdi|iS(NR(R3R(R((s/sys/lib/python/rfc822.pyt__str__sN( t__name__t __module__t__doc__RRR RRRR1R2R4R R7R5R<R?R=RHRIRJRKRORRRTRURVRXRYRZR[R\(((s/sys/lib/python/rfc822.pyRQs:   K                cCst|djoz|ido7|ido'|dd!iddiddSn|ido|ido|dd!Sqn|S( sRemove quotes from a string.it"is\\s\s\"t(R Rtendswithtreplace(R;((s/sys/lib/python/rfc822.pytunquotes  ' cCs|iddiddS(sAdd quotes around a string.s\s\\R`s\"(Rd(R;((s/sys/lib/python/rfc822.pytquotescCs,t|}|i}|pdSn|dS(s3Parse an address into a (realname, mailaddr) tuple.iN(NN(RR@R (taddressRER!((s/sys/lib/python/rfc822.pyt parseaddrs   t AddrlistClasscBseZdZdZdZdZdZdZdZdZ dd Z d Z d Z d Z dd ZdZRS(s)Address parser class by Ben Escoto. To understand what this class does, it helps to have a copy of RFC 2822 in front of you. http://www.faqs.org/rfcs/rfc2822.html Note: this class interface is deprecated and may be removed in the future. Use rfc822.AddressList instead. cCsld|_d|_d|_d|_|i|i|i|_|iidd|_||_g|_dS(sInitialize a new instance. `field' is an unparsed address header field, containing one or more addresses. s ()<>@,:;."[]is s t.RN( tspecialstpostLWStCRtatomendsRdt phraseendstfieldt commentlist(RRq((s/sys/lib/python/rfc822.pyRs     cCsx|it|ijoh|i|i|idjo|id|_q|i|idjo|ii|iqPqWdS(s*Parse up to the start of the next address.s it(N(RlR RqRmRrRt getcomment(R((s/sys/lib/python/rfc822.pytgotonext s cCs;g}|i}x"|o||7}|i}qW|S(sVParse all addresses. Returns a list containing all of the addresses. (t getaddress(RR8tad((s/sys/lib/python/rfc822.pyR=s    cCsg|_|i|i}|i}|i}|ig}|it|ijo.|o#di|i|dfg}qen|i|idjo=||_||_|i}di|i|fg}n|i|idjog}t|i}|id7_xK|it|ijoY|i|i|jo+|i|idjo|id7_Pn||i}qWn|i|idjof|i }|io4di|ddi|id |fg}qedi||fg}nX|o#di|i|dfg}n.|i|i|i jo|id7_n|i|it|ijo*|i|id jo|id7_n|S( sParse the next address.t is.@R'it;Ras (t)t,( RrRuRlt getphraselistR RqR3t getaddrspecRvt getrouteaddrRk(Rtoldpostoldcltplistt returnlisttaddrspectfieldlent routeaddr((s/sys/lib/python/rfc822.pyRvsL      '    '  4# 0cCs/|i|idjodSnd}|id7_|id}x|it|ijo|o|id}n|i|idjo|id7_Pnw|i|idjo|id7_d}nG|i|idjo|id7_n|i}|id7_P|iqGW|S( sParse a route address (Return-path value). This method just skips all the route stuff and returns the addrspec. RaNiiRRbt@R'(RqRlRuR t getdomainR}(Rt expectroutetadlist((s/sys/lib/python/rfc822.pyR~Ys.     cCsTg}|ix|it|ijo|i|idjo |id|id7_ne|i|idjo|id|in3|i|i|ijoPn|i|i|iqW|it|ijp|i|idjodi|Sn|id|id7_|idi||i S(sParse an RFC 2822 addr-spec.RjiR`s"%s"RR( RuRlR RqRtgetquoteRotgetatomR3R(Rtaslist((s/sys/lib/python/rfc822.pyR}ys$  0  cCs)g}x|it|ijo|i|i|ijo|id7_q |i|idjo|ii|iq |i|idjo|i|iq |i|idjo |id7_|idq |i|i|ijoPq |i|i q Wdi |S(s-Get the complete domain name from an address.iRst[RjR( RlR RqRmRrRRttgetdomainliteralRoRR3(Rtsdlist((s/sys/lib/python/rfc822.pyRsicCsC|i|i|jodSndg}d}|id7_x|it|ijo|djo!|i|i|id}n|i|i|jo|id7_Pnq|o1|i|idjo|i|iq@n9|i|idjo d}n|i|i|i|id7_q@Wdi|S(sParse a header fragment delimited by special characters. `beginchar' is the start character for the fragment. If self is not looking at an instance of `beginchar' then getdelimited returns the empty string. `endchars' is a sequence of allowable end-delimiting characters. Parsing stops when one of these is encountered. If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed within the parsed fragment. RiiRss\(RqRlR RRtR3(Rt beginchartendcharst allowcommentstslistRf((s/sys/lib/python/rfc822.pyt getdelimiteds(     cCs|idddS(s1Get a quote-delimited fragment from self's field.R`s" i(R(R((s/sys/lib/python/rfc822.pyRscCs|idddS(s7Get a parenthesis-delimited fragment from self's field.Rss) i(R(R((s/sys/lib/python/rfc822.pyRtscCsd|idddS(s!Parse an RFC 2822 domain-literal.s[%s]Rs] i(R(R((s/sys/lib/python/rfc822.pyRscCsdg}|djo |i}nx`|it|ijoF|i|i|joPn|i|i|i|id7_q&Wdi|S(sParse an RFC 2822 atom. Optional atomends specifies a different set of end token delimiters (the default is to use self.atomends). This is used e.g. in getphraselist() since phrase endings must not include the `.' (which is legal in phrases).RiN(R RoRlR RqRR3(RRotatomlist((s/sys/lib/python/rfc822.pyRs   cCsg}x|it|ijo|i|i|ijo|id7_q |i|idjo|i|iq |i|idjo|ii|iq |i|i|ijoPq |i|i |iq W|S(sParse a sequence of RFC 2822 phrases. A phrase is a sequence of words, which are in turn either RFC 2822 atoms or quoted-strings. Phrases are canonicalized by squeezing all runs of continuous whitespace into one space. iR`Rs( RlR RqRmRRRrRtRpR(RR((s/sys/lib/python/rfc822.pyR|sN(R]R^R_RRuR=RvR~R}RRRRtRR RR|(((s/sys/lib/python/rfc822.pyRis   :   %    cBsVeZdZdZdZdZdZdZdZdZ dZ RS( s@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs7ti|||o|i|_n g|_dS(N(RiRR=R@(RRq((s/sys/lib/python/rfc822.pyRscCs t|iS(N(R R@(R((s/sys/lib/python/rfc822.pyRJscCsditt|iS(Ns, (R3tmaptdump_address_pairR@(R((s/sys/lib/python/rfc822.pyR\ scCsUtd}|i|_x5|iD]*}||ijo|ii|q#q#W|S(N(RR R@R(RtothertnewaddrR&((s/sys/lib/python/rfc822.pyt__add__ s   cCs<x5|iD]*}||ijo|ii|q q W|S(N(R@R(RRR&((s/sys/lib/python/rfc822.pyt__iadd__s  cCsHtd}x5|iD]*}||ijo|ii|qqW|S(N(RR R@R(RRRR&((s/sys/lib/python/rfc822.pyt__sub__s   cCs<x5|iD]*}||ijo|ii|q q W|S(N(R@tremove(RRR&((s/sys/lib/python/rfc822.pyt__isub__%s  cCs |i|S(N(R@(Rtindex((s/sys/lib/python/rfc822.pyRK,s( R]R^R_RRJR\RRRRRK(((s/sys/lib/python/rfc822.pyRs      cCs7|do d|dd|ddSn |dSdS(s4Dump a (name, address) pair in a canonicalized form.iR`s" Gsz    2 ( U