+
    2j
                        R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHt ]'       d   ^ RIHt RR.t]P                   ! 4       tR	 R
 lt]R R l4       tR R ltR R ltR# )zWrite a file by staging it beside the destination and renaming over it.

Shared by the on-disk cache and the lockfile emitters. A write that fails
partway leaves any existing file untouched.
)annotationsN)contextmanager)Path)TYPE_CHECKING)Iteratoratomic_writeatomic_write_textc                   V ^8  d   QhRR/# )   returnint )formats   "[/home/user/billing-ledger-validation/.venv/lib/python3.14/site-packages/nab_index/atomic.py__annotate__r      s     
 
s 
    c                     \         ;_uu_ 4        \        P                  ! ^?4      p \        P                  ! V 4       RRR4       RX ( ,          #   + '       g   i     L; i)zReturn the mode ``open`` would have given a new file.

The umask can only be read by setting it, so set a restrictive one and
put it straight back, under a lock because the cache writes from the
fetch threads.
Ni  )_umask_lockosumask)r   s    r   _default_moder      s<     

 
 E6> 
s   -AA	c                    V ^8  d   QhRRRR/# )r
   pathr   r   zIterator[int]r   )r   s   "r   r   r   ,   s      $ = r   c              #    "   \         P                  ! V P                  V P                  R,           RR7      w  r\	        V4      p Vx  V P                  4       '       d   \        P                  ! W4       MVP                  \        4       4       \        P                  ! W04       R#   \         dQ    \        P                  ! \        4      ;_uu_ 4        TP!                  4        RRR4       h   + '       g   i     h ; ii ; i5i)zYield a file descriptor for a temp file beside ``path``.

On a clean exit the temp file is renamed over ``path``; on any exception it
is removed and ``path`` is left as it was. Staging in the destination
directory keeps the rename on one filesystem.
.z.tmp)dirprefixsuffixN)tempfilemkstempparentnamer   existsshutilcopymodechmodr   r   replaceBaseException
contextlibsuppressOSErrorunlink)r   fdtmptmp_paths   &   r   _stagedr/   +   s      4;;tyy3vVGBCyH ;;==OOD+NN=?+ 	

8"   ))OO * *)s7   ADA B' %D'-DC.%	D.C>9	DDc               $    V ^8  d   QhRRRRRR/# )r
   r   r   databytesr   Noner   )r   s   "r   r   r   H   s!      t 5 T r   c           	     f   \        V 4      ;_uu_ 4       p\        P                  ! VR4      ;_uu_ 4       pVP                  V4       VP	                  4        \        P
                  ! VP                  4       4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zReplace ``path`` with ``data``.wbNr/   r   fdopenwriteflushfsyncfileno)r   r1   r,   fs   &&  r   r   r   H   s^    	"biiD11Q	 	
	
 211s#    BAB	:BBBB0	c               $    V ^8  d   QhRRRRRR/# )r
   r   r   textstrr   r3   r   )r   s   "r   r   r   S   s!      D   r   c           	     j   \        V 4      ;_uu_ 4       p\        P                  ! VRRR7      ;_uu_ 4       pVP                  V4       VP	                  4        \        P
                  ! VP                  4       4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z1Replace ``path`` with ``text``, encoded as UTF-8.wzutf-8)encodingNr6   )r   r>   r,   r<   s   &&  r   r   r   S   s_    	"biiC'BBa			
	 CBBs#   "B!AB	<B!BB!!B2	)__doc__
__future__r   r(   r   r#   r   	threadingr   pathlibr   typingr   collections.abcr   __all__Lockr   r   r/   r   r   r   r   r   <module>rK      sm    #  	    %   ( 
 nn
  8r   