^Rc@sddZddddgZddlZddlZdZdZd Zd d d d dddddddddddddddddddd gZd!d"d#d$d%d&d'gZid(d)6d(d*6d(d+6d(d,6d-d.6d/d06d1d26d-d36d4d56d1d66d7d86d4d96d:d;6d7d<6Z d=Z d>Z d?Z d@Z dAfdBYZdCefdDYZdS(EscEmail address parsing code. Lifted directly from rfc822.py. This should eventually be rewritten. t mktime_tzt parsedatet parsedate_tztquoteiNt ts, tjantfebtmartaprtmaytjuntjultaugtseptocttnovtdectjanuarytfebruarytmarchtapriltjunetjulytaugustt septembertoctobertnovembertdecembertmonttuetwedtthutfritsattsunitUTtUTCtGMTtZiptASTitADTi tESTtEDTitCSTtCDTiDtMSTtMDTitPSTtPDTc Cs|j}|djds5|djtkr?|d=n8|djd}|dkrw|d|d|ddS|d }|\}}}}}|j}|t kr||j}}|t krdSnt j |d}|d kr|d 8}n|d dkr|d }n|jd }|dkr||}}n|d dkr,|d }n|dj sL||}}n|d dkri|d }n|jd }t|d kr|\} } d} n(t|dkr|\} } } ndSy@t |}t |}t | } t | } t | } Wnt k rdSX|dkrN|dkrA|d7}qN|d7}nd} |j}|tkryt|} n$yt |} Wnt k rnX| r| dkrd } | } nd} | | dd| dd} n|||| | | ddd | f S(sQConvert a date string to a time tuple. Accounts for military timezones. it,iit-it+Rii it:it0idiDiliii<N(tsplittendswithtlowert _daynamestrfindtlentfindtappendtNonet _monthnamestindextisdigittintt ValueErrortuppert _timezones(tdatatitstufftstddtmmtyyttmttztthhttmmttssttzoffsetttzsign((s&/usr/lib/python2.7/email/_parseaddr.pyR-s )                               !cCs+t|}t|tr#|d S|SdS(s&Convert a time string to a time tuple.i N(Rt isinstancettuple(RGtt((s&/usr/lib/python2.7/email/_parseaddr.pyRs cCsD|ddkr%tj|d dStj|}||dSdS(sETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.i iiN(i(R?ttimetmktimetcalendarttimegm(RGRW((s&/usr/lib/python2.7/email/_parseaddr.pyRscCs|jddjddS(sPrepare string to be used in a quoted string. Turns backslash and double quote characters into quoted pairs. These are the only characters that need to be quoted inside a quoted string. Does not add the surrounding double quotes. s\s\\t"s\"(treplace(tstr((s&/usr/lib/python2.7/email/_parseaddr.pyRst AddrlistClasscBseZdZdZdZdZdZdZdZdZ e dZ d Z d Z d Zdd Zd ZRS(sAddress parser class by Ben Escoto. To understand what this class does, it helps to have a copy of RFC 2822 in front of you. Note: this class interface is deprecated and may be removed in the future. Use rfc822.AddressList instead. cCsd|_d|_d|_d|_|j|j|_|j|j|j|_|jjdd|_||_g|_ dS(sInitialize a new instance. `field' is an unparsed address header field, containing one or more addresses. s ()<>@,:;."[]is s t.RN( tspecialstpostLWStCRtFWStatomendsR]t phraseendstfieldt commentlist(tselfRh((s&/usr/lib/python2.7/email/_parseaddr.pyt__init__s     cCsx{|jt|jkr}|j|j|jdkrJ|jd7_q|j|jdkry|jj|jqPqWdS(s*Parse up to the start of the next address.s it(N(RbR<RhRcRiR>t getcomment(Rj((s&/usr/lib/python2.7/email/_parseaddr.pytgotonexts cCsUg}xH|jt|jkrP|j}|r@||7}q |jdq W|S(sVParse all addresses. Returns a list containing all of the addresses. R(RR(RbR<Rht getaddressR>(Rjtresulttad((s&/usr/lib/python2.7/email/_parseaddr.pyt getaddrlists  cCsg|_|j|j}|j}|j}|jg}|jt|jkr|rPtj|j|dfg}qPn|j|jdkr||_||_|j}tj|j|fg}nz|j|jdkrg}t|j}|jd7_x=|jt|jkr|j|j|krm|j|jdkrm|jd7_Pn||j }qWn|j|jdkr|j }|jrtj|ddj|jd |fg}qPtj||fg}nS|r%tj|j|dfg}n+|j|j|j krP|jd7_n|j|jt|jkr|j|jd kr|jd7_n|S( sParse the next address.is.@R5it;tt@R5(RhRbtFalseRnR<t getdomaintTrueRy(Rjt expectroutetadlist((s&/usr/lib/python2.7/email/_parseaddr.pyRzs.     cCsLg}|jx|jt|jkr|j|jdkr`|jd|jd7_nf|j|jdkr|jdt|jn0|j|j|jkrPn|j|j|jqW|jt|jks|j|jdkrt j |S|jd|jd7_|jt j ||j S(sParse an RFC 2822 addr-spec.R`iR\s"%s"R( RnRbR<RhR>RtgetquoteRftgetatomt EMPTYSTRINGRxR(Rjtaslist((s&/usr/lib/python2.7/email/_parseaddr.pyRy<s$   .   cCsg}x|jt|jkr|j|j|jkrL|jd7_q |j|jdkr{|jj|jq |j|jdkr|j|jq |j|jdkr|jd7_|jdq |j|j|jkrPq |j|j q Wt j |S(s-Get the complete domain name from an address.iRlt[R`( RbR<RhRcRiR>RmtgetdomainliteralRfRRRx(Rjtsdlist((s&/usr/lib/python2.7/email/_parseaddr.pyRUscCs-|j|j|krdSdg}t}|jd7_x|jt|jkr|ry|j|j|jt}n|j|j|kr|jd7_Pnk|r|j|jdkr|j|jq;n6|j|jdkrt}n|j|j|j|jd7_q;Wtj|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. RiRls\( RhRbRR<R>RmRRRx(Rjt beginchartendcharst allowcommentstslistR((s&/usr/lib/python2.7/email/_parseaddr.pyt getdelimitedhs(    cCs|jddtS(s1Get a quote-delimited fragment from self's field.R\s" (RR(Rj((s&/usr/lib/python2.7/email/_parseaddr.pyRscCs|jddtS(s7Get a parenthesis-delimited fragment from self's field.Rls) (RR(Rj((s&/usr/lib/python2.7/email/_parseaddr.pyRmscCsd|jddtS(s!Parse an RFC 2822 domain-literal.s[%s]Rs] (RR(Rj((s&/usr/lib/python2.7/email/_parseaddr.pyRscCsdg}|dkr!|j}nx\|jt|jkr|j|j|krVPn|j|j|j|jd7_q$Wtj|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?RfRbR<RhR>RRx(RjRftatomlist((s&/usr/lib/python2.7/email/_parseaddr.pyRs   cCsg}x|jt|jkr|j|j|jkrL|jd7_q |j|jdkrx|j|jq |j|jdkr|jj|jq |j|j|jkrPq |j|j |jq 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\Rl( RbR<RhReR>RRiRmRgR(RjR}((s&/usr/lib/python2.7/email/_parseaddr.pyRvsN(t__name__t __module__t__doc__RkRnRrRoRzRyRRRRRmRR?RRv(((s&/usr/lib/python2.7/email/_parseaddr.pyR_s   ;   %    t AddressListcBsMeZdZdZdZdZdZdZdZdZ RS(s@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs5tj|||r(|j|_n g|_dS(N(R_RkRrt addresslist(RjRh((s&/usr/lib/python2.7/email/_parseaddr.pyRkscCs t|jS(N(R<R(Rj((s&/usr/lib/python2.7/email/_parseaddr.pyt__len__scCsStd}|j|_x3|jD](}||jkr#|jj|q#q#W|S(N(RR?RR>(Rjtothertnewaddrtx((s&/usr/lib/python2.7/email/_parseaddr.pyt__add__s   cCs:x3|jD](}||jkr |jj|q q W|S(N(RR>(RjRR((s&/usr/lib/python2.7/email/_parseaddr.pyt__iadd__scCsFtd}x3|jD](}||jkr|jj|qqW|S(N(RR?RR>(RjRRR((s&/usr/lib/python2.7/email/_parseaddr.pyt__sub__s  cCs:x3|jD](}||jkr |jj|q q W|S(N(Rtremove(RjRR((s&/usr/lib/python2.7/email/_parseaddr.pyt__isub__scCs |j|S(N(R(RjRA((s&/usr/lib/python2.7/email/_parseaddr.pyt __getitem__s( RRRRkRRRRRR(((s&/usr/lib/python2.7/email/_parseaddr.pyRs     (Rt__all__RXRZRwRt COMMASPACER@R:RFRRRRR_R(((s&/usr/lib/python2.7/email/_parseaddr.pyts4  b