
    .Ph2                     D    d Z ddlZddlZdZ G d dej                  ZdS )zUseful utilities for working with the `mbox`_-formatted
mailboxes. Credit to Mark Williams for these.

.. _mbox: https://en.wikipedia.org/wiki/Mbox
    Ni  @ c                        e Zd ZdZddZd ZdS )mbox_readonlydira&  A subclass of :class:`mailbox.mbox` suitable for use with mboxs
    insides a read-only mail directory, e.g., ``/var/mail``. Otherwise
    the API is exactly the same as the built-in mbox.

    Deletes messages via truncation, in the manner of `Heirloom mailx`_.

    Args:
        path (str): Path to the mbox file.
        factory (type): Message type (defaults to :class:`rfc822.Message`)
        create (bool): Create mailbox if it does not exist. (defaults
                       to ``True``)
        maxmem (int): Specifies, in bytes, the largest sized mailbox
                      to attempt to copy into memory. Larger mailboxes
                      will be copied incrementally which is more
                      hazardous. (defaults to 4MB)

    .. note::

       Because this truncates and rewrites parts of the mbox file,
       this class can corrupt your mailbox.  Only use this if you know
       the built-in :class:`mailbox.mbox` does not work for your use
       case.

    .. _Heirloom mailx: http://heirloom.sourceforge.net/mailx.html
    NT   c                 X    t           j                            | |||           || _        d S )N)mailboxmbox__init__maxmem)selfpathfactorycreater
   s        Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/boltons/mboxutils.pyr	   zmbox_readonlydir.__init__F   s)    dD'6:::    c           
         | j         s)| j        r t          j        | j                   d| _        dS | j        J | j                            dd           | j                                        }|| j        k    rt          j	        d| j        |fz            | j                            d           t          j                    5 }i }|                     |           t          | j                                                  D ]}| j        |         \  }}| j                            |           |                     |           |                                }	 | j                            t#          d|| j                                        z
                      }|dk    rn|                    |           _||                                f||<   |                     |           |                                | _        | j                            d           |                    d           | j        | j        k    r-| j                            |                                           n4	 |                    d          }|sn| j                            |           3| j                                         ddd           n# 1 swxY w Y   || _        d| _         d| _        | j        rt          j        | j        d	           dS dS )
zWrite any pending changes to disk. This is called on mailbox
        close and is usually not called explicitly.

        .. note::

           This deletes messages via truncation. Interruptions may
           corrupt your mailbox.
        FNr      z4Size of mailbox file changed (expected %i, found %i)Ti    )dotlock)_pending_pending_syncr   _sync_flush_file_tocseektell_file_lengthExternalClashErrortempfileTemporaryFile_pre_mailbox_hooksortedkeys_pre_message_hookreadminwrite_post_message_hookr
   truncate_locked
_lock_file)	r   cur_lennew_filenew_tockeystartstop	new_startbuffers	            r   flushzmbox_readonlydir.flushJ   sC    } 	! + #DJ///%*"F
 y$$$ 	
1*//##d''', .G.2.?-I.J K K K 	
 #%%  	"G""8,,,dinn..// 2 2"int
&&&&&x000$MMOO	+!Z__S15
8I8I1I.K .K L LF||NN6***+ !*8==??;''1111 (DJOOAMM!  DK//
  1111-%]]400F! J$$V,,,	- J!!!A 	"  	"  	"  	"  	"  	"  	"  	"  	"  	"  	"  	"  	"  	"  	"F 	"< 	:tz5999999	: 	:s   G4KKK)NTr   )__name__
__module____qualname____doc__r	   r3    r   r   r   r   ,   sF         2   L: L: L: L: L:r   r   )r7   r   r   DEFAULT_MAXMEMr   r   r8   r   r   <module>r:      sj   >    !j: j: j: j: j:w| j: j: j: j: j:r   