
    ViK                     F    S r SSKrSSKrSr " S S\R                  5      rg)zUseful utilities for working with the `mbox`_-formatted
mailboxes. Credit to Mark Williams for these.

.. _mbox: https://en.wikipedia.org/wiki/Mbox
    Ni  @ c                   (    \ rS rSrSrSS jrS rSrg)mbox_readonlydir.   a  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
Nc                 P    [         R                  R                  XX#5        X@l        g )N)mailboxmbox__init__maxmem)selfpathfactorycreater
   s        d/home/james-whalen/.local/share/pipx/venvs/semgrep/lib/python3.13/site-packages/boltons/mboxutils.pyr	   mbox_readonlydir.__init__H   s    d':    c           
      f   U R                   (       d9  U R                  (       a'  [        R                  " U R                  5        SU l        gU R
                  c   eU R                  R                  SS5        U R                  R                  5       nXR                  :w  a%  [        R                  " SU R                  U4-  5      eU R                  R                  S5        [        R                  " 5        n0 nU R                  U5        [        U R
                  R                  5       5       H  nU R
                  U   u  pVU R                  R                  U5        U R                  U5        UR                  5       n U R                  R!                  [#        SX`R                  R                  5       -
  5      5      nUS:X  a  OUR%                  U5        MY  XrR                  5       4X4'   U R'                  U5        M     UR                  5       U l        U R                  R                  S5        UR                  S5        U R                  U R(                  ::  a*  U R                  R%                  UR!                  5       5        O7 UR!                  S5      nU(       d  OU R                  R%                  U5        M6  U R                  R+                  5         SSS5        WU l        SU l         SU l        U R,                  (       a   [        R.                  " U R                  SS9  gg! , (       d  f       NU= f)	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)i    )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   flushmbox_readonlydir.flushL   sx    }}!! ##DJJ/%*"
 yy$$$ 	

1**//#''',, .G.2.?.?-I.J K K 	

 ##%G""8,diinn./"iin

&&&x0$MMO	!ZZ__S15

8I1I.K LF|NN6*  !*==?;''1 0 !)DJJOOAMM!   DKK/

  1%]]40F!JJ$$V,	  JJ!A &F 	"<<tzz59 M &%s   4GL""
L0)r   r   r   r   r
   )NTi   )__name__
__module____qualname____firstlineno____doc__r	   r4   __static_attributes__ r   r   r   r   .   s    2L:r   r   )r:   r   r   DEFAULT_MAXMEMr   r   r<   r   r   <module>r>      s,   B   !j:w|| j:r   