
    ZTh                     <    d dl Z d dlZd dlZd dlmZ  G d d      Zy)    N)Pathc                   *    e Zd ZdZddZd Zd Zd Zy)NamedTemporaryFilez
    Created a named temporary file.

    Works on both Windows and Unix systems.

    See https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file
    for more information on Windows compatibility.
    c                 "   t        j                         | _        t        | j                        d| z  | _        |j                  d      r(t        j                  | j                  |d      | _        y t        | j                  |d      | _        y )Ntempfilez.gz )newline)	r   mkdtemptemp_dirr   nameendswithgzipopenfile)selfmodesuffixs      a/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/sift_py/data_import/tempfile.py__init__zNamedTemporaryFile.__init__   sf     ((*'HVH*==	??5!		$))T2>DITYYb9DI    c                 6    | j                   j                         S N)r   closer   s    r   r   zNamedTemporaryFile.close   s    yy  r   c                     | j                   S r   )r   r   s    r   	__enter__zNamedTemporaryFile.__enter__   s    yyr   c                    | j                   j                  s| j                   j                          	 t        j                  | j
                         t        j                  | j                         y # t        t        f$ r Y y w xY wr   )
r   closedr   osremover   rmdirr   FileNotFoundErrorPermissionError)r   exc_type	exc_value	tracebacks       r   __exit__zNamedTemporaryFile.__exit__   sY    yyIIOO	IIdii HHT]]#!?3 		s   >A1 1BBN)r   )__name__
__module____qualname____doc__r   r   r   r'    r   r   r   r      s    :!r   r   )r   r   r   pathlibr   r   r,   r   r   <module>r.      s     	     r   