HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/atomicfile.cpython-39.pyc
a

�*�^��@s^ddlmZddlZddlZddlmZmZe��Zda	Gdd�dej
�ZGdd�de�Z
dS)�)�absolute_importN)�errors�osutilsc@seZdZdZdd�ZdS)�AtomicFileAlreadyClosedzF"%(function)s" called on an AtomicFile after it was closed: "%(path)s"cCstjj||dd�||_dS)N)�pathZextra)r�	PathError�__init__�function)�selfrr	�r�3/usr/lib/python3/dist-packages/breezy/atomicfile.pyr&sz AtomicFileAlreadyClosed.__init__N)�__name__�
__module__�__qualname__Z_fmtrrrrrr!src@sbeZdZdZgd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
AtomicFilez�A file that does an atomic-rename to move into place.

    This also causes hardlinks to break when it's written out.

    Open this as for a regular file, then use commit() to move into
    place or abort() to cancel.
    )�tmpfilename�realfilename�_fd�wbNcCs�d|_tdurt��ad|ttt�d�f|_||_tj	tj
BtjBtjB}|dkr`|tj
O}n|dkrttd|��|dur�|}nd}t�|j||�|_|dur�t�|j�}t�|j�|kr�t�|j|�dS)Nz%s.%d.%s.%s.tmp�
rZwtzinvalid AtomicFile mode %ri�)r�	_hostnamerZ
get_host_name�_pidZ
rand_charsrr�os�O_EXCL�O_CREAT�O_WRONLYZO_NOINHERITZO_BINARY�
ValueError�open�fstat�stat�S_IMODE�st_modeZchmod_if_possible)r
�filename�modeZnew_mode�flagsZ
local_mode�strrrr6s(�zAtomicFile.__init__cCsd|jj|jfS)Nz%s(%r))�	__class__r
r�r
rrr�__repr__Ys�zAtomicFile.__repr__cCst�|j|�dS)z.Write some data to the file. Like file.write()N)r�writer)r
�datarrrr)]szAtomicFile.writecCs2|jdurt|j|d��|j}d|_t�|�dS)z<Close the local temp file in preparation for commit or abortN)rr	)rrrr�close)r
Z	func_name�fdrrr�_close_tmpfileas
�zAtomicFile._close_tmpfilecCs|�d�t�|j|j�dS)z&Close the file and move to final name.�commitN)r-r�renamerrr'rrrr.js
zAtomicFile.commitcCs|�d�t�|j�dS)z2Discard temporary file without committing changes.�abortN)r-r�removerr'rrrr0os
zAtomicFile.abortcCs|jdur|��dS)z*Discard the file unless already committed.N)rr0r'rrrr+ts
zAtomicFile.closecCs|S)Nrr'rrr�	__enter__yszAtomicFile.__enter__cCs|r|��dS|��dS)NF)r0r.)r
�exc_typeZexc_valZexc_tbrrr�__exit__|szAtomicFile.__exit__)rN)r
rr�__doc__�	__slots__rr(r)r-r.r0r+r2r4rrrrr+s
#	r)Z
__future__rrrZbreezyrr�getpidrrrr�objectrrrrr�<module>s