o
    vi                     @  sz   d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
 ddlmZ ddlmZmZ G d	d
 d
eZd
gZdS )    )annotationsN)suppress)EACCESEEXIST)Path   )BaseFileLock)ensure_directory_existsraise_on_not_writable_filec                   @  s$   e Zd ZdZd	ddZd	ddZdS )
SoftFileLockz.Simply watches the existence of the lock file.returnNonec              
   C  s   t | j t| j tjtjB tjB tjB }ttdd }|d ur$||O }zt	| j|| j
j}W n* tyZ } z|jtksH|jtkrGtjdksO W Y d }~d S W Y d }~d S d }~ww || j
_d S )N
O_NOFOLLOWwin32)r
   	lock_filer	   osO_WRONLYO_CREATO_EXCLO_TRUNCgetattropen_contextmodeOSErrorerrnor   r   sysplatformlock_file_fd)selfflags
o_nofollowfile_handler	exception r$   M/home/air/biblejyuku/back/venv/lib/python3.10/site-packages/filelock/_soft.py_acquire   s0   


zSoftFileLock._acquirec                 C  sb   | j jd usJ t| j j d | j _tt t| j  W d    d S 1 s*w   Y  d S )N)	r   r   r   closer   r   r   r   unlink)r   r$   r$   r%   _release'   s   
"zSoftFileLock._releaseN)r   r   )__name__
__module____qualname____doc__r&   r)   r$   r$   r$   r%   r      s    
r   )
__future__r   r   r   
contextlibr   r   r   r   pathlibr   _apir   _utilr	   r
   r   __all__r$   r$   r$   r%   <module>   s    #