Files
PowerToys/PythonHome/Lib/email/utils.pyc

87 lines
9.4 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc @sdZddddddddd d
d d d g ZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
m Z ddl
m Z ddl
mZddl
mZddl
mZddlmZddlmZmZdZdZdZdZdZejd<00>Zejd<00>Z d<00>Z!d<00>Z"d <00>Z#d!<00>Z$d"<00>Z%ejd#ej&ej'B<>Z(de*e*d$<00>Z+dd%<00>Z,d&<00>Zd'<00>Zd(<00>Z-d)<00>Z.d*<00>Z/ddd+<00>Z0ejd,<00>Z1d-<00>Z2d.d/d0<00>Z3dS(1sMiscellaneous utilities.tcollapse_rfc2231_valuet decode_paramstdecode_rfc2231tencode_rfc2231t
formataddrt
formatdatet getaddressest
make_msgidt mktime_tzt parseaddrt parsedatet parsedate_tztunquotei<65><69><EFBFBD><EFBFBD>N(tquote(t AddressList(R(R
(R (t decodestring(t_bencodet_qencodes, tus
2014-07-10 23:57:08 +08:00
t's[][\\()<>@,:;".]s [][\\()"]cCs|S(N((ts((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyt _identity:scCs|s
2014-07-09 18:15:23 +08:00
|Stj|<00>S(s<>Decodes a base64 string.
This function is equivalent to base64.decodestring and it's retained only
for backward compatibility. It used to remove the last \n of the decoded
string, if it had any (see issue 7143).
2014-07-10 23:57:08 +08:00
(tbase64R(R((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyt_bdecode>scCs.tjdt|<00>}tjdt|<00>}|S(s-Replace all line-ending characters with \r\n.s (?<!\r)\ns\r(?!\n)(tretsubtCRLF(R((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pytfix_eolsKscCsZ|\}}|rVd}tj|<00>r0d}ntjd|<00>}d||||fS|S(sThe inverse of parseaddr(), this takes a 2-tuple of the form
2014-07-09 18:15:23 +08:00
(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.
Rt"s\\\g<0>s %s%s%s <%s>(t
2014-07-10 23:57:08 +08:00
specialsretsearcht escapesreR(tpairtnametaddresstquotes((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyRUs  cCs"tj|<00>}t|<00>}|jS(s7Return a list of (REALNAME, EMAIL) for each fieldvalue.(t
COMMASPACEtjoint _AddressListt addresslist(t fieldvaluestallta((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyRhs s_
2014-07-09 18:15:23 +08:00
=\? # 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 ?=
2014-07-10 23:57:08 +08:00
c CsM|d$krtj<00>}n|r<>tj|<00>}tjrO|drOtj}n tj}tt|<00>d<00>\}}|dkr<>d}nd}d|||df}n$tj|<00>}|r<>d}nd }d
2014-07-09 18:15:23 +08:00
d d d ddddg|d|dddddddddddddg |d d |d|d!|d"|d#|fS(%s<>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<><69><EFBFBD><EFBFBD>iit-t+s
2014-07-10 23:57:08 +08:00
%s%02d%02di<tGMTs-0000s"%s, %02d %s %04d %02d:%02d:%02d %stMontTuetWedtThutFritSattSuniitJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDeciiiiN( tNonettimet localtimetdaylighttaltzonettimezonetdivmodtabstgmtime( ttimevalRCtusegmttnowtoffsetthourstminutestsigntzone((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR|s.       !cCs<>tj<00>}tjdtj|<00><00>}tj<00>}tjd<00>}|dkrWd}n
2014-07-09 18:15:23 +08:00
d|}tj <00>}d|||||f}|S(s<>Returns 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.
s %Y%m%d%H%M%Si<53><69>Rt.s<%s.%s.%s%s@%s>N(
2014-07-10 23:57:08 +08:00
RBtstrftimeRItostgetpidtrandomt randrangeRAtsockettgetfqdn(tidstringRJtutcdatetpidtrandinttidhosttmsgid((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR<00>s    
2014-07-09 18:15:23 +08:00
 cCs|s
dSt|<00>S(N(RAt
2014-07-10 23:57:08 +08:00
_parsedate(tdata((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR
2014-07-09 18:15:23 +08:00
<00>scCs|s
2014-07-10 23:57:08 +08:00
dSt|<00>S(N(RAt _parsedate_tz(Ra((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR <00>scCs!t|<00>j}|sdS|dS(NRi(RR(R&R'(taddrtaddrs((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR <00>scCs<>t|<00>dkr|jd<00>rS|jd<00>rS|dd!jdd<00>jdd<00>S|jd<00>r|jd<00>r|dd!Sn|S( sRemove quotes from a string.iRi<><69><EFBFBD><EFBFBD>s\\s\s\"t<t>(tlent
startswithtendswithtreplace(tstr((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR <00>s #cCs5|jtd<00>}t|<00>dkr1dd|fS|S(s#Decode string according to RFC 2231iN(tsplittTICKRgRA(Rtparts((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR<00>s cCscddl}|j|dd<00>}|dkr=|dkr=|S|dkrRd}nd|||fS(s<>Encode string according to RFC 2231.
2014-07-09 18:15:23 +08:00
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.
2014-07-10 23:57:08 +08:00
i<><69><EFBFBD><EFBFBD>NtsafeRs%s'%s'%s(turllibR RA(RtcharsettlanguageRp((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR<00>s   s&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c Cs|}g}i}|jd<00>\}}|j||f<00>x<>|r|jd<00>\}}|jd<00>rqt}nt}t|<00>}tj|<00>}|r<>|jdd<00>\}}|dk r<>t
2014-07-09 18:15:23 +08:00
|<00>}n|j |g<00>j|||f<00>q>|j|dt |<00>f<00>q>W|r<>x<>|j <00>D]<5D>\}}g}t} |j<00>xB|D]:\}}
}|rztj|
<00>}
t} n|j|
<00>qMWt tj|<00><00>}| r<>t|<00>\} } }|j|| | d|ff<00>q$|j|d|f<00>q$Wn|S(sDecode parameters list according to RFC 2231.
params is a sequence of 2-tuples containing (param name, string value).
it*R!tnums"%s"N(tpoptappendRitTruetFalseR trfc2231_continuationtmatchtgroupRAtintt
setdefaultR titemstsortRpt EMPTYSTRINGR%R( tparamst
2014-07-10 23:57:08 +08:00
new_paramstrfc2231_paramsR!tvaluetencodedtmoRtt continuationstextendedRRqRr((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyRsD    %!
 #Rjsus-asciicCsut|t<00>rgt|d<19>}|dp,d}yt|||<00>SWqqtk
2014-07-09 18:15:23 +08:00
rct|||<00>SXn
t|<00>SdS(Niisus-ascii(t
2014-07-10 23:57:08 +08:00
isinstancettupleR tunicodet LookupError(R<>terrorstfallback_charsettrawvalRq((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyR9s (4t__doc__t__all__RTRRBRRVRXRptwarningstemail._parseaddrR RR&RR
2014-07-09 18:15:23 +08:00
R`R RbtquopriRt_qdecodetemail.encodersRRR$R<>t UEMPTYSTRINGRRmtcompileRRRRRRRtVERBOSEt
2014-07-10 23:57:08 +08:00
IGNORECASEtecreRARxRRR R RRRyRR(((s@e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\email\utils.pyt<module>sl          
2014-07-09 18:15:23 +08:00
 5      5