/usr/lib64/python3.9/email/__pycache__
Edit: /usr/lib64/python3.9/email/__pycache__/utils.cpython-39.opt-1.pyc (12735B)
a
à”|jYH ã @ s d Z g d¢ZddlZddlZddlZddlZddlZddlZddlZ ddl
mZ ddl
mZ
ddl
mZ ddl
mZmZmZ ddlmZ d Zd
Zd
ZdZdZe d
¡Ze d¡ZdZdadd„ Zdd„ Zdd„ Z dd„ Z!dFdd„Z"dd„ Z#dd„ Z$dZ%dd œd!d"„Z&d#d$„ Z'd%d&„ Z(d'd(„ Z)d)d*„ Z*dGd,d-„Z+dHd.d/„Z,dId0d1„Z-d2d3„ Z.dd œd4d5„Z/d6d7„ Z0d8d9„ Z1dJd:d;„Z2e d
„ Z5dKdAdB„Z6dLdDdE„Z7dS )MzMiscellaneous utilities.)Úcollapse_rfc2231_valueÚ
decode_paramsÚdecode_rfc2231Úencode_rfc2231Ú
formataddrÚ
formatdateÚformat_datetimeÚgetaddressesÚ
make_msgidÚ mktime_tzÚ parseaddrÚ parsedateÚparsedate_tzÚparsedate_to_datetimeÚunquoteé N)Úquote)ÚAddressList)r
)r r
Ú
_parsedate_tz)ÚCharsetz, Ú z
ú'z[][\\()<>@,:;".]z[\\"]z/etc/python/email.cfgc C s t du rtƒ a t S )z5"Cache implementation for _cached_strict_addr_parsingN)Ú_cached_strict_addr_parsingÚ_use_strict_email_parsing_impl© r r ú#/usr/lib64/python3.9/email/utils.pyÚ_use_strict_email_parsing7 s r c C s˜ t tj d¡ƒ} | rdS zttƒ}W n ty6 Y nV0 |�@ ddl}|jddd�}| |¡ |j
dddd�} W d ƒ n1 s‚0 Y | r”dS d S )
z]Returns True if strict email parsing is not disabled by
config file or env variable.
Z(PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSINGFr N)ú#)Z
interpolationZcomment_prefixesZemail_addr_parsing)ÚfallbackT)ÚboolÚosÚenvironÚgetÚopenÚ_EMAIL_CONFIG_FILEÚFileNotFoundErrorÚconfigparserÚConfigParserZ read_fileZ
getboolean)ÚdisabledÚfiler% Zconfigr r r r ? s$ þ
.r c C s( z| ¡ W dS ty" Y dS 0 dS )z8Return True if s contains surrogate-escaped binary data.FTN)ÚencodeÚUnicodeEncodeError)Úsr r r Ú_has_surrogates\ s
r, c C s | dd¡}| dd¡S )Núutf-8ÚsurrogateescapeÚreplace)r) Údecode)ÚstringZoriginal_bytesr r r Ú _sanitizei s r2 r- c C s’ | \}}| d¡ |rŽz| d¡ W n: ty^ t|tƒrDt|ƒ}| |¡}d||f Y S 0 d}t |¡rrd}t d|¡}d||||f S |S )aú 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.
The optional charset 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'.
Úasciiz%s <%s>r ú"z\\\g<0>z%s%s%s <%s>)
r) r* Ú
isinstanceÚstrr Z
header_encodeÚ
specialsreÚsearchÚ escapesreÚsub)ZpairÚcharsetÚnameÚaddressZencoded_nameZquotesr r r r u s
r c c s\ d}d}t | ƒD ]8\}}|r0|d| fV d}q|dkr>d}q||fV q|rX|dfV d S )Nr Fú\T)Ú enumerate)ÚaddrÚposÚescapeÚchr r r Ú_iter_escaped_chars– s rD c C sŽ d| vr| S d}d}g }t | ƒD ]D\}}|dkr |du r>|}q ||krX| | ||… ¡ |d }d}q |t| ƒk r„| | |d… ¡ d |¡S )z Strip real names between quotes.r4 r Né r )rD ÚappendÚlenÚjoin)r@ ÚstartZopen_posÚresultrA rC r r r Ú_strip_quoted_realnames¥ s rK T)Ústrictc C s¤ |dkrt ƒ }|s4t dd„ | D ƒ¡}t|ƒ}|jS dd„ | D ƒ} t| ƒ} t | ¡}t|ƒ}t|jƒ}d}| D ]}t|ƒ}|d| d¡ 7 }qnt |ƒ|kr d gS |S )
zñReturn 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.
Nc s s | ]}t |ƒV qd S )N©r6 ©Ú.0Úvr r r Ú Ø ó zgetaddresses..c S s g | ]}t |ƒ‘qS r rM rN r r r Ú
Ü rR z getaddresses..r rE ú,©r r )
r Ú
COMMASPACErH Ú_AddressListÚaddresslistÚ_pre_parse_validationÚ_post_parse_validationrK ÚcountrG )ZfieldvaluesrL ÚallÚar@ rJ ÚnrP r r r r À s$
r c C sV t | ƒ} d}t| ƒD ]8\}}|dkr.|d7 }q|dkr|d8 }|dk r dS q|dkS )Nr ú(rE ú)F)rK rD )r@ ZopensrA rC r r r Ú_check_parenthesisñ s
ra c C s( g }| D ]}t |ƒsd}| |¡ q|S )Nz('', ''))ra rF )Zemail_header_fieldsÚaccepted_valuesrP r r r rY s rY c C s, g }| D ]}d|d v rd}| |¡ q|S )Nú[rE rU )rF )Zparsed_email_header_tuplesrb rP r r r rZ
s rZ c C sH dg d¢| d | d g d¢| d d | d | d | d | d
|f S )Nz"%s, %02d %s %04d %02d:%02d:%02d %s)ZMonZTueZWedZThuZFriZSatZSuné é )ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrE r é é é r )Ú timetupleÚzoner r r Ú_format_timetuple_and_zone s
ÿúrk Fc C sR | du rt ¡ } |s|r,tj | tjj¡}ntj | ¡}|rH| ¡ }d}t||ƒS )aƒ 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.
NF)ÚtimeÚdatetimeZ
fromtimestampÚtimezoneÚutcZutcfromtimestampÚ
astimezoner )ÚtimevalÚ localtimeÚusegmtÚdtr r r r s r c C sV | ¡ }|r2| jdu s$| jtjjkr,tdƒ‚d}n| jdu rBd}n
| d¡}t||ƒS )a$ 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.
Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)ri Útzinform rn ro Ú
ValueErrorÚstrftimerk )rt rs Únowrj r r r r < s
r c C s^ t t ¡ d ƒ}t ¡ }t d¡}| du r0d} nd| } |du rHt ¡ }d|||| |f }|S )a{ 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. Optional domain if given provides the
portion of the message id after the '@'. It defaults to the locally
defined hostname.
éd é@ Nr Ú.z<%d.%d.%d%s@%s>)Úintrl r ÚgetpidÚrandomÚgetrandbitsÚsocketÚgetfqdn)ZidstringÚdomainrq ÚpidÚrandintZmsgidr r r r O s
r c C sN t | ƒ�^ }}|d u r(tj|d d… Ž S tj|d d… dt tj|d�¡iŽS )Nrd ru ©Úseconds)r rm rn Ú timedelta)ÚdataZdtupleÚtzr r r r f s ÿr c C s„ |dkrt ƒ }|s,t| ƒj}|s$dS |d S t| tƒr>| d } t| tƒsLdS t| gƒd } tt| ƒjƒ}|rxt|ƒdkr|dS |d S )a
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.
NrU r rE ) r rW rX r5 Úlistr6 rY rZ rG )r@ rL Úaddrsr r r r n s
r c C s` t | ƒdkr\| d¡r<| d¡r<| dd… dd¡ dd¡S | d¡r\| d¡r\| dd… S | S ) zRemove quotes from a string.rE r4 éÿÿÿÿz\\r> z\"ú<ú>)rG Ú
startswithÚendswithr/ rM r r r r ’ s r c C s&