Current File : //proc/self/root/lib/python3/dist-packages/twisted/mail/__pycache__/maildir.cpython-312.pyc
�

Ϫ�fLl���dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZmZmZdd	lmZmZmZdd
lmZddlmZddlmZmZd
Z Gd�d�Z!e!e�jDZ#d�Z$Gd�dejJ�Z&e
ejN�Gd�d��Z(e
ejR�Gd�d��Z*Gd�dejV�Z,e
ejZ�Gd�d��Z.e
ej^�Gd�de(��Z0e
ejb�Gd�d��Z2y)z 
Maildir-style mailbox support.
�N)�md5)�IO)�implementer)�checkers�credentials�portal)�UnauthorizedLogin)�defer�
interfaces�reactor)�mail�pop3�smtp��dirdbm)�basic)�failure�logz�From: Twisted.mail Internals
Subject: An Error Occurred

  An internal server error has occurred.  Please contact the
  server administrator.
c��eZdZdZdZej�Zej�jdd�jdd�Zd�Zd�Z
y	)
�_MaildirNameGeneratoraK
    A utility class to generate a unique maildir name.

    @type n: L{int}
    @ivar n: A counter used to generate unique integers.

    @type p: L{int}
    @ivar p: The ID of the current process.

    @type s: L{bytes}
    @ivar s: A representation of the hostname.

    @ivar _clock: See C{clock} parameter of L{__init__}.
    r�/z\057�:z\072c��||_y)z�
        @type clock: L{IReactorTime <interfaces.IReactorTime>} provider
        @param clock: A reactor which will be used to learn the current time.
        N)�_clock)�self�clocks  �6/usr/lib/python3/dist-packages/twisted/mail/maildir.py�__init__z_MaildirNameGenerator.__init__8s��
���c	��|jdz|_|jj�}tt	|��}dt	|t	|�z
dz�fz}|�d|�d|j
�d|j�d|j��	S)a�
        Generate a string which is intended to be unique across all calls to
        this function (across all processes, reboots, etc).

        Strings returned by earlier calls to this method will compare less
        than strings returned by later calls as long as the clock provided
        doesn't go backwards.

        @rtype: L{bytes}
        @return: A unique string.
        �z%07dg�cAz.M�P�Q�.)�nr�seconds�str�int�p�s)r�tr&�microsecondss    r�generatez_MaildirNameGenerator.generate?s������!�����K�K���!���c�!�f�+����a�#�a�&�j�D�%8�!9� ;�;����"�\�N�!�D�F�F�8�1�T�V�V�H�A�d�f�f�X�F�FrN)�__name__�
__module__�__qualname__�__doc__r%�os�getpidr)�socket�gethostname�replacer*rr-�rrrr$sP��
�	
�A���	�	��A������$�$�S�'�2�:�:�3��H�A��Grrc��tj|�}tjj|�s�tj|d�dD]6}tjtjj||�d��8dD]7}tjtjj|d|�d��9t
tjj|dd�d�j�yy)z�
    Create a maildir user directory if it doesn't already exist.

    @type dir: L{bytes}
    @param dir: The path name for a user directory.
    i�)�new�cur�tmp�.Trash)r9r:r;r<�
maildirfolder�wN)r2�fsdecode�path�isdir�mkdir�join�open�close)�dir�subdirs  r�initializeMaildirrHUs���
�+�+�c�
�C�
�7�7�=�=���
����e��5�	7�F��H�H�R�W�W�\�\�#�v�.��6�	7�+�	A�F��H�H�R�W�W�\�\�#�x��8�%�@�	A�	
�R�W�W�\�\�#�x��
9�3�?�E�E�G�rc�&�eZdZdZdZd�Zd�Zd�Zy)�MaildirMessagez�
    A message receiver which adds a header and delivers a message to a file
    whose name includes the size of the message.

    @type size: L{int}
    @ivar size: The number of octets in the message.
    Nc��d|z}|j|�t|�|_tjj
||g|��i|��y)a�
        @type address: L{bytes}
        @param address: The address of the message recipient.

        @type fp: file-like object
        @param fp: The file in which to store the message while it is being
            received.

        @type a: 2-L{tuple} of (0) L{bytes}, (1) L{bytes}
        @param a: Positional arguments for L{FileMessage.__init__}.

        @type kw: L{dict}
        @param kw: Keyword arguments for L{FileMessage.__init__}.
        sDelivered-To: %s
N)�write�len�sizer
�FileMessager)r�address�fp�a�kw�headers      rrzMaildirMessage.__init__rsE��'��0��
�������K��	����!�!�$��5�Q�5�"�5rc��tjj||�|xjt	|�dzz
c_y)zo
        Write a line to the file.

        @type line: L{bytes}
        @param line: A received line.
        r!N)r
rO�lineReceivedrNrM)r�lines  rrVzMaildirMessage.lineReceived�s0��	
���%�%�d�D�1��	�	�S��Y��]�"�	rc��|jd|jzz|_tjj	|�S)aO
        At the end of message, rename the file holding the message to its final
        name concatenated with the size of the file.

        @rtype: L{Deferred <defer.Deferred>} which successfully results in
            L{bytes}
        @return: A deferred which returns the name of the file holding the
            message.
        z,S=%d)�	finalNamerNr
rO�eomReceived�rs rrZzMaildirMessage.eomReceived�s4�����'�D�I�I�*=�=������+�+�D�1�1r)r.r/r0r1rNrrVrZr7rrrJrJgs����D�6�(#�2rrJc�J�eZdZdZdZdZd�Zd�Zd�Zdd�Z	d�Z
d�Zd	�Zd
�Z
y)�AbstractMaildirDomainz�
    An abstract maildir-backed domain.

    @type alias: L{None} or L{dict} mapping
        L{bytes} to L{AliasBase}
    @ivar alias: A mapping of username to alias.

    @ivar root: See L{__init__}.
    Nc��||_y)z�
        @type service: L{MailService}
        @param service: An email service.

        @type root: L{bytes}
        @param root: The maildir root directory.
        N)�root)r�servicer_s   rrzAbstractMaildirDomain.__init__�s����	rc��y)z�
        Return the maildir directory for a user.

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

        @rtype: L{bytes} or L{None}
        @return: The user's mail directory for a valid user. Otherwise,
            L{None}.
        Nr7�r�users  r�
userDirectoryz#AbstractMaildirDomain.userDirectory�s��rc��||_y)z�
        Set the group of defined aliases for this domain.

        @type alias: L{dict} mapping L{bytes} to L{IAlias} provider.
        @param alias: A mapping of domain name to alias.
        N)�alias)rrfs  r�
setAliasGroupz#AbstractMaildirDomain.setAliasGroup�s����
rc������j�jj����fd�S	�j�jj}|j	�j|���r�fd�Stjdt��z�tj���#t$rtj���wxYw)a�
        Check whether a user exists in this domain or an alias of it.

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

        @type memo: L{None} or L{dict} of L{AliasBase}
        @param memo: A record of the addresses already considered while
            resolving aliases. The default value should be used by all
            external code.

        @rtype: no-argument callable which returns L{IMessage <smtp.IMessage>}
            provider.
        @return: A function which takes no arguments and returns a message
            receiver for the user.

        @raises SMTPBadRcpt: When the given user does not exist in this domain
            or an alias of it.
        c�&���j��S�N)�startMessagerbs��r�<lambda>z.AbstractMaildirDomain.exists.<locals>.<lambda>�s���4�,�,�T�2�rc����Srjr7)�aliasess�rrlz.AbstractMaildirDomain.exists.<locals>.<lambda>�s���w�rzBad alias configuration: )rd�dest�localrf�resolver�errr'r�SMTPBadRcpt�
BaseException)rrc�memorRrns``  @r�existszAbstractMaildirDomain.exists�s����(���d�i�i�o�o�.�:�2�2�		)��
�
�4�9�9�?�?�+�A��i�i��
�
�D�1�G��&�&��G�G�/�#�d�)�;�<��"�"�4�(�(���	)��"�"�4�(�(�	)�s�#B,�,Cc
��t|t�r|jdd�\}}n,|jj|jj
}}|j
|�}t�}tjj|d|�}t|d�}t|�d|��||tjj|d|��S)z�
        Create a maildir message for a user.

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

        @rtype: L{MaildirMessage}
        @return: A message receiver for this user.
        �@r!r;r>r9)
�
isinstancer'�splitrorp�domainrd�_generateMaildirNamer2r@rCrDrJ)rrc�namer{rF�fname�filenamerQs        rrkz"AbstractMaildirDomain.startMessage�s����d�C� ��:�:�c�1�-�L�D�&��9�9�?�?�D�I�I�,<�,<�&�D�� � ��&��$�&���7�7�<�<��U�E�2��
�(�C�
 ����f�A�f�X���H�b�g�g�l�l�3��u�.M�
�	
rc��y)a�
        Check whether this domain will relay.

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

        @type protocol: L{SMTP}
        @param protocol: The protocol over which the message to be relayed is
            being received.

        @rtype: L{bool}
        @return: An indication of whether this domain will relay the message to
            the destination.
        Fr7)rrc�protocols   r�	willRelayzAbstractMaildirDomain.willRelays��rc��t�)z�
        Add a user to this domain.

        Subclasses should override this method.

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

        @type password: L{bytes}
        @param password: A password.
        ��NotImplementedError�rrc�passwords   r�addUserzAbstractMaildirDomain.addUsers
��"�!rc��t�)a

        Return credentials checkers for this domain.

        Subclasses should override this method.

        @rtype: L{list} of L{ICredentialsChecker
            <checkers.ICredentialsChecker>} provider
        @return: Credentials checkers for this domain.
        r�r[s r�getCredentialsCheckersz,AbstractMaildirDomain.getCredentialsCheckers#s
��"�!rrj)r.r/r0r1rfr_rrdrgrvrkr�r�r�r7rrr]r]�s<���
�E��D����)�B
�,�""�
"rr]c���eZdZdZeej�Zeej�Z	eej�Zeej�Z
d�Zd�Zd�Zd�Zd�Zd�Zdd	�Zd
�Zd�Zy)
� _MaildirMailboxAppendMessageTaska�
    A task which adds a message to a maildir mailbox.

    @ivar mbox: See L{__init__}.

    @type defer: L{Deferred <defer.Deferred>} which successfully returns
        L{None}
    @ivar defer: A deferred which fires when the task has completed.

    @type opencall: L{IDelayedCall <interfaces.IDelayedCall>} provider or
        L{None}
    @ivar opencall: A scheduled call to L{prodProducer}.

    @type msg: file-like object
    @ivar msg: The message to add.

    @type tmpname: L{bytes}
    @ivar tmpname: The pathname of the temporary file holding the message while
        it is being transferred.

    @type fh: file
    @ivar fh: The new maildir file.

    @type filesender: L{FileSender <basic.FileSender>}
    @ivar filesender: A file sender which sends the message.

    @type myproducer: L{IProducer <interfaces.IProducer>}
    @ivar myproducer: The registered producer.

    @type streaming: L{bool}
    @ivar streaming: Indicates whether the registered producer provides a
        streaming interface.
    c��||_tj�|_d|_t	|d�stj|�}||_y)z�
        @type mbox: L{MaildirMailbox}
        @param mbox: A maildir mailbox.

        @type msg: L{bytes} or file-like object
        @param msg: The message to add.
        N�read)�mboxr
�Deferred�openCall�hasattr�io�BytesIO�msg)rr�r�s   rrz)_MaildirMailboxAppendMessageTask.__init__Ys>����	��^�^�%��
���
��s�F�#��*�*�S�/�C���rc���|j�|jdk7r@tj�|_|jj|j|�yy)z@
        Start transferring the message to the mailbox.
        ���N)�createTempFile�fhr�
FileSender�
filesender�beginFileTransferr�r[s r�startUpz(_MaildirMailboxAppendMessageTask.startUphsH��	
�����7�7�b�=�#�.�.�0�D�O��O�O�-�-�d�h�h��=�rc�F�||_||_|s|j�yy)aS
        Register a producer and start asking it for data if it is
        non-streaming.

        @type producer: L{IProducer <interfaces.IProducer>}
        @param producer: A producer.

        @type streaming: L{bool}
        @param streaming: A flag indicating whether the producer provides a
            streaming interface.
        N)�
myproducer�	streaming�prodProducer)r�producerr�s   r�registerProducerz1_MaildirMailboxAppendMessageTask.registerProducerqs&��#���"��������rc��d|_|j�@tjd|j�|_|jj�yy)zK
        Repeatedly prod a non-streaming producer to produce data.
        Nr)r�r�r�	callLaterr��resumeProducingr[s rr�z-_MaildirMailboxAppendMessageTask.prodProducer�sD����
��?�?�&�#�-�-�a��1B�1B�C�D�M��O�O�+�+�-�'rc�v�d|_d|_|j|j�|j	�y)zA
        Finish transferring the message to the mailbox.
        N)r�r��oscloser��
moveFileToNewr[s r�unregisterProducerz3_MaildirMailboxAppendMessageTask.unregisterProducer�s.�����������T�W�W�����rc�|�	|j|j|�y#t$r|j�YywxYw)z�
        Write data to the maildir file.

        @type data: L{bytes}
        @param data: Data to be written to the file.
        N)�oswriter�rt�fail)r�datas  rrLz&_MaildirMailboxAppendMessageTask.write�s1��	��L�L����$�'���	��I�I�K�	�s��;�;Nc��|�tj�}|j�|jj�|jj|�d|_y)z�
        Fire the deferred to indicate the task completed with a failure.

        @type err: L{Failure <failure.Failure>}
        @param err: The error that occurred.
        N)r�Failurer��cancelr
�errback)rrrs  rr�z%_MaildirMailboxAppendMessageTask.fail�sH���;��/�/�#�C��=�=�$��M�M� � �"��
�
���3����
rc���	tjj|jjdt	��}	|j|j|�	|�H|jjj|�|jjd�d|_yy#t$rC}|j\}}ddl	}||jk7r|j�d}Yd}~��Yd}~nd}~wwxYw��)z�
        Place the message in the I{new/} directory, add it to the mailbox and
        fire the deferred to indicate that the task has completed
        successfully.
        r9rN)r2r@rCr�r|�osrename�tmpname�OSError�args�errno�EEXISTr��list�appendr
�callback)r�newname�err�estrr�s      rr�z._MaildirMailboxAppendMessageTask.moveFileToNew�s�����g�g�l�l�4�9�9�>�>�5�:N�:P�Q�G�
��
�
�d�l�l�G�4�����I�I�N�N�!�!�'�*��J�J����%��D�J����
��f�f���d���%�,�,�&��I�I�K�"�G��'��
��s�B(�(	C4�14C/�/C4c�J�tjtjztjzt	tdd�zt	tdd�z}d}d|_	tjj|jjdt��|_
	|j|j|d�|_y#t$rQ|dz
}|d	kDrD|jjtd
|jjz��d|_
YyYnwxYw��)zY
        Create a temporary file to hold the message as it is being transferred.
        �O_NOINHERITr�
O_NOFOLLOWr�r;i�Nr!i�z Could not create tmp file for %s)r2�O_RDWR�O_CREAT�O_EXCL�getattrr�r@rCr�r|r��osopenr�r
r��RuntimeError)r�attr�triess   rr�z/_MaildirMailboxAppendMessageTask.createTempFile�s��

�I�I��j�j�
��i�i�
��b�-��+�
,��b�,��*�	
+�	
��������7�7�<�<��	�	����?S�?U�V�D�L�
 ��+�+�d�l�l�D�%�@������	
 ���
���3�;��J�J�&�&�$�>������O���
"&�D�J���	
 ��s�$"C�AD!� D!rj)r.r/r0r1�staticmethodr2rDr�rLr�rEr��renamer�rr�r�r�r�r�r�r�r7rrr�r�0so�� �D�"�'�'�
"�F��2�8�8�$�G��2�8�8�$�G��B�I�I�&�H�
�>� �".��
���2 rr�c�@�eZdZdZeZd�Zd
d�Zd�Zd�Z	d�Z
d�Zd	�Zy)�MaildirMailboxa�
    A maildir-backed mailbox.

    @ivar path: See L{__init__}.

    @type list: L{list} of L{int} or 2-L{tuple} of (0) file-like object,
        (1) L{bytes}
    @ivar list: Information about the messages in the mailbox. For undeleted
        messages, the file containing the message and the
        full path name of the file are stored.  Deleted messages are indicated
        by 0.

    @type deleted: L{dict} mapping 2-L{tuple} of (0) file-like object,
        (1) L{bytes} to L{bytes}
    @type deleted: A mapping of the information about a file before it was
        deleted to the full path name of the deleted file in the I{.Trash/}
        subfolder.
    c
��||_g|_i|_t|�dD]v}t	j
tjj
||��D]>}|jj|tjj
|||�f��@�x|jj�|jD�cgc]}|d��	c}|_ycc}w)ze
        @type path: L{bytes}
        @param path: The directory name for a maildir mailbox.
        )r:r9r!N)	r@r��deletedrHr2�listdirrCr��sort)rr@r}�filer�s     rrzMaildirMailbox.__init__�s���
��	���	�����$��"�	I�D��
�
�2�7�7�<�<��d�#;�<�
I���	�	� � �$������T�4��(F�!G�H�
I�	I�	
�	�	����#'�9�9�-�a�Q�q�T�-��	��-s�CNc�R�|�^g}|jD]K}|r6|jtj|�tj��;|jd��M|S|j|xr3tj|j|�tjxsdS)al
        Retrieve the size of a message, or, if none is specified, the size of
        each message in the mailbox.

        @type i: L{int} or L{None}
        @param i: The 0-based index of a message.

        @rtype: L{int} or L{list} of L{int}
        @return: The number of octets in the specified message, or, if an index
            is not specified, a list of the number of octets for all messages
            in the mailbox.  Any value which corresponds to a deleted message
            is set to 0.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        r)r�r�r2�stat�ST_SIZE)r�i�ret�messs    r�listMessageszMaildirMailbox.listMessages
s���"
�9��C��	�	�
"����J�J�r�w�w�t�}�T�\�\�:�;��J�J�q�M�	
"�
�J��y�y��|�C�����	�	�!�� 5�d�l�l� C�H�q�Hrc�2�t|j|�S)aR
        Retrieve a file-like object with the contents of a message.

        @type i: L{int}
        @param i: The 0-based index of a message.

        @rtype: file-like object
        @return: A file containing the message.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        )rDr��rr�s  r�
getMessagezMaildirMailbox.getMessage%s���D�I�I�a�L�!�!rc��tjj|j|�}t	|�j�S)ar
        Get a unique identifier for a message.

        @type i: L{int}
        @param i: The 0-based index of a message.

        @rtype: L{bytes}
        @return: A string of printable characters uniquely identifying the
            message for all time.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        )r2r@�basenamer�r�	hexdigest)rr��bases   r�getUidlzMaildirMailbox.getUidl4s3���w�w����	�	�!��-���4�y�"�"�$�$rc	�L�tjj|jddtjj|j|��}tj
|j||�||j|j|<d|j|<y)aK
        Mark a message for deletion.

        Move the message to the I{.Trash/} subfolder so it can be undeleted
        by an administrator.

        @type i: L{int}
        @param i: The 0-based index of a message.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        r<r:rN)r2r@rCr�r�r�r�)rr��	trashFiles   r�
deleteMessagezMaildirMailbox.deleteMessageFsu���G�G�L�L��I�I�x�����(8�(8����1��(F�
�	�	�	�	�$�)�)�A�,�	�*�%.����T�Y�Y�q�\�"���	�	�!�rc���|jj�D]E\}}	tj||�	||j|jjd�<�G|jj�y#t$r|jj|�Y��wxYw#t$r-}|j\}}ddl
}||jk7r�Yd}~��d}~wwxYw)z�
        Undelete all messages marked for deletion.

        Move each message marked for deletion from the I{.Trash/} subfolder back
        to its original position.
        rN)
r��itemsr2r�r��index�
ValueErrorr�r�r�r��ENOENT�clear)r�real�trashr�rrr�r�s       r�undeleteMessageszMaildirMailbox.undeleteMessagesZs��� �<�<�-�-�/�	+�K�D�%�
+��	�	�%��&�+�48�D�I�I�d�i�i�o�o�a�0�1�	+� 	
�������"�+��I�I�$�$�T�*�+���
��f�f���d���%�,�,�&��'��
�s(�B(�(A>�>$B%�$B%�(	C�1#C�Cc�b�|j||�}|j}|j�|S)a
        Add a message to the mailbox.

        @type txt: L{bytes} or file-like object
        @param txt: A message to add.

        @rtype: L{Deferred <defer.Deferred>}
        @return: A deferred which fires when the message has been added to
            the mailbox.
        )�
AppendFactoryr
r�)r�txt�task�results    r�
appendMessagezMaildirMailbox.appendMessagess-���!�!�$��,�����������
rrj)
r.r/r0r1r�r�rr�r�r�r�r�r�r7rrr�r��s2���&5�M�
.�I�6
"�%�$�(�2rr�c�L�eZdZdZd�Zdd�Zdedeefd�Z	d�Z
d	�Zd
�Zd�Z
y)
�StringListMailboxz�
    An in-memory mailbox.

    @ivar  msgs: See L{__init__}.

    @type _delete: L{set} of L{int}
    @ivar _delete: The indices of messages which have been marked for deletion.
    c�0�||_t�|_y)zs
        @type msgs: L{list} of L{bytes}
        @param msgs: The contents of each message in the mailbox.
        N)�msgs�set�_delete)rr�s  rrzStringListMailbox.__init__�s��
��	��u��rNc���|�;tt|j��D�cgc]}|j|���c}S||jvryt|j|�Scc}w)ak
        Retrieve the size of a message, or, if none is specified, the size of
        each message in the mailbox.

        @type i: L{int} or L{None}
        @param i: The 0-based index of a message.

        @rtype: L{int} or L{list} of L{int}
        @return: The number of octets in the specified message, or, if an index
            is not specified, a list of the number of octets in each message in
            the mailbox.  Any value which corresponds to a deleted message is
            set to 0.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        r)�rangerMr�r�r�)rr�r�s   rr�zStringListMailbox.listMessages�sZ��"
�9�6;�C��	�	�N�6K�L�s�D�%�%�c�*�L�L��������4�9�9�Q�<� � ��Ms�A%r��returnc�F�tj|j|�S)a9
        Return an in-memory file-like object with the contents of a message.

        @param i: The 0-based index of a message.

        @return: An in-memory file-like object containing the message.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        )r�r�r�r�s  rr�zStringListMailbox.getMessage�s���z�z�$�)�)�A�,�'�'rc�N�t|j|�j�S)aP
        Get a unique identifier for a message.

        @type i: L{int}
        @param i: The 0-based index of a message.

        @rtype: L{bytes}
        @return: A hash of the contents of the message at the given index.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        )rr�r�r�s  rr�zStringListMailbox.getUidl�s ���4�9�9�Q�<� �*�*�,�,rc�:�|jj|�y)z�
        Mark a message for deletion.

        @type i: L{int}
        @param i: The 0-based index of a message to delete.

        @raise IndexError: When the index does not correspond to a message in
            the mailbox.
        N)r��addr�s  rr�zStringListMailbox.deleteMessage�s��	
������rc�"�t�|_y)zL
        Undelete any messages which have been marked for deletion.
        N)r�r�r[s rr�z"StringListMailbox.undeleteMessages�s
���u��rc�b�|jD]}d|j|<�t�|_y)zK
        Discard the contents of any messages marked for deletion.
        �N)r�r�r�)rr�s  r�synczStringListMailbox.sync�s.���\�\�	"�E�!�D�I�I�e��	"��u��rrj)r.r/r0r1rr�r(r�bytesr�r�r�r�rr7rrr�r��s<����!�.(�C�(�B�u�I�(�
-�
��rr�c�8�eZdZdZdZdZdd�Zd�Zd�Zd�Z	d�Z
y)	�MaildirDirdbmDomaina�
    A maildir-backed domain where membership is checked with a
    L{DirDBM <dirdbm.DirDBM>} database.

    The directory structure of a MaildirDirdbmDomain is:

    /passwd <-- a DirDBM directory

    /USER/{cur, new, del} <-- each user has these three directories

    @ivar postmaster: See L{__init__}.

    @type dbm: L{DirDBM <dirdbm.DirDBM>}
    @ivar dbm: The authentication database for the domain.
    Nc�F�tj|�}tj|||�tjj|d�}tjj
|�stj|�tj|�|_
||_y)av
        @type service: L{MailService}
        @param service: An email service.

        @type root: L{bytes}
        @param root: The maildir root directory.

        @type postmaster: L{bool}
        @param postmaster: A flag indicating whether non-existent addresses
            should be forwarded to the postmaster (C{True}) or
            bounced (C{False}).
        spasswdN)r2�fsencoder]rr@rCrv�makedirsrrD�dbm�
postmaster)rr`r_r
rs     rrzMaildirDirdbmDomain.__init__�sk���{�{�4� ���&�&�t�W�d�;��g�g�l�l�4��+���w�w�~�~�c�"��K�K����;�;�s�#���$��rc���||jvr|jsyd}tjj	|j
|�}tjj
|�st|�|S)aq
        Return the path to a user's mail directory.

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

        @rtype: L{bytes} or L{None}
        @return: The path to the user's mail directory for a valid user. For
            an invalid user, the path to the postmaster's mailbox if bounces
            are redirected there. Otherwise, L{None}.
        Nr
)rr
r2r@rCr_rvrH)rr}rFs   rrdz!MaildirDirdbmDomain.userDirectorysT���t�x�x���?�?���D��g�g�l�l�4�9�9�d�+���w�w�~�~�c�"��c�"��
rc�D�||j|<|j|�y)a
        Add a user to this domain by adding an entry in the authentication
        database and initializing the user's mail directory.

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

        @type password: L{bytes}
        @param password: A password.
        N)rrdr�s   rr�zMaildirDirdbmDomain.addUser$s��"���������4� rc�h�|j�t|j�g|_|jS)z�
        Return credentials checkers for this domain.

        @rtype: L{list} of L{ICredentialsChecker
            <checkers.ICredentialsChecker>} provider
        @return: Credentials checkers for this domain.
        )�
_credcheckers�DirdbmDatabaserr[s rr�z*MaildirDirdbmDomain.getCredentialsCheckers3s0�����%�"0����":�!;�D���!�!�!rc��tj|vrtd��|tjk(rttg�}n3ttjj|j|��}tj|d�fS)aw
        Get the mailbox for an authenticated user.

        The mailbox for the authenticated user will be returned only if the
        given interfaces include L{IMailbox <pop3.IMailbox>}.  Requests for
        anonymous access will be met with a mailbox containing a message
        indicating that an internal error has occurred.

        @type avatarId: L{bytes} or C{twisted.cred.checkers.ANONYMOUS}
        @param avatarId: A string which identifies a user or an object which
            signals a request for anonymous access.

        @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 (0) L{IMailbox <pop3.IMailbox>},
            (1) L{IMailbox <pop3.IMailbox>} provider, (2) no-argument
            callable
        @return: A tuple of the supported interface, a mailbox, and a
            logout function.

        @raise NotImplementedError: When the given interfaces do not include
            L{IMailbox <pop3.IMailbox>}.
        zNo interfacec��yrjr7r7rrrlz3MaildirDirdbmDomain.requestAvatar.<locals>.<lambda>cs�r)r�IMailboxr�r�	ANONYMOUSr��INTERNAL_ERRORr�r2r@rCr_)r�avatarId�mindrr�s     r�
requestAvatarz!MaildirDirdbmDomain.requestAvatar?sd��:�=�=�
�*�%�n�5�5��x�)�)�)�$�n�%5�6�D�!�"�'�'�,�,�t�y�y�(�"C�D�D��
�
�t�\�2�2r)r)r.r/r0r1rrrrdr�r�rr7rrrr�s,��� �F��M�%�*�*
!�
"�$3rrc�L�eZdZdZej
ejfZd�Zd�Z	y)rz�
    A credentials checker which authenticates users out of a
    L{DirDBM <dirdbm.DirDBM>} database.

    @type dirdbm: L{DirDBM <dirdbm.DirDBM>}
    @ivar dirdbm: An authentication database.
    c��||_y)zf
        @type dbm: L{DirDBM <dirdbm.DirDBM>}
        @param dbm: An authentication database.
        Nr)rrs  rrzDirdbmDatabase.__init__vs��
��rc��|j|jvr4|j|j|j�r|jSt��)a�
        Authenticate a user and, if successful, return their username.

        @type c: L{IUsernamePassword <credentials.IUsernamePassword>} or
            L{IUsernameHashedPassword <credentials.IUsernameHashedPassword>}
            provider.
        @param c: Credentials.

        @rtype: L{bytes}
        @return: A string which identifies an user.

        @raise UnauthorizedLogin: When the credentials check fails.
        )�usernamer�
checkPasswordr	)r�cs  r�requestAvatarIdzDirdbmDatabase.requestAvatarId}s@��
�:�:����$����t�{�{�1�:�:�6�7��z�z�!��!�!rN)
r.r/r0r1r�IUsernamePassword�IUsernameHashedPassword�credentialInterfacesrr!r7rrrrfs-���	�%�%��+�+���
�"rr)3r1r�r2r4r��hashlibr�typingr�zope.interfacer�twisted.credrrr�twisted.cred.errorr	�twisted.internetr
rr�twisted.mailr
rr�twisted.persistedr�twisted.protocolsr�twisted.pythonrrrrr-r|rHrOrJ�IAliasableDomainr]�	IConsumerr��Mailboxr�rr��IRealmr�ICredentialsCheckerrr7rr�<module>r4sU���
�	�
����&�6�6�0�7�7�)�)�$�#�'���+G�+G�\-�W�5�>�>��H�$42�T�%�%�42�n
�T�
"�
"�#�N"�N"�$�N"�b
�Z�
!�
!�"�q �q �#�q �h\�T�\�\�\�~
�T�]�]��]�]��]�@
�V�]�]��}3�/�}3��}3�@
�X�
)�
)�*�'"�'"�+�'"r
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!