U
    xÊ¹j¯  ã                   @  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d„Zddœdd„ZdS )	ÚSoftFileLockz.Simply watches the existence of the lock file.ÚNone)Úreturnc              
   C  s”   t | jƒ t| jƒ tjtjB tjB tjB }zt | j|| j	j
¡}W nB tk
r† } z$|jtksv|jtkrttjdksv‚ W 5 d }~X Y n
X || j	_d S )NÚwin32)r
   Ú	lock_filer	   ÚosÚO_WRONLYÚO_CREATÚO_EXCLÚO_TRUNCÚopenÚ_contextÚmodeÚOSErrorÚerrnor   r   ÚsysÚplatformÚlock_file_fd)ÚselfÚflagsÚfile_handlerÚ	exception© r!   úM/var/www/html/bwave/python/venv/lib/python3.8/site-packages/filelock/_soft.pyÚ_acquire   s*    

ÿþýÿÿþþzSoftFileLock._acquirec              	   C  sL   | j jd k	st‚t | j j¡ d | j _ttƒ� t| jƒ 	¡  W 5 Q R X d S )N)
r   r   ÚAssertionErrorr   Úcloser   r   r   r   Úunlink)r   r!   r!   r"   Ú_release%   s
    
zSoftFileLock._releaseN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r'   r!   r!   r!   r"   r      s   r   )Ú
__future__r   r   r   Ú
contextlibr   r   r   r   Úpathlibr   Z_apir   Z_utilr	   r
   r   Ú__all__r!   r!   r!   r"   Ú<module>   s   !ÿ