Viewing File: /opt/alt/python311/lib64/python3.11/email/__pycache__/_encoded_words.cpython-311.pyc



f]!4dZddlZddlZddlZddlZddlmZmZddlm	Z	gdZ
ejejdj
dZdZGd	d
eZeZdeed<d
ZdZdZdZdZeedZdZeedZeedZddZdS)z Routines for manipulating RFC2047 encoded words.

This is currently a package-private API, but will be considered for promotion
to a public API if there is demand.

N)
ascii_lettersdigits)errors)decode_qencode_qdecode_bencode_blen_qlen_bdecodeencodes=([a-fA-F0-9]{2})ct|dS)N)bytesfromhexgroupr)ms ;/opt/alt/python311/lib64/python3.11/email/_encoded_words.py<lambda>rAs(%--

 1 1 3 344cP|dd}t|gfS)N_ )replace_q_byte_subber)encodeds rrrCs(oodD))G'""B&&rc\eZdZdejdzejdzZdZdS)	_QByteMaps-!*+/asciicz||jvrt|||<nd|||<||S)Nz={:02X})safechrformat)selfkeys  r__missing__z_QByteMap.__missing__MsA$)CDII!((--DICyrN)__name__
__module____qualname__rr
rr!r&rrrrIsL*m*7333mfmG6L6LLDrr_ c@dd|DS)Nc30K|]}t|VdSN)_q_byte_map.0xs  r	<genexpr>zencode_q.<locals>.<genexpr>Zs&33a;q>333333r)joinbstrings rrrYs#
77337333333rc4td|DS)Nc3JK|]}tt|VdSr0)lenr1r2s  rr5zlen_q.<locals>.<genexpr>]s.44qs;q>""444444r)sumr7s rr
r
\s44G444444rc8t|dz}|r
ddd|z
nd}	tj||zd|rtjgngfS#t
j$r	tj|dtjgfcYS#t
j$rt	tj|dzdtjtjgfcYcYS#t
j$r|tjgfcYcYcYSwxYwwxYwwxYw)Ns===rT)validateFs==)	r;base64	b64decoderInvalidBase64PaddingDefectbinasciiErrorInvalidBase64CharactersDefectInvalidBase64LengthDefect)rpad_errmissing_paddings   rrrds'llQG,3<fZaiZ((OEW6FFF5<DV
.
0
011"
	
>EEE	E 59995778


~	E	E	E
E$Wu_uEEE9;;688:
>
E
E
E!A!C!C DDDDDDDDD

E	EEsS0AD&)BDD">C% D!D%%D
DDDDDcPtj|dS)Nr)r@	b64encoderr7s rr	r	s!G$$++G444rcZtt|d\}}|dz|rdndzS)Nr>r)divmodr;)r8groups_of_3leftovers   rrrs4"3w<<33K?82aa33r)qbc|d\}}}}}|d\}}}|}|dd}t	||\}}	||}n#t$rD|tj	d|d||d}Ynottf$r\|dd}|dkr+|tjd|d	YnwxYw||||fS)
aDecode encoded word and return (string, charset, lang, defects) tuple.

    An RFC 2047/2243 encoded word has the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' may be omitted but the other parts may not be.

    This function expects exactly such a string (that is, it does not check the
    syntax and may raise errors if the string is not well formed), and returns
    the encoded_string decoded first from its Content Transfer Encoding and
    then from the resulting bytes into unicode using the specified charset.  If
    the cte-decoded string does not successfully decode using the specified
    character set, a defect is added to the defects list and the unknown octets
    are replaced by the unicode 'unknown' character \uFDFF.

    The specified charset and language are returned.  The default for language,
    which is rarely if ever encountered, is the empty string.

    ?*rsurrogateescapez0Encoded word contains bytes not decodable using z charsetunknown-8bitzUnknown charset z* in encoded word; decoded as unknown bytes)
split	partitionlowerr

_cte_decodersrUnicodeDecodeErrorappendrUndecodableBytesDefectLookupErrorUnicodeEncodeErrorCharsetError)	ewr+charsetcte
cte_stringlangr8defectsstrings	         rrrs*&(XXc]]"AwZ((--GQ

))++C):;;G$S)'22GW
?((<<<v46F296F6F6FGG	H	H	H):;;+,???):;;==??n,,NN6.0='0=0=0=>>
?
?
??
7D'))s8BAEA)EEutf-8r.c@|dkr|dd}n||}|7td|}td|}||z
dkrdnd}t||}|rd|z}d	||||S)
aEncode string using the CTE encoding that produces the shorter result.

    Produces an RFC 2047/2243 encoded word of the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' is omitted unless the 'lang' parameter is given a value.
    Optional argument charset (defaults to utf-8) specifies the charset to use
    to encode the string to binary before CTE encoding it.  Optional argument
    'encoding' is the cte specifier for the encoding that should be used ('q'
    or 'b'); if it is None (the default) the encoding which produces the
    shortest encoded sequence is used, except that 'q' is preferred if it is up
    to five characters longer.  Optional argument 'lang' (default '') gives the
    RFC 2243 language string to specify in the encoded word.

    rVrrUNrPrQrTz=?{}{}?{}?{}?=)r
_cte_encode_length
_cte_encodersr#)rgrbencodingrer8qlenblenrs        rr
r
s".  --):;;--((!#&w//!#&w//+//33sH%g..GTz""7D(GDDDr)rhNr.)__doc__rer@rC	functoolsrgrremailr__all__partialcompilesubrrdictrr1ordrr
rr	rrZrrlrkr
r*rr<module>rzsR
			



((((((((


#":2:.C#D#D#H4466'''								ikkCCHH444555$E$E$EL555444
	
'*'*'*V
	

	
EEEEEEr
Back to Directory File Manager