ó {fc @sdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl mZddl mZddl mZddlmZddlmZmZdZdZdZdZdZejdƒZejdƒZ d„Z!d„Z"d „Z#d!„Z$d"„Z%ejd#ej&ej'BƒZ(de*e*d$„Z+dd%„Z,d&„Zd'„Zd(„Z-d)„Z.d*„Z/ddd+„Z0ejd,ƒZ1d-„Z2d.d/d0„Z3dS(1sMiscellaneous utilities.tcollapse_rfc2231_valuet decode_paramstdecode_rfc2231tencode_rfc2231t formataddrt formatdatet getaddressest make_msgidt mktime_tzt parseaddrt parsedatet parsedate_tztunquoteiÿÿÿÿN(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(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). (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  cCs"tj|ƒ}t|ƒ}|jS(s7Return a list of (REALNAME, EMAIL) for each fieldvalue.(t COMMASPACEtjoint _AddressListt addresslist(t fieldvaluestallta((s#/usr/lib64/python2.7/email/utils.pyRhs 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|r¨tj|ƒ}tjrO|drOtj}n tj}tt|ƒdƒ\}}|dkrˆd}nd}d|||df}n$tj|ƒ}|rÆd}nd }d 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ÿÿÿÿiit-t+s %s%02d%02di<tGMTs-0000s"%s, %02d %s %04d %02d:%02d:%02d %stMontTuetWedtThutFritSattSuniitJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDeciiiiN( tNonettimet localtimetdaylighttaltzonettimezonetdivmodtabstgmtime( ttimevalRCtusegmttnowtoffsetthourstminutestsigntzone((s#/usr/lib64/python2.7/email/utils.pyR|s.       !cCsyttjƒdƒ}tjƒ}tjdƒ}|dkrFd}n d|}tjƒ}d|||||f}|S(sõReturns a string suitable for RFC 2822 compliant Message-ID, e.g: <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. idi@Rt.s<%d.%d.%d%s@%s>N( tintRBtostgetpidtrandomt getrandbitsRAtsockettgetfqdn(tidstringRJtpidtrandinttidhosttmsgid((s#/usr/lib64/python2.7/email/utils.pyR±s     cCs|s dSt|ƒS(N(RAt _parsedate(tdata((s#/usr/lib64/python2.7/email/utils.pyR ÉscCs|s dSt|ƒS(N(RAt _parsedate_tz(R`((s#/usr/lib64/python2.7/email/utils.pyR ÏscCs!t|ƒj}|sdS|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 ('', ''). Ri(RR(R&R'(taddrtaddrs((s#/usr/lib64/python2.7/email/utils.pyR ÕscCsƒt|ƒdkr|jdƒrS|jdƒrS|dd!jddƒjddƒS|jdƒr|jdƒr|dd!Sn|S( sRemove quotes from a string.iRiÿÿÿÿs\\s\s\"t(tlent startswithtendswithtreplace(tstr((s#/usr/lib64/python2.7/email/utils.pyR ãs #cCs5|jtdƒ}t|ƒdkr1dd|fS|S(s#Decode string according to RFC 2231iN(tsplittTICKRfRA(Rtparts((s#/usr/lib64/python2.7/email/utils.pyRïs cCscddl}|j|ddƒ}|dkr=|dkr=|S|dkrRd}nd|||fS(sÜ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. iÿÿÿÿNtsafeRs%s'%s'%s(turllibR RA(RtcharsettlanguageRo((s#/usr/lib64/python2.7/email/utils.pyR÷s   s&^(?P\w+)\*((?P[0-9]+)\*?)?$c Cs|}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ƒxB|D]:\}} }|rztj| ƒ} t} n|j| ƒqMWt tj|ƒƒ}| rÞt|ƒ\} } }|j|| | d|ffƒq$|j|d|fƒ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(tpoptappendRhtTruetFalseR trfc2231_continuationtmatchtgroupRARSt setdefaultR titemstsortRot EMPTYSTRINGR%R( tparamst new_paramstrfc2231_paramsR!tvaluetencodedtmoRst continuationstextendedRRpRq((s#/usr/lib64/python2.7/email/utils.pyR sD    %!  #Risus-asciicCsut|tƒrgt|dƒ}|dp,d}yt|||ƒSWqqtk rct|||ƒSXn t|ƒSdS(Niisus-ascii(t isinstancettupleR tunicodet LookupError(R‚terrorstfallback_charsettrawvalRp((s#/usr/lib64/python2.7/email/utils.pyR>s (4t__doc__t__all__RTRRBRRVRXRotwarningstemail._parseaddrR RR&RR R_R RatquopriRt_qdecodetemail.encodersRRR$R~t UEMPTYSTRINGRRltcompileRRRRRRRtVERBOSEt IGNORECASEtecreRARwRRR R RRRxRR(((s#/usr/lib64/python2.7/email/utils.pytsl            5      5