%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/mail/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/mail/__pycache__/mail.cpython-312.pyc

�

Ϫ�faP��L�dZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZdd	lmZmZGd
�d�Zee�Gd�d
��Zeej.�Gd�d��ZGd�dej2�ZGd�dej6�Zy)z
Mail service support.
�N)�implementer)�internet�service)�Portal)�defer)�	protocols�smtp)�IAliasableDomain�IDomain)�log�utilc��eZdZdZd�Zd�Zd�Zedd��Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
efd�Zd
efd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�DomainWithDefaultDictz�
    A simulated dictionary for mapping domain names to domain objects with
    a default value for non-existing keys.

    @ivar domains: See L{__init__}
    @ivar default: See L{__init__}
    c� �||_||_y)z�
        @type domains: L{dict} of L{bytes} -> L{IDomain} provider
        @param domains: A mapping of domain name to domain object.

        @type default: L{IDomain} provider
        @param default: The default domain.
        N)�domains�default)�selfrrs   �3/usr/lib/python3/dist-packages/twisted/mail/mail.py�__init__zDomainWithDefaultDict.__init__$s��������c��||_y)z
        Set the default domain.

        @type domain: L{IDomain} provider
        @param domain: The default domain.
        N)r)r�domains  r�setDefaultDomainz&DomainWithDefaultDict.setDefaultDomain/s����rc�<�tjdtd��y)�
        Test for the presence of a domain name in this dictionary.

        This always returns C{True} because a default value will be returned
        if the name doesn't exist in this dictionary.

        @type name: L{bytes}
        @param name: A domain name.

        @rtype: L{bool}
        @return: C{True} to indicate that the domain name is in this
            dictionary.
        zotwisted.mail.mail.DomainWithDefaultDict.has_key was deprecated in Twisted 16.3.0. Use the `in` keyword instead.�)�category�
stacklevel�)�warnings�warn�DeprecationWarning�r�names  r�has_keyzDomainWithDefaultDict.has_key8s"��	�
�
�
,�(��	
�rNc�,�|�}|D]}|||<�	|S)a�
        Create a new L{DomainWithDefaultDict} with the specified keys.

        @type keys: iterable of L{bytes}
        @param keys: Domain names to serve as keys in the new dictionary.

        @type value: L{None} or L{IDomain} provider
        @param value: A domain object to serve as the value for all new keys
            in the dictionary.

        @rtype: L{DomainWithDefaultDict}
        @return: A new dictionary.
        �)�klass�keys�value�d�ks     r�fromkeyszDomainWithDefaultDict.fromkeysOs(��
�G���	�A��A�a�D�	��rc��y)rrr'r#s  r�__contains__z"DomainWithDefaultDict.__contains__cs��rc�N�|jj||j�S)a-
        Look up a domain name and, if it is present, return the domain object
        associated with it.  Otherwise return the default domain.

        @type name: L{bytes}
        @param name: A domain name.

        @rtype: L{IDomain} provider or L{None}
        @return: A domain object.
        )r�getrr#s  r�__getitem__z!DomainWithDefaultDict.__getitem__ss���|�|����d�l�l�3�3rc�"�||j|<y)z�
        Associate a domain object with a domain name in this dictionary.

        @type name: L{bytes}
        @param name: A domain name.

        @type value: L{IDomain} provider
        @param value: A domain object.
        N�r)rr$r*s   r�__setitem__z!DomainWithDefaultDict.__setitem__�s��#����T�rc��|j|=y)z�
        Delete the entry for a domain name in this dictionary.

        @type name: L{bytes}
        @param name: A domain name.
        Nr4r#s  r�__delitem__z!DomainWithDefaultDict.__delitem__�s��
�L�L��rc�,�t|j�S)z�
        Return an iterator over the domain names in this dictionary.

        @rtype: iterator over L{bytes}
        @return: An iterator over the domain names.
        )�iterr�rs r�__iter__zDomainWithDefaultDict.__iter__�s���D�L�L�!�!rc�,�t|j�S)z�
        Return the number of domains in this dictionary.

        @rtype: L{int}
        @return: The number of domains in this dictionary.
        )�lenrr:s r�__len__zDomainWithDefaultDict.__len__�s���4�<�<� � r�returnc�"�d|j�d�S)z�
        Build an informal string representation of this dictionary.

        @rtype: L{bytes}
        @return: A string containing the mapping of domain names to domain
            objects.
        z<DomainWithDefaultDict �>r4r:s r�__str__zDomainWithDefaultDict.__str__�s��)�����a�8�8rc�"�d|j�d�S)z�
        Build an "official" string representation of this dictionary.

        @rtype: L{bytes}
        @return: A pseudo-executable string describing the underlying domain
            mapping of this object.
        zDomainWithDefaultDict(�)r4r:s r�__repr__zDomainWithDefaultDict.__repr__�s��(����~�Q�7�7rc�:�|jj||�S)a�
        Look up a domain name in this dictionary.

        @type key: L{bytes}
        @param key: A domain name.

        @type default: L{IDomain} provider or L{None}
        @param default: A domain object to be returned if the domain name is
            not in this dictionary.

        @rtype: L{IDomain} provider or L{None}
        @return: The domain object associated with the domain name if it is in
            this dictionary.  Otherwise, the default value.
        )rr1�r�keyrs   rr1zDomainWithDefaultDict.get�s���|�|����W�-�-rc�^�t|jj�|j�S)z�
        Make a copy of this dictionary.

        @rtype: L{DomainWithDefaultDict}
        @return: A copy of this dictionary.
        )rr�copyrr:s rrJzDomainWithDefaultDict.copy�s"��%�T�\�\�%6�%6�%8�$�,�,�G�Grc�6�|jj�S)a�
        Return an iterator over the domain name/domain object pairs in the
        dictionary.

        Using the returned iterator while adding or deleting entries from the
        dictionary may result in a L{RuntimeError} or failing to iterate over
        all the domain name/domain object pairs.

        @rtype: iterator over 2-L{tuple} of (E{1}) L{bytes},
            (E{2}) L{IDomain} provider or L{None}
        @return: An iterator over the domain name/domain object pairs.
        )r�	iteritemsr:s rrLzDomainWithDefaultDict.iteritems�s���|�|�%�%�'�'rc�6�|jj�S)ae
        Return an iterator over the domain names in this dictionary.

        Using the returned iterator while adding or deleting entries from the
        dictionary may result in a L{RuntimeError} or failing to iterate over
        all the domain names.

        @rtype: iterator over L{bytes}
        @return: An iterator over the domain names.
        )r�iterkeysr:s rrNzDomainWithDefaultDict.iterkeys�s���|�|�$�$�&�&rc�6�|jj�S)a�
        Return an iterator over the domain objects in this dictionary.

        Using the returned iterator while adding or deleting entries from the
        dictionary may result in a L{RuntimeError} or failing to iterate over
        all the domain objects.

        @rtype: iterator over L{IDomain} provider or
            L{None}
        @return: An iterator over the domain objects.
        )r�
itervaluesr:s rrPz DomainWithDefaultDict.itervalues�s���|�|�&�&�(�(rc�6�|jj�S)z�
        Return a list of all domain names in this dictionary.

        @rtype: L{list} of L{bytes}
        @return: The domain names in this dictionary.

        )rr)r:s rr)zDomainWithDefaultDict.keys�s���|�|� � �"�"rc�6�|jj�S)z�
        Return a list of all domain objects in this dictionary.

        @rtype: L{list} of L{IDomain} provider or L{None}
        @return: The domain objects in this dictionary.
        )r�valuesr:s rrSzDomainWithDefaultDict.values	s���|�|�"�"�$�$rc�6�|jj�S)a
        Return a list of all domain name/domain object pairs in this
        dictionary.

        @rtype: L{list} of 2-L{tuple} of (E{1}) L{bytes}, (E{2}) L{IDomain}
            provider or L{None}
        @return: Domain name/domain object pairs in this dictionary.
        )r�itemsr:s rrUzDomainWithDefaultDict.itemss���|�|�!�!�#�#rc�6�|jj�S)aE
        Remove a random domain name/domain object pair from this dictionary and
        return it as a tuple.

        @rtype: 2-L{tuple} of (E{1}) L{bytes}, (E{2}) L{IDomain} provider or
            L{None}
        @return: A domain name/domain object pair.

        @raise KeyError: When this dictionary is empty.
        )r�popitemr:s rrWzDomainWithDefaultDict.popitems���|�|�#�#�%�%rc�8�|jj|�S)a�
        Update this dictionary with domain name/domain object pairs from
        another dictionary.

        When this dictionary contains a domain name which is in the other
        dictionary, its value will be overwritten.

        @type other: L{dict} of L{bytes} -> L{IDomain} provider and/or
            L{bytes} -> L{None}
        @param other: Another dictionary of domain name/domain object pairs.

        @rtype: L{None}
        @return: None.
        )r�update)r�others  rrYzDomainWithDefaultDict.update*s���|�|�"�"�5�)�)rc�6�|jj�S)zh
        Remove all items from this dictionary.

        @rtype: L{None}
        @return: None.
        )r�clearr:s rr\zDomainWithDefaultDict.clear;s���|�|�!�!�#�#rc�:�|jj||�S)a�
        Return the domain object associated with the domain name if it is
        present in this dictionary. Otherwise, set the value for the
        domain name to the default and return that value.

        @type key: L{bytes}
        @param key: A domain name.

        @type default: L{IDomain} provider
        @param default: A domain object.

        @rtype: L{IDomain} provider or L{None}
        @return: The domain object associated with the domain name.
        )r�
setdefaultrGs   rr^z DomainWithDefaultDict.setdefaultDs���|�|�&�&�s�G�4�4r�N)�__name__�
__module__�__qualname__�__doc__rrr%�classmethodr-r/r2r5r7r;r>�strrBrEr1rJrLrNrPr)rSrUrWrYr\r^r'rrrrs����	���.����&� 4�
#��"�!�9��9�8�#�8�.�"H�
(�'�)�#�%�	$�&�*�"$�5rrc�(�eZdZdZd�Zd�Zd�Zd�Zy)�BounceDomainzN
    A domain with no users.

    This can be used to block off a domain.
    c�,�tj|��)z�
        Raise an exception to indicate that the user does not exist in this
        domain.

        @type user: L{User}
        @param user: A user.

        @raise SMTPBadRcpt: When the given user does not exist in this domain.
        )r	�SMTPBadRcpt)r�users  r�existszBounceDomain.exists^s�����t�$�$rc��y)aq
        Indicate that this domain will not relay.

        @type user: L{Address}
        @param user: The destination address.

        @type protocol: L{Protocol <twisted.internet.protocol.Protocol>}
        @param protocol: The protocol over which the message to be relayed is
            being received.

        @rtype: L{bool}
        @return: C{False}.
        Fr')rrj�protocols   r�	willRelayzBounceDomain.willRelayjs��rc��y)z�
        Ignore attempts to add a user to this domain.

        @type user: L{bytes}
        @param user: A username.

        @type password: L{bytes}
        @param password: A password.
        Nr')rrj�passwords   r�addUserzBounceDomain.addUserzs��	
rc��gS)z{
        Return no credentials checkers for this domain.

        @rtype: L{list}
        @return: The empty list.
        r'r:s r�getCredentialsCheckersz#BounceDomain.getCredentialsCheckers�s	���	rN)r`rarbrcrkrnrqrsr'rrrgrgVs���
%�� 

�rrgc�(�eZdZdZd�Zd�Zd�Zd�Zy)�FileMessagez�
    A message receiver which delivers a message to a file.

    @ivar fp: See L{__init__}.
    @ivar name: See L{__init__}.
    @ivar finalName: See L{__init__}.
    c�.�||_||_||_y)a�
        @type fp: file-like object
        @param fp: The file in which to store the message while it is being
            received.

        @type name: L{bytes}
        @param name: The full path name of the temporary file.

        @type finalName: L{bytes}
        @param finalName: The full path name that should be given to the file
            holding the message after it has been fully received.
        N)�fpr$�	finalName)rrwr$rxs    rrzFileMessage.__init__�s�������	�"��rc�@�|jj|dz�y)zx
        Write a received line to the file.

        @type line: L{bytes}
        @param line: A received line.
        �
N)rw�write)r�lines  r�lineReceivedzFileMessage.lineReceived�s��	
���
�
�d�U�l�#rc���|jj�tj|j|j
�t
j|j
�S)z�
        At the end of message, rename the file holding the message to its
        final name.

        @rtype: L{Deferred} which successfully results in L{bytes}
        @return: A deferred which returns the final name of the file.
        )rw�close�os�renamer$rxr�succeedr:s r�eomReceivedzFileMessage.eomReceived�s:��	
���
�
��
�	�	�$�)�)�T�^�^�,��}�}�T�^�^�,�,rc�v�|jj�tj|j�y)zI
        Delete the file holding the partially received message.
        N)rwrr��remover$r:s r�connectionLostzFileMessage.connectionLost�s!��	
���
�
��
�	�	�$�)�)�rN)r`rarbrcrr}r�r�r'rrruru�s���#�"$�
-�rruc�Z�eZdZdZdZdZdZdZdZd�Z	d�Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zy)�MailServicea�
    An email service.

    @type queue: L{Queue} or L{None}
    @ivar queue: A queue for outgoing messages.

    @type domains: L{dict} of L{bytes} -> L{IDomain} provider
    @ivar domains: A mapping of supported domain name to domain object.

    @type portals: L{dict} of L{bytes} -> L{Portal}
    @ivar portals: A mapping of domain name to authentication portal.

    @type aliases: L{None} or L{dict} of
        L{bytes} -> L{IAlias} provider
    @ivar aliases: A mapping of domain name to alias.

    @type smtpPortal: L{Portal}
    @ivar smtpPortal: A portal for authentication for the SMTP server.

    @type monitor: L{FileMonitoringService}
    @ivar monitor: A service to monitor changes to files.
    Nc��tjj|�tit	��|_i|_t�|_|jj|�t|�|_y)z.
        Initialize the mail service.
        N)r�MultiServicerrrgr�portals�FileMonitoringService�monitor�setServiceParentr�
smtpPortalr:s rrzMailService.__init__�sV��	���%�%�d�+�,�R���@������,�.������%�%�d�+� ��,��rc�,�tj|�S)z{
        Create a POP3 protocol factory.

        @rtype: L{POP3Factory}
        @return: A POP3 protocol factory.
        )r�POP3Factoryr:s r�getPOP3FactoryzMailService.getPOP3Factory�s���$�$�T�*�*rc�B�tj||j�S)z�
        Create an SMTP protocol factory.

        @rtype: L{SMTPFactory <protocols.SMTPFactory>}
        @return: An SMTP protocol factory.
        )r�SMTPFactoryr�r:s r�getSMTPFactoryzMailService.getSMTPFactory�s���$�$�T�4�?�?�;�;rc�B�tj||j�S)z�
        Create an ESMTP protocol factory.

        @rtype: L{ESMTPFactory <protocols.ESMTPFactory>}
        @return: An ESMTP protocol factory.
        )r�ESMTPFactoryr�r:s r�getESMTPFactoryzMailService.getESMTPFactorys���%�%�d�D�O�O�<�<rc��t|�}t|j|j��||j|<||j
|<|jr2tj|�r|j|j�yyy)z�
        Add a domain for which the service will accept email.

        @type name: L{bytes}
        @param name: A domain name.

        @type domain: L{IDomain} provider
        @param domain: A domain object.
        N)
r�map�registerCheckerrsrr��aliasesr
�
providedBy�
setAliasGroup)rr$r�portals    r�	addDomainzMailService.addDomainsq�������F�"�"�F�$A�$A�$C�D�#����T��#����T���<�<�,�7�7��?�� � ����.�@�<rc��||_y)z�
        Set the queue for outgoing emails.

        @type queue: L{Queue}
        @param queue: A queue for outgoing messages.
        N)�queue)rr�s  r�setQueuezMailService.setQueues����
rc��tj|vr*tj||�}tj|d�fSt	��)a�
        Return a message delivery for an authenticated SMTP user.

        @type avatarId: L{bytes}
        @param avatarId: A string which identifies an authenticated user.

        @type mind: L{None}
        @param mind: Unused.

        @type interfaces: n-L{tuple} of C{zope.interface.Interface}
        @param interfaces: A group of interfaces one of which the avatar must
            support.

        @rtype: 3-L{tuple} of (E{1}) L{IMessageDelivery},
            (E{2}) L{ESMTPDomainDelivery}, (E{3}) no-argument callable
        @return: A tuple of the supported interface, a message delivery, and
            a logout function.

        @raise NotImplementedError: When the given interfaces do not include
            L{IMessageDelivery}.
        c��yr_r'r'rr�<lambda>z+MailService.requestAvatar.<locals>.<lambda>@s�r)r	�IMessageDeliveryr�ESMTPDomainDelivery�NotImplementedError)r�avatarId�mind�
interfaces�as     r�
requestAvatarzMailService.requestAvatar(s@��,� � �J�.��-�-�d�H�=�A��(�(�!�\�9�9�!�#�#rc� �|j|S)z�
        Find the portal for a domain.

        @type name: L{bytes}
        @param name: A domain name.

        @rtype: L{Portal}
        @return: A portal.
        �r�r#s  r�lookupPortalzMailService.lookupPortalCs���|�|�D�!�!rc� �|jdS)z�
        Return the portal for the default domain.

        The default domain is named ''.

        @rtype: L{Portal}
        @return: The portal for the default domain.
        �r�r:s r�
defaultPortalzMailService.defaultPortalOs���|�|�B��r)r`rarbrcr�rr�r�r�rr�r�r�r�r�r�r�r�r'rrr�r��sO���.
�E��G��G��G��J�'�+�<�=�/�"�$�6
"�	 rr�c�<�eZdZdZd�Zd�Zd�Zd�Zd
d�Zd�Z	d�Z
y	)r�a_
    A service for monitoring changes to files.

    @type files: L{list} of L{list} of (E{1}) L{float}, (E{2}) L{bytes},
        (E{3}) callable which takes a L{bytes} argument, (E{4}) L{float}
    @ivar files: Information about files to be monitored.  Each list entry
        provides the following information for a file: interval in seconds
        between checks, filename, callback function, time of last modification
        to the file.

    @type intervals: L{_IntervalDifferentialIterator
        <twisted.python.util._IntervalDifferentialIterator>}
    @ivar intervals: Intervals between successive file checks.

    @type _call: L{IDelayedCall <twisted.internet.interfaces.IDelayedCall>}
        provider
    @ivar _call: The next scheduled call to check a file.

    @type index: L{int}
    @ivar index: The index of the next file to be checked.
    c�Z�g|_ttjgd��|_y)z9
        Initialize the file monitoring service.
        �<N)�filesr9r
�IntervalDifferential�	intervalsr:s rrzFileMonitoringService.__init__rs$����
��d�7�7��B�?�@��rc�b�tjj|�|j�y)z4
        Start the file monitoring service.
        N)r�Service�startService�
_setupMonitorr:s rr�z"FileMonitoringService.startServiceys"��	���$�$�T�*����rc��ddlm}|jj�\}|_|j||j�|_y)z4
        Schedule the next monitoring call.
        r)�reactorN)�twisted.internetr�r��next�index�	callLater�_monitor�_call)rr��ts   rr�z#FileMonitoringService._setupMonitor�s7��	-����+�+�-�
��4�:��&�&�q�$�-�-�8��
rc��tjj|�|jr"|jj	�d|_yy)z3
        Stop the file monitoring service.
        N)rr��stopServicer��cancelr:s rr�z!FileMonitoringService.stopService�s9��	���#�#�D�)��:�:��J�J�����D�J�rc���	tjj|�}|jj||||g�|jj|�y#t$rd}Y�HwxYw)av
        Start monitoring a file for changes.

        @type name: L{bytes}
        @param name: The name of a file to monitor.

        @type callback: callable which takes a L{bytes} argument
        @param callback: The function to call when the file has changed.

        @type interval: L{float}
        @param interval: The interval in seconds between checks.
        rN)r��path�getmtime�
BaseExceptionr��appendr��addInterval)rr$�callback�interval�mtimes     r�monitorFilez!FileMonitoringService.monitorFile�s`��	��G�G�$�$�T�*�E�	
�
�
���8�T�8�U�;�<����"�"�8�,���	��E�	�s�A�A*�)A*c���tt|j��D]Q}||j|dk(s�|jj	|j|d�|j|=yy)zi
        Stop monitoring a file.

        @type name: L{bytes}
        @param name: A file name.
        rrN)�ranger=r�r��removeInterval)rr$�is   r�
unmonitorFilez#FileMonitoringService.unmonitorFile�sb���s�4�:�:��'�	�A��t�z�z�!�}�Q�'�'����-�-�d�j�j��m�A�.>�?��J�J�q�M��		rc�n�d|_|j��|j|jdd\}}}	tjj|�}||kDr<tj|�d��||j|jd<||�|j�y#t$rd}Y�_wxYw)zG
        Monitor a file and make a callback if it has changed.
        Nrrz changed, notifying listener�)
r�r�r�r�r�r�r�r�msgr�)rr$r�r��nows     rr�zFileMonitoringService._monitor�s�����
��:�:�!�$(�J�J�t�z�z�$:�1�2�$>�!�D�(�E�
��g�g�&�&�t�,���U�{����4�&� <�=�>�,/��
�
�4�:�:�&�q�)���������
!�
���
�s�B&�&B4�3B4N)�
)r`rarbrcrr�r�r�r�r�r�r'rrr�r�[s+���,A��9��-�(�rr�)rcr�r �zope.interfacer�twisted.applicationrr�twisted.cred.portalrr�r�twisted.mailrr	�twisted.mail.interfacesr
r�twisted.pythonrr
rrg�IMessagerur�r��TimerServicer�r'rr�<module>r�s���
�

��&�1�&�#�)�=�$�x5�x5�v	
�W��6�6��6�r
�T�]�]��4�4��4�nP �'�&�&�P �fg�H�1�1�gr

Zerion Mini Shell 1.0