��Qc@sddZddddgZddlZddlZdZdZd Zd
ddd
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>�Zd?�Zd@�Z
dAfdB��YZdCefdD��YZdS(EscEmail address parsing code.
Lifted directly from rfc822.py. This should eventually be rewritten.
t mktime_tzt parsedatetparsedate_tztquotei�Nt ts, tjantfebtmartaprtmaytjuntjultaugtseptocttnovtdectjanuarytfebruarytmarchtapriltjunetjulytaugustt septembertoctobertnovembertdecembertmonttuetwedtthutfritsattsunitUTtUTCtGMTtZip�ASTi��ADTi�ESTtEDTi��CSTtCDTiD�MSTtMDTi��PSTtPDTcCs|j�}|djd�s5|dj�tkr?|d=n8|djd�}|dkrw|d|d|d<nt|�dkr�|djd�}t|�dkr�||d}q�nt|�dkr(|d}|jd�}|dkr|| ||dg|d)q(|jd�nt|�d kr>dS|d }|\}}}}}|j�}|t kr�||j�}}|t kr�dSnt j
|�d}|d
kr�|d
8}n|ddkr�d }n|jd�}|dkr||}}n|ddkr,|d }n|dj�sL||}}n|ddkri|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
r�nX|r�dkr�d}
|}nd}
|
|dd|dd}n|||| |
|ddd|f
S(sQConvert a date string to a time tuple.
Accounts for military timezones.
it,iit-it+Riii�t:it0idiDili�ii<N(tsplittendswithtlowert _daynamestrfindtlentfindtappendtNonet_monthnamestindextisdigittintt
ValueErrortuppert
_timezones(tdatatitstufftstddtmmtyyttmttztthhttmmttssttzoffsetttzsign((s&/sys/lib/python2.7/email/_parseaddr.pyR-s�)
!cCs+t|�}t|t�r#|d S|SdS(s&Convert a time string to a time tuple.i N(Rt
isinstancettuple(RGtt((s&/sys/lib/python2.7/email/_parseaddr.pyR�scCsD|ddkr%tj|d d�Stj|�}||dSdS(sETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.i ii�N(i�(R?ttimetmktimetcalendarttimegm(RGRW((s&/sys/lib/python2.7/email/_parseaddr.pyR�scCs|jdd�jdd�S(s�Prepare 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&/sys/lib/python2.7/email/_parseaddr.pyR�st
AddrlistClasscBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z e
d�Zd �Zd
�Z
d�Zdd�Zd
�ZRS(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.
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(s�Initialize a new instance.
`field' is an unparsed address header field, containing
one or more addresses.
s()<>@,:;."[]is s
t.RN(
tspecialstpostLWStCRtFWStatomendsR]t
phraseendstfieldtcommentlist(tselfRh((s&/sys/lib/python2.7/email/_parseaddr.pyt__init__�s cCs�x{|jt|j�kr}|j|j|jdkrJ|jd7_q|j|jdkry|jj|j��qPqWdS(s*Parse up to the start of the next address.s
it(N(RbR<RhRcRiR>t
getcomment(Rj((s&/sys/lib/python2.7/email/_parseaddr.pytgotonext�scCsUg}xH|jt|j�krP|j�}|r@||7}q |jd�q W|S(sVParse all addresses.
Returns a list containing all of the addresses.
R(RR(RbR<Rht
getaddressR>(Rjtresulttad((s&/sys/lib/python2.7/email/_parseaddr.pytgetaddrlist�s
cCs�g|_|j�|j}|j}|j�}|j�g}|jt|j�kr�|rPtj|j�|dfg}qPn�|j|jdkr�||_||_|j�}tj|j�|fg}nz|j|jdkr�g}t|j�}|jd7_x=|jt|j�kr�|j�|j|krm|j|jdkrm|jd7_Pn||j �}qWn�|j|jdkr�j
�}|jr�j|�ddj|j�d |fg}qPtj|�|fg}nS|r%tj|j�|dfg}n+|j|j|jkrP|jd7_n|j�|jt|j�kr�|j|jd
kr�|jd7_n|S(sParse the next address.is.@R5it;t<s (Rt)R2(RiRnRbt
getphraselistR<RhtSPACEtjointgetaddrspecRotgetrouteaddrRa(Rjtoldpostoldcltplistt
returnlisttaddrspectfieldlent routeaddr((s&/sys/lib/python2.7/email/_parseaddr.pyRo�sL
%
% 3"
.cCs |j|jdkrdSt}|jd7_|j�d}x�|jt|j�kr|rs|j�t}n�|j|jdkr�|jd7_Pnr|j|jdkr�|jd7_t}nD|j|jdkr�jd7_n|j�}|jd7_P|j�qBW|S(s�Parse a route address (Return-path value).
This method just skips all the route stuff and returns the addrspec.
RtNiRt>t@R5(RhRbtFalseRnR<t getdomaintTrueRy(Rjtexpectroutetadlist((s&/sys/lib/python2.7/email/_parseaddr.pyRzs.
cCsLg}|j�x�|jt|j�kr�|j|jdkr`|jd�|jd7_nf|j|jdkr�|jdt|j���n0|j|j|jkr�Pn|j|j��|j�qW|jt|j�ks|j|jdkrt j
|�S|jd�|jd7_|j�t j
|�|j�S(sParse an RFC 2822 addr-spec.R`iR\s"%s"R�(RnRbR<RhR>RtgetquoteRftgetatomtEMPTYSTRINGRxR�(Rjtaslist((s&/sys/lib/python2.7/email/_parseaddr.pyRy<s$
.
cCsg}x|jt|j�kr|j|j|jkrL|jd7_q |j|jdkr{|jj|j��q |j|jdkr�|j|j��q |j|jdkr�|jd7_|jd�q |j|j|jkr� |j|j ��q Wt
j|�S(s-Get the complete domain name from an address.iRlt[R`(RbR<RhRcRiR>RmtgetdomainliteralRfR�R�Rx(Rjtsdlist((s&/sys/lib/python2.7/email/_parseaddr.pyR�UscCs-|j|j|krdSdg}t}|jd7_x�jt|j�kr|ry|j|j|j�t}n�|j|j|kr�|jd7_Pnk|r�|j|jdkr�|j|j��q;n6|j|jdkr�}n|j|j|j�|jd7_q;Wtj|�S(s�Parse 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\( RhRbR�R<R>RmR�R�Rx(Rjt beginchartendcharst
allowcommentstslistR((s&/sys/lib/python2.7/email/_parseaddr.pytgetdelimitedhs(
cCs|jddt�S(s1Get a quote-delimited fragment from self's field.R\s"
(R�R�(Rj((s&/sys/lib/python2.7/email/_parseaddr.pyR��scCs|jddt�S(s7Get a parenthesis-delimited fragment from self's field.Rls)
(R�R�(Rj((s&/sys/lib/python2.7/email/_parseaddr.pyRm�scCsd|jddt�S(s!Parse an RFC 2822 domain-literal.s[%s]R�s]
(R�R�(Rj((s&/sys/lib/python2.7/email/_parseaddr.pyR��scCs�dg}|dkr!|j}nx\|jt|j�kr|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>R�Rx(RjRftatomlist((s&/sys/lib/python2.7/email/_parseaddr.pyR��s cCs�g}x�|jt|j�kr�j|j|jkrL|jd7_q |j|jdkrx|j|j��q |j|jdkr�|jj|j��q |j|j|jkr�Pq |j|j |j��q W|S(s�Parse 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>R�RiRmRgR�(RjR}((s&/sys/lib/python2.7/email/_parseaddr.pyRv�sN(t__name__t
__module__t__doc__RkRnRrRoRzRyR�R�R�R�RmR�R?R�Rv(((s&/sys/lib/python2.7/email/_parseaddr.pyR_�s
; % tAddressListcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z RS(s@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs5tj||�|r(|j�|_n g|_dS(N(R_RkRrtaddresslist(RjRh((s&/sys/lib/python2.7/email/_parseaddr.pyRk�scCs
t|j�S(N(R<R�(Rj((s&/sys/lib/python2.7/email/_parseaddr.pyt__len__�scCsStd�}|j|_x3|jD](}||jkr#|jj|�q#q#W|S(N(R�R?R�R>(Rjtothertnewaddrtx((s&/sys/lib/python2.7/email/_parseaddr.pyt__add__�s
cCs:x3|jD](}||jkr
|jj|�q
q
W|S(N(R�R>(RjR�R�((s&/sys/lib/python2.7/email/_parseaddr.pyt__iadd__�scCsFtd�}x3|jD](}||jkr|jj|�qqW|S(N(R�R?R�R>(RjR�R�R�((s&/sys/lib/python2.7/email/_parseaddr.pyt__sub__�s
cCs:x3|jD](}||jkr
|jj|�q
q
W|S(N(R�tremove(RjR�R�((s&/sys/lib/python2.7/email/_parseaddr.pyt__isub__�scCs|j|S(N(R�(RjRA((s&/sys/lib/python2.7/email/_parseaddr.pyt__getitem__�s(
R�R�R�RkR�R�R�R�R�R�(((s&/sys/lib/python2.7/email/_parseaddr.pyR��s (R�t__all__RXRZRwR�t
COMMASPACER@R:RFRRRRR_R�(((s&/sys/lib/python2.7/email/_parseaddr.pyt<module>s4 b
|