%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.12/email/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.12/email/__pycache__/headerregistry.cpython-312.pyc

�

���fSQ��,�dZddlmZddlmZddlmZddlmZGd�d�ZGd�d	�Z	Gd
�de
�Zd�ZGd
�d�Z
Gd�de
�ZGd�d�ZGd�de�ZGd�d�ZGd�de�ZGd�de�ZGd�de�ZGd�d�ZGd�d �ZGd!�d"e�ZGd#�d$e�ZGd%�d&�ZGd'�d(�Zid)e�d*e�d+e�d,e�d-e�d.e�d/e�d0e�d1e�d2e�d3e�d4e�d5e�d6e�d7e�d8e�d9e�eeed:��ZGd;�d<�Zy=)>z�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.
�)�MappingProxyType)�utils)�errors)�_header_value_parserc�f�eZdZd
d�Zed��Zed��Zed��Zed��Zd�Z	d�Z
d	�Zy)�AddressNc	��djtd||||f��}d|vsd|vrtd��|�w|s|rtd��t	j
|�\}}|rtdj
||���|jr|jd�|j}|j}||_
||_||_y)	a�Create an object representing 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.

        �N�
�
z8invalid arguments; address parts cannot contain CR or LFz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)
�join�filter�
ValueError�	TypeError�parser�
get_addr_spec�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_spec�inputs�a_s�rests        �+/usr/lib/python3.12/email/headerregistry.py�__init__zAddress.__init__s���"�����|�X�v�y�&Q�R�S���6�>�T�V�^��W�X�X�� ��6��!8�9�9��,�,�Y�7�I�C��� �"=�=C�V�$'��>4�5�5�����o�o�a�(�(��~�~�H��Z�Z�F�)���!������c��|jS�N�r�rs r!rzAddress.display_name8����!�!�!r#c��|jSr%)rr's r!rzAddress.username<����~�~�r#c��|jSr%)rr's r!rzAddress.domain@����|�|�r#c���|j}tjj|�stj|�}|j
r|dz|j
zS|sy|S)z�The addr_spec (username@domain) portion of the address, quoted
        according to RFC 5322 rules, but with no Content Transfer Encoding.
        �@�<>)rr�
DOT_ATOM_ENDS�
isdisjoint�quote_stringr)r�lps  r!rzAddress.addr_specDsV��
�]�]���#�#�.�.�r�2��$�$�R�(�B��;�;���8�d�k�k�)�)����	r#c��dj|jj|j|j|j
�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrrr's r!�__repr__zAddress.__repr__Rs9��B�I�I����/�/��)�)�4�=�=�$�+�+�G�	Gr#c��|j}tjj|�stj|�}|r/|j
dk(rdn|j
}dj
||�S|j
S)Nr/r
z{} <{}>)rr�SPECIALSr1r2rr)r�disprs   r!�__str__zAddress.__str__Wse��� � �����)�)�$�/��&�&�t�,�D��"�n�n�d�2�����I��#�#�D�)�4�4��~�~�r#c���t|t�stS|j|jk(xr4|j|jk(xr|j
|j
k(Sr%)�
isinstancer�NotImplementedrrr�r�others  r!�__eq__zAddress.__eq__`sU���%��)�!�!��!�!�U�%7�%7�7�,��
�
����/�,����u�|�|�+�	-r#)r
r
r
N)r6�
__module__�__qualname__r"�propertyrrrrr7r;rA�r#r!rrsh��(�T�"��"�������������G�
�-r#rc�F�eZdZdd�Zed��Zed��Zd�Zd�Zd�Z	y)	�GroupNc�V�||_|rt|�|_yt�|_y)aCreate an object representing an address group.

        An address group consists of a display_name followed by colon and a
        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�	addressess   r!r"zGroup.__init__js"��*���.7�%�	�*���U�W��r#c��|jSr%r&r's r!rzGroup.display_name|r(r#c��|jSr%)rJr's r!rKzGroup.addresses�s�����r#c�x�dj|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rr5r6rrKr's r!r7zGroup.__repr__�s1��5�<�<����(�(��"�"�D�N�N�4�	4r#c�x�|j�0t|j�dk(rt|jd�S|j}|�4tj
j
|�st	j|�}djd�|jD��}|rd|zn|}dj||�S)N�r�, c3�2K�|]}t|����y�wr%)�str)�.0�xs  r!�	<genexpr>z Group.__str__.<locals>.<genexpr>�s����:�a�3�q�6�:�s�� z{}:{};)
r�lenrKrSrr9r1r2r
r)rr:�adrstrs   r!r;z
Group.__str__�s������$��T�^�^�)<�a�)?��t�~�~�a�(�)�)�� � ����F�O�O�$>�$>�t�$D��&�&�t�,�D����:�4�>�>�:�:��!'��v��V�����t�V�,�,r#c��t|t�stS|j|jk(xr|j|jk(Sr%)r=rGr>rrKr?s  r!rAzGroup.__eq__�s@���%��'�!�!��!�!�U�%7�%7�7�2����%�/�/�1�	3r#)NN)
r6rBrCr"rDrrKr7r;rArEr#r!rGrGhs?��E�$�"��"�����4�
-�3r#rGc�X�eZdZdZd�Zd�Zed��Zed��Zd�Z	e
d��Zd�Zy	)
�
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.

    c��dgi}|j||�tj|d�rtj|d�|d<tj||d�}|d=|j|fi|��|S)N�defects�decoded)�parser�_has_surrogates�	_sanitizerS�__new__�init)�cls�name�value�kwdsrs     r!rczBaseHeader.__new__�st���2����	�	�%���� � ��i��1�#�o�o�d�9�o�>�D��O��{�{�3��Y��0����O���	�	�$��$���r#c�.�||_||_||_yr%)�_name�_parse_tree�_defects)rrf�
parse_treer^s    r!rdzBaseHeader.init�s����
�%�����
r#c��|jSr%)rjr's r!rfzBaseHeader.name�s���z�z�r#c�,�t|j�Sr%)rIrlr's r!r^zBaseHeader.defects�s���T�]�]�#�#r#c��t|jj|jjt	|�f|j�fSr%)�_reconstruct_headerr5r6�	__bases__rS�__getstate__r's r!�
__reduce__zBaseHeader.__reduce__�sC������'�'����(�(��D�	�
�

����!�	!r#c�.�tj||�Sr%)rSrc)rergs  r!�_reconstructzBaseHeader._reconstruct�s���{�{�3��&�&r#c	��tjtjtj|jd�tjdd�g�g�}|j
r9|j
tjtjdd�g��|j
|j
�|j|��S)atFold header according to policy.

        The parsed representation of the header is folded according to
        RFC5322 rules, as modified by the policy.  If the parse tree
        contains surrogateescaped bytes, the bytes are CTE encoded using
        the charset 'unknown-8bit".

        Any non-ASCII characters in the parse tree are CTE encoded using
        charset utf-8. XXX: make this a policy setting.

        The returned value is an ASCII-only string possibly containing linesep
        characters, and ending with a linesep character.  The string includes
        the header name and the ': ' separator.

        zheader-name�:z
header-seprW�fws)�policy)
r�Header�HeaderLabel�
ValueTerminalrfrk�append�CFWSList�WhiteSpaceTerminal�fold)rrz�headers   r!r�zBaseHeader.fold�s���"�������$�$�T�Y�Y�
�>��$�$�S�,�7� 9�
:� ���
����M�M�����!:�!:�3��!F� G�H�
J��
�
�d�&�&�'��{�{�&�{�)�)r#N)
r6rBrC�__doc__rcrdrDrfr^rt�classmethodrvr�rEr#r!r\r\�sX���@� �
�����$��$�!��'��'�*r#r\c�:�t||i�j|�Sr%)�typerv)�cls_name�basesrgs   r!rqrqs����%��$�1�1�%�8�8r#c�D�eZdZdZeej�Zed��Z	y)�UnstructuredHeaderNc�N�|j|�|d<t|d�|d<y)Nrmr_)�value_parserrS�rergrhs   r!r`zUnstructuredHeader.parse	s*�� �-�-�e�4��\���d�<�0�1��Y�r#)
r6rBrC�	max_count�staticmethodr�get_unstructuredr�r�r`rEr#r!r�r�s)���I��� 7� 7�8�L��2��2r#r�c��eZdZdZy)�UniqueUnstructuredHeaderrPN�r6rBrCr�rEr#r!r�r�����Ir#r�c�j��eZdZdZdZeej�Ze	d��Z
�fd�Zed��Z
�xZS)�
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.
    Nc��|sH|djtj��d|d<d|d<tj�|d<yt|t�r||d<	tj|�}||d<tj|d�|d<|j|d�|d<y#t$rF|djtjd��d|d<tj�|d<YywxYw)Nr^�datetimer
r_rmzInvalid date value or format)
r~r�HeaderMissingRequiredValuer�	TokenListr=rSr�parsedate_to_datetimer�InvalidDateDefect�format_datetimer�r�s   r!r`zDateHeader.parse$s������O�"�"�6�#D�#D�#F�G�#�D��� �D��O�!'�!1�!1�!3�D�����e�S�!�#�D��O�
��3�3�E�:��!��Z���/�/��Z�0@�A��Y�� �-�-�d�9�o�>��\����
��Y��&�&�v�'?�'?�@^�'_�`�#'��Z� �%+�%5�%5�%7��\�"��	
�s�!B.�.AC=�<C=c�P��|jd�|_t�|�|i|��y)Nr�)�pop�	_datetime�superrd�r�args�kwr5s   �r!rdzDateHeader.init9s$������
�+���
���d�!�b�!r#c��|jSr%)r�r's r!r�zDateHeader.datetime=r*r#)r6rBrCr�r�r�rr�r�r�r`rdrDr��
__classcell__�r5s@r!r�r�sL�����I� �� 7� 7�8�L��?��?�("����r#r�c��eZdZdZy)�UniqueDateHeaderrPNr�rEr#r!r�r�Br�r#r�c�b��eZdZdZed��Zed��Z�fd�Ze	d��Z
e	d��Z�xZS)�
AddressHeaderNc�H�tj|�\}}|rJd��|S)Nzthis should not happen)r�get_address_list)rg�address_lists  r!r�zAddressHeader.value_parserKs+��$�5�5�e�<���e��2�2�2�y��r#c��t|t�r�|j|�x|d<}g}|jD]t}|j	t|j|jD�cgc]9}t|jxsd|jxsd|jxsd���;c}���vt|j�}n9t|d�s|g}|D�cgc]}t|d�s
td|g�n|��}}g}||d<||d<dj|D�cgc]
}t|���c}�|d<d|vr|j|d�|d<yycc}wcc}wcc}w)	Nrmr
�__iter__rK�groupsr^rQr_)r=rSr�rKr~rGr�
all_mailboxesrrr�listr�hasattrr
)	rergrhr�r��addr�mbr^�items	         r!r`zAddressHeader.parseQsy���e�S�!�14�0@�0@��0G�G�D�����F�$�.�.�
E���
�
�e�D�$5�$5�04�/A�/A�%C�*,�&-�R�_�_�-B��-/�]�]�-@�b�-/�Y�Y�_�"�&>�%C�D�E�
E��<�3�3�4�G��5�*�-����16�7�(,�29��{�1K�e�D�4�&�)�/3�4�7�F�7��G���X��!��Y���)�)�6�$B�4�S��Y�$B�C��Y���t�#�!$�!1�!1�$�y�/�!B�D���$��!%C��7��%Cs�!>E
�"E�Ec�p��t|jd��|_d|_t	�|�|i|��y)Nr�)rIr��_groupsrJr�rdr�s   �r!rdzAddressHeader.initms0����R�V�V�H�-�.������
���d�!�b�!r#c��|jSr%)r�r's r!r�zAddressHeader.groupsrr,r#c�t�|j�!td�|jD��|_|jS)Nc3�BK�|]}|jD]}|����y�wr%)rK)rT�group�addresss   r!rVz*AddressHeader.addresses.<locals>.<genexpr>ys1����$L��;@�?�?�$L�07�%,�$L�G�$L�s�)rJrIr�r's r!rKzAddressHeader.addressesvs5���?�?�"�#�$L����$L�L�D�O����r#)
r6rBrCr�r�r�r�r`rdrDr�rKr�r�s@r!r�r�Gs]����I�����
�C��C�6"�
�������r#r�c��eZdZdZy)�UniqueAddressHeaderrPNr�rEr#r!r�r�~r�r#r�c��eZdZed��Zy)�SingleAddressHeaderc��t|j�dk7r$tdj|j���|jdS)NrPz9value of single address header {} is not a single addressr)rXrKrrrfr's r!r�zSingleAddressHeader.address�sB���t�~�~���!��#�$*�F�4�9�9�$5�7�
7��~�~�a� � r#N)r6rBrCrDr�rEr#r!r�r��s��
�!��!r#r�c��eZdZdZy)�UniqueSingleAddressHeaderrPNr�rEr#r!r�r��r�r#r�c���eZdZdZeej�Zed��Z	�fd�Z
ed��Zed��Z
ed��Z�xZS)�MIMEVersionHeaderrPc�:�|j|�x|d<}t|�|d<|dj|j�|j�dn|j
|d<|j|d<|j�dj
|d|d�|d<yd|d<y)Nrmr_r^�major�minorz{}.{}�version)r�rS�extendrr�r�r�rergrhrms    r!r`zMIMEVersionHeader.parse�s���*-�*:�*:�5�*A�A��\��Z��j�/��Y���Y����z�5�5�6� *� 0� 0� 8��j�>N�>N��W�
�"�(�(��W�
����'�%�n�n�T�'�]�D��M�J�D��O�"�D��Or#c���|jd�|_|jd�|_|jd�|_t	�|�|i|��y)Nr�r�r�)r��_version�_major�_minorr�rdr�s   �r!rdzMIMEVersionHeader.init�sB������y�)��
��f�f�W�o����f�f�W�o���
���d�!�b�!r#c��|jSr%)r�r's r!r�zMIMEVersionHeader.major�����{�{�r#c��|jSr%)r�r's r!r�zMIMEVersionHeader.minor�r�r#c��|jSr%)r�r's r!r�zMIMEVersionHeader.version�����}�}�r#)r6rBrCr�r�r�parse_mime_versionr�r�r`rdrDr�r�r�r�r�s@r!r�r��sk����I��� 9� 9�:�L��	#��	#�"������������r#r�c�B��eZdZdZed��Z�fd�Zed��Z�xZ	S)�ParameterizedMIMEHeaderrPc�f�|j|�x|d<}t|�|d<|dj|j�|j�i|d<y|jD��cic]<\}}tj|�j�tj|���>c}}|d<ycc}}w)Nrmr_r^�params)r�rSr�rr�rrb�lower)rergrhrmrfs     r!r`zParameterizedMIMEHeader.parse�s���*-�*:�*:�5�*A�A��\��Z��j�/��Y���Y����z�5�5�6����$��D��N�
3=�2C�2C�E�#.�4��$�o�o�d�3�9�9�;�$)�O�O�E�$:�;�E�D��N��Es�$AB-c�P��|jd�|_t�|�|i|��y)Nr�)r��_paramsr�rdr�s   �r!rdzParameterizedMIMEHeader.init�s$����v�v�h�'���
���d�!�b�!r#c�,�t|j�Sr%)rr�r's r!r�zParameterizedMIMEHeader.params�s������-�-r#)
r6rBrCr�r�r`rdrDr�r�r�s@r!r�r��s7���
�I��
E��
E�"��.��.r#r�c�r��eZdZeej
�Z�fd�Zed��Z	ed��Z
ed��Z�xZS)�ContentTypeHeaderc����t�|�|i|��tj|jj
�|_tj|jj�|_yr%)	r�rdrrbrk�maintype�	_maintype�subtype�_subtyper�s   �r!rdzContentTypeHeader.init�sL���
���d�!�b�!�����)9�)9�)B�)B�C�������(8�(8�(@�(@�A��
r#c��|jSr%)r�r's r!r�zContentTypeHeader.maintype�r*r#c��|jSr%)r�r's r!r�zContentTypeHeader.subtype�r�r#c�:�|jdz|jzS)N�/)r�r�r's r!�content_typezContentTypeHeader.content_type�s���}�}�s�"�T�\�\�1�1r#)
r6rBrCr�r�parse_content_type_headerr�rdrDr�r�r�r�r�s@r!r�r��sU����� @� @�A�L�B�
���������2��2r#r�c�R��eZdZeej
�Z�fd�Zed��Z	�xZ
S)�ContentDispositionHeaderc���t�|�|i|��|jj}|�||_yt	j
|�|_yr%)r�rdrk�content_dispositionrrb�_content_disposition)rr�r��cdr5s    �r!rdzContentDispositionHeader.init�sA���
���d�!�b�!�
�
�
�
1�
1��*,�*�B��!�%�/�/�"�:M��!r#c��|jSr%)r�r's r!r�z,ContentDispositionHeader.content_disposition�s���(�(�(r#)r6rBrCr�r� parse_content_disposition_headerr�rdrDr�r�r�s@r!r�r��s-����� G� G�H�L�N�
�)��)r#r�c�f��eZdZdZeej�Zed��Z	�fd�Z
ed��Z�xZ
S)�ContentTransferEncodingHeaderrPc��|j|�x|d<}t|�|d<|dj|j�y�Nrmr_r^�r�rSr�rr�s    r!r`z#ContentTransferEncodingHeader.parse��A��*-�*:�*:�5�*A�A��\��Z��j�/��Y���Y����z�5�5�6r#c���t�|�|i|��tj|jj
�|_yr%)r�rdrrbrk�cte�_cter�s   �r!rdz"ContentTransferEncodingHeader.inits0���
���d�!�b�!��O�O�D�$4�$4�$8�$8�9��	r#c��|jSr%)r�r's r!r�z!ContentTransferEncodingHeader.ctes���y�y�r#)r6rBrCr�r�r�&parse_content_transfer_encoding_headerr�r�r`rdrDr�r�r�s@r!r�r��sC����I��� M� M�N�L��7��7�
:����r#r�c�D�eZdZdZeej�Zed��Z	y)�MessageIDHeaderrPc��|j|�x|d<}t|�|d<|dj|j�yr�r�r�s    r!r`zMessageIDHeader.parser�r#N)
r6rBrCr�r�r�parse_message_idr�r�r`rEr#r!rr
s)���I��� 7� 7�8�L��7��7r#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-encodingz
message-idc�0�eZdZdZeedfd�Zd�Zd�Zd�Z	y)�HeaderRegistryz%A header_factory and header registry.Tc�r�i|_||_||_|r |jjt�yy)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)rrr�use_default_maps    r!r"zHeaderRegistry.__init__6s5����
�$���*�����M�M� � �!4�5�r#c�>�||j|j�<y)zLRegister cls as the specialized class for handling "name" headers.

        N)rr��rrfres   r!�map_to_typezHeaderRegistry.map_to_typeHs��'*��
�
�d�j�j�l�#r#c��|jj|j�|j�}t	d|j
z||jfi�S)N�_)r�getr�rr�r6rrs   r!�__getitem__zHeaderRegistry.__getitem__NsE���m�m����
�
��d�.@�.@�A���C����$�s�D�O�O�&<�b�A�Ar#c��||||�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.

        rE)rrfrgs   r!�__call__zHeaderRegistry.__call__Rs���t�D�z�$��&�&r#N)
r6rBrCr�r\r�r"rrrrEr#r!rr2s#��/�",�<N�'+�6�$*�B�
'r#rN)r��typesr�emailrrrrrrGrSr\rqr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrEr#r!�<module>rs����
#���0�Y-�Y-�x/3�/3�ha*��a*�H9�2�2��1��
+�+�\�z��
4�4�n�-��
!�-�!�� 3��
"�"�J.�.�:2�/�2�,)�6�)���*	7�	7��
�$<��
�$4���J���$4�	�

�$=���$7�
�	�$7���M��	�$7���M��
�$7���M���$7���M���$7�� �$5�!�"�$5�#�$%=�$A�$3�)��.*'�*'r#

Zerion Mini Shell 1.0