ofc @sLdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl mZddl mZddl mZddlmZddlmZmZdZdZdZdZdZejdZejdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&e'Z(e'd$Z)ejd%ej*ej+BZ,de.e.d&Z/dd'Z0d(Zd)Ze'd*Z1d+Z2d,Z3d-Z4d.Z5d/Z6ddd0Z7ejd1Z8d2Z9d3d4d5Z:dS(6sMiscellaneous utilities.tcollapse_rfc2231_valuet decode_paramstdecode_rfc2231tencode_rfc2231t formataddrt formatdatet getaddressest make_msgidt mktime_tzt parseaddrt parsedatet parsedate_tztunquoteiN(tquote(t AddressList(R(R (R (t decodestring(t_bencodet_qencodes, tus t's[][\\()<>@,:;".]s [][\\()"]cCs|S(N((ts((s#/usr/lib64/python2.7/email/utils.pyt _identity:scCs|s |Stj|S(sDecodes 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). (tbase64R(R((s#/usr/lib64/python2.7/email/utils.pyt_bdecode>scCs.tjdt|}tjdt|}|S(s-Replace all line-ending characters with \r\n.s (?s %s%s%s <%s>(t specialsretsearcht escapesreR(tpairtnametaddresstquotes((s#/usr/lib64/python2.7/email/utils.pyRUs  ccsd}t}xXt|D]J\}}|rC|d|fVt}q|dkrXt}q||fVqW|r{|dfVndS(Nis\(tFalset enumeratetTrue(taddrtpostescapetch((s#/usr/lib64/python2.7/email/utils.pyt_iter_escaped_charsgs   cCsd|kr|Sd}d}g}xqt|D]c\}}|dkr/|dkr\|}q||kr|j|||!n|d}d}q/q/W|t|kr|j||ndj|S(s Strip real names between quotes.RiiRN(tNoneR+tappendtlentjoin(R'tstarttopen_postresultR(R*((s#/usr/lib64/python2.7/email/utils.pyt_strip_quoted_realnamesvs        cCs|s2tjd|D}t|}|jSg|D]}t|^q9}t|}tj|}t|}t|j}d}x1|D])}t|}|d|jd7}qWt ||krdgS|S(sReturn a list of (REALNAME, EMAIL) or ('','') for each fieldvalue. When parsing fails for a fieldvalue, a 2-tuple of ('', '') is returned in its place. If strict is true, use a strict parser which rejects malformed inputs. css|]}t|VqdS(N(tstr(t.0tv((s#/usr/lib64/python2.7/email/utils.pys siit,R(RR( t COMMASPACER/t _AddressListt addresslistR4t_pre_parse_validationt_post_parse_validationR3tcountR.(t fieldvalueststricttalltaR6R'R2tn((s#/usr/lib64/python2.7/email/utils.pyRs      s_ =\? # literal =? (?P[^?]*?) # non-greedy up to the next ? is the charset \? # literal ? (?P[qb]) # either a "q" or a "b", case insensitive \? # literal ? (?P.*?) # non-greedy up to the next ?= is the atom \?= # literal ?= c CsM|d$krtj}n|rtj|}tjrO|drOtj}n tj}tt|d\}}|dkrd}nd}d|||df}n$tj|}|rd}nd }d d d d ddddg|d|dddddddddddddg |d d |d|d!|d"|d#|fS(%sReturns 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. iiit-t+s %s%02d%02di<tGMTs-0000s"%s, %02d %s %04d %02d:%02d:%02d %stMontTuetWedtThutFritSattSuniitJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDeciiiiN( R,ttimet localtimetdaylighttaltzonettimezonetdivmodtabstgmtime( ttimevalRZtusegmttnowtoffsetthourstminutestsigntzone((s#/usr/lib64/python2.7/email/utils.pyRs.       !cCstj}tjdtj|}tj}tjd}|dkrWd}n d|}tj }d|||||f}|S(sReturns 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%SiRt.s<%s.%s.%s%s@%s>N( RYtstrftimeR`tostgetpidtrandomt randrangeR,tsockettgetfqdn(tidstringRatutcdatetpidtrandinttidhosttmsgid((s#/usr/lib64/python2.7/email/utils.pyRs      cCs|s dSt|S(N(R,t _parsedate(tdata((s#/usr/lib64/python2.7/email/utils.pyR scCs|s dSt|S(N(R,t _parsedate_tz(Rx((s#/usr/lib64/python2.7/email/utils.pyR scCs|s't|j}|sdS|dSt|trC|d}nt|tsVdSt|gd}tt|j}| st|dkrdS|dS(s Parse addr into its constituent realname and email address parts. Return a tuple of realname and email address, unless the parse fails, in which case return a 2-tuple of ('', ''). If strict is True, use a strict parser which rejects malformed inputs. Rii(RR(RR(RR(R9R:t isinstancetlistR4R;R<R.(R'R?taddrs((s#/usr/lib64/python2.7/email/utils.pyR $s  cCs{t|}d}x\t|D]N\}}|dkrD|d7}q|dkr|d8}|dkrmtSqqW|dkS(Nit(it)(R3R+R$(R'topensR(R*((s#/usr/lib64/python2.7/email/utils.pyt_check_parenthesisCs       cCs=g}x0|D](}t|s(d}n|j|q W|S(Ns('', '')(RR-(temail_header_fieldstaccepted_valuesR6((s#/usr/lib64/python2.7/email/utils.pyR;Rs    cCsAg}x4|D],}d|dkr,d}n|j|q W|S(Nt[iR(RR(R-(tparsed_email_header_tuplesRR6((s#/usr/lib64/python2.7/email/utils.pyR<\s   cCst|dkr|jdrS|jdrS|dd!jddjddS|jdr|jdr|dd!Sn|S( sRemove quotes from a string.iRis\\s\s\"t(R.t startswithtendswithtreplace(R4((s#/usr/lib64/python2.7/email/utils.pyR is #cCs5|jtd}t|dkr1dd|fS|S(s#Decode string according to RFC 2231iN(tsplittTICKR.R,(Rtparts((s#/usr/lib64/python2.7/email/utils.pyRus cCscddl}|j|dd}|dkr=|dkr=|S|dkrRd}nd|||fS(sEncode 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. iNtsafeRs%s'%s'%s(turllibR R,(RtcharsettlanguageR((s#/usr/lib64/python2.7/email/utils.pyR}s   s&^(?P\w+)\*((?P[0-9]+)\*?)?$c Cs|}g}i}|jd\}}|j||fx|r|jd\}}|jdrqt}nt}t|}tj|}|r|jdd\}}|dk rt |}n|j |gj|||fq>|j|dt |fq>W|rx|j D]\}}g}t} |jxB|D]:\}} }|rztj| } t} n|j| qMWt tj|}| rt|\} } }|j|| | d|ffq$|j|d|fq$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(tpopR-RR&R$R trfc2231_continuationtmatchtgroupR,tintt setdefaultR titemstsortRt EMPTYSTRINGR/R( tparamst new_paramstrfc2231_paramsR!tvaluetencodedtmoRt continuationstextendedRRR((s#/usr/lib64/python2.7/email/utils.pyRsD    %!  #Rsus-asciicCsut|trgt|d}|dp,d}yt|||SWqqtk rct|||SXn t|SdS(Niisus-ascii(RzttupleR tunicodet LookupError(Rterrorstfallback_charsettrawvalR((s#/usr/lib64/python2.7/email/utils.pyRs (;t__doc__t__all__RkRRYRRmRoRtwarningstemail._parseaddrR RR9RR RwR RytquopriRt_qdecodetemail.encodersRRR8Rt UEMPTYSTRINGRRtcompileRRRRRRR+R3R&tsupports_strict_parsingRtVERBOSEt IGNORECASEtecreR,R$RRR RR;R<R RRRRR(((s#/usr/lib64/python2.7/email/utils.pytsx              -5       5