Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/email/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`s�dZddlmZddlmZddlmZddlmZddlmZm Z m
Z
ddd d
ddd
ddddddddgZddlZddl
Z
ejr�de
_nddlZddlZddlZddlZddlmZddlmZmZddlZddlmZddlmZddlmZ
ddlm!Z!ddlm"Z"m#Z#m$Z$ddl%m&Z'ddl(m)Z)m*Z*dd
l+m,Z,d!Z-d"Z.d"Z/d#Z0d$Z1e
j2d%�Z3e
j2d&�Z4e
j2d'�j5Z6d(�Z7d)d*�Z8d+�Z9e
j2d,e
j:e
j;B�Z<d-�Z=de?e?d.�Z@e?d/�ZAddd0�ZBd1�ZCd2�ZDd3�Zd4�ZEddd5�ZFe
j2d6e
j�ZGd7�ZHd8d9d:�ZIdd;d<�ZJdS(=uMiscellaneous
utilities.i(tunicode_literals(tdivision(tabsolute_import(tutils(tbytestinttstrucollapse_rfc2231_valueu
decode_paramsudecode_rfc2231uencode_rfc2231u
formataddru
formatdateuformat_datetimeugetaddressesu
make_msgidu mktime_tzu parseaddru parsedateuparsedate_tzuparsedate_to_datetimeuunquoteN(tdatetime(tquotetunquote(tStringIO(R(tAddressList(t mktime_tz(t parsedatetparsedate_tzt
_parsedate_tz(tdecodestring(t_bencodet_qencode(tCharsetu,
uu
u'u[][\\()<>@,:;".]u[\\"]u'([^�-�]|\A)[�-�]([^�-�]|\Z)cC`s"|jdd�}|jdd�S(Nuasciiusurrogateescapeureplace(tencodetdecode(tstringtoriginal_bytes((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt _sanitizeHsuutf-8cC`s�|\}}|jd�|r�y|jd�WnItk
r{t|t�r^t|�}n|j|�}d||fSXd}tj|�r�d}ntj d|�}d||||fSn|S(u�The
inverse of parseaddr(), this takes a 2-tuple of the form
(realname, email_address) and returns the string value suitable
for an RFC 2822 From, To or Cc header.
If the first element of pair is false, then the second element is
returned unmodified.
Optional charset if given is the character set that is used to encode
realname in case realname is not ASCII safe. Can be an instance of str
or
a Charset-like object which has a header_encode method. Default is
'utf-8'.
uasciiu%s <%s>uu"u\\\g<0>u%s%s%s <%s>(
RtUnicodeEncodeErrort
isinstanceRRt
header_encodet
specialsretsearcht escapesretsub(tpairtcharsettnametaddresstencoded_nametquotes((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt
formataddrPs
cC`s"tj|�}t|�}|jS(u7Return
a list of (REALNAME, EMAIL) for each fieldvalue.(t
COMMASPACEtjoint_AddressListtaddresslist(tfieldvaluestallta((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pytgetaddressesrsu_
=\? # literal =?
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
\? # literal ?
(?P<encoding>[qb]) # either a "q" or a "b",
case insensitive
\? # literal ?
(?P<atom>.*?) # non-greedy up to the next ?= is the atom
\?= # literal ?=
cC`s�ddddddddg|d |d
ddd
dddddddddg|dd|d|d|d|d|fS(Nu"%s, %02d
%s %04d %02d:%02d:%02d
%suMonuTueuWeduThuuFriuSatuSuniiuJanuFebuMaruApruMayuJunuJuluAuguSepuOctuNovuDeciiiii((t timetupletzone((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt_format_timetuple_and_zone�s
!c C`s�|d
krtj�}n|r�tj|�}tjrO|drOtj}n tj}tt|�d�\}}|dkr�d}nd}d|||df}n$tj|�}|r�d}nd }t ||�S(u�Returns
a date string as specified by RFC 2822, e.g.:
Fri, 09 Nov 2001 01:08:47 -0000
Optional timeval if given is a floating point time value as accepted by
gmtime() and localtime(), otherwise the current time is used.
Optional localtime is a flag that when True, interprets timeval, and
returns a date relative to the local timezone instead of UTC, properly
taking daylight savings time into account.
Optional argument usegmt means that the timezone is written out as
an ascii string, not numeric one (so "GMT" instead of
"+0000"). This
is needed for HTTP, and is only used when localtime==False.
i����iiu-u+u
%s%02d%02di<uGMTu-0000N(
tNonettimet localtimetdaylighttaltzonettimezonetdivmodtabstgmtimeR1( ttimevalR4tusegmttnowtoffsetthourstminutestsignR0((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt
formatdate�s" cC`s�|j�}|rN|jdks6|jtjjkrEtd��nd}n'|jdkrfd}n|jd�}t||�S(u$Turn
a datetime into a date string as specified in RFC 2822.
If usegmt is True, dt must be an aware datetime with an offset of zero.
In
this case 'GMT' will be rendered instead of the normal +0000
required by
RFC2822. This is to support HTTP headers involving date stamps.
u%usegmt option requires a UTC
datetimeuGMTu-0000u%zN( R/ttzinfoR2RR7tutct
ValueErrortstrftimeR1(tdtR<R=R0((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pytformat_datetime�s$ cC`s�tj�}tjdtj|��}tj�}tjd�}|dkrWd}n
d|}|dkr|tj �}nd|||||f}|S(unReturns a string suitable
for RFC 2822 compliant Message-ID, e.g:
<20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
uniqueness of the message id. Optional domain if given provides the
portion of the message id after the '@'. It defaults to the
locally
defined hostname.
u%Y%m%d%H%M%Si��uu.u<%s.%s.%s%s@%s>N(
R3RFR:tostgetpidtrandomt randrangeR2tsockettgetfqdn(tidstringtdomainR;tutcdatetpidtrandinttmsgid((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt
make_msgid�s
cC`svtt|��}|d g|d\}}|dkrJtj|d
�Stjdtjtjd|��|d
�S(Ni����iRCtseconds(tlistRR2RR7t timedelta(tdatat _3to2listtdtuplettz((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pytparsedate_to_datetime�s cC`s!t|�j}|sdS|dS(Nui(uu(R)R*(taddrtaddrs((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt parseaddr�scC`s�t|�dkr|jd�rS|jd�rS|dd!jdd�jdd�S|jd�r|jd�r|dd!Sn|S( uRemove
quotes from a
string.iu"i����u\\u\u\"u<u>(tlent
startswithtendswithtreplace(R((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyR �s#cC`s5|jtd�}t|�dkr1dd|fS|S(u#Decode
string according to RFC
2231iN(tsplittTICKRaR2(tstparts((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pytdecode_rfc2231s
cC`s`t|ddd|pd�}|dkr:|dkr:|S|dkrOd}nd|||fS(u�Encode
string according to RFC 2231.
If neither charset nor language is given, then s is returned as-is. If
charset is given but not language, the string is encoded using the
empty
string for language.
tsafeutencodinguasciiu%s'%s'%sN(t url_quoteR2(RgR!tlanguage((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pytencode_rfc2231s u&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
C`s|}g}i}|jd�\}}|j||f�x�|r|jd�\}}|jd�rqt}nt}t|�}tj|�}|r�|jdd�\}}|dk r�t
|�}n|j|g�j|||f�q>|j|dt|�f�q>W|r�x�|j
�D]�\}}g}t} |j�xE|D]=\}}
}|r}t|
dd�}
t} n|j|
�qMWttj|��}| r�t|�\}}}|j|||d|ff�q$|j|d|f�q$Wn|S( uDecode
parameters list according to RFC 2231.
params is a sequence of 2-tuples containing (param name, string value).
iu*unameunumu"%s"Rkulatin-1N(tpoptappendRctTruetFalseR trfc2231_continuationtmatchtgroupR2Rt
setdefaultRtitemstsortturl_unquotetEMPTYSTRINGR(Ri(
tparamst
new_paramstrfc2231_paramsR"tvaluetencodedtmotnumt
continuationstextendedRgR!Rm((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt
decode_paramssD %!
#ureplaceuus-asciicC`s}t|t�s"t|�dkr,t|�S|\}}}t|d�}yt|||�SWntk
rxt|�SXdS(Niuraw-unicode-escape(RttupleRaR RRtLookupError(R~terrorstfallback_charsetR!Rmttexttrawbytes((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pytcollapse_rfc2231_valueUs"
i����c C`s\|dkr(tjjtjj�j�S|jdk rA|j�S|j�d
|f}tj |�}tj
|�}y.tjd|j�}tj||j
�}Wn�tk
rK|tjtj|�d
�}tjo�|jdk}|r�tjntj}|tjd|�kr9tj|tj|�}qLtj|�}nX|jd|�S(u�Return
local time as an aware datetime object.
If called without arguments, return current time. Otherwise *dt*
argument should be a datetime instance, and it is converted to the
local time zone according to the system time zone database. If *dt* is
naive (that is, dt.tzinfo is None), it is assumed to be in local time.
In this case, a positive or zero value for *isdst* causes localtime to
presume initially that summer time (for example, Daylight Saving Time)
is or is not (respectively) in effect for the specified time. A
negative value for *isdst* causes the localtime() function to attempt
to divine whether summer time is in effect for the specified time.
i����RViiRCN(R2RR=R7RDt
astimezoneRCR/R3tmktimeR4RXt tm_gmtoffttm_zonetAttributeErrorR:R5ttm_isdstR6ttznameRd( RGtisdstttmRVtlocaltmtdeltaR\tdsttgmtoff((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyR4ks$
(Kt__doc__t
__future__RRRtfutureRtfuture.builtinsRRRt__all__RItretPY2tASCIIR3tbase64RKRMtfuture.backportsRtfuture.backports.urllib.parseRRlR RytwarningstioR
t!future.backports.email._parseaddrRR)RR
RRtquopriRt_qdecodetfuture.backports.email.encodersRRtfuture.backports.email.charsetRR'RztUEMPTYSTRINGtCRLFRftcompileRRRt_has_surrogatesRR&R.tVERBOSEt
IGNORECASEtecreR1R2RrRBRHRUR]R`RiRnRsR�R�R4(((s@/usr/lib/python2.7/site-packages/future/backports/email/utils.pyt<module>s� " - 8