o
    Q `}
                     @   s   d Z ddlmZ ddlmZ ddlZddlZddlZddlZddlm	Z	 ddl
mZ ejr5ddlmZmZ ejG d	d
 d
eZdS )aL  Manage filesystems in temporary locations.

A temporary filesytem is stored in a location defined by your OS
(``/tmp`` on linux). The contents are deleted when the filesystem
is closed.

A `TempFS` is a good way of preparing a directory structure in advance,
that you can later copy. It can also be used as a temporary data store.

    )print_function)unicode_literalsN   )errors)OSFS)OptionalTextc                       sN   e Zd ZdZ				d fdd	Zdd Zd	d
 Z fddZdd Z  Z	S )TempFSaN  A temporary filesystem on the OS.

    Arguments:
        identifier (str): A string to distinguish the directory within
            the OS temp location, used as part of the directory name.
        temp_dir (str, optional): An OS path to your temp directory
            (leave as `None` to auto-detect)
        auto_clean (bool): If `True` (the default), the directory
            contents will be wiped on close.
        ignore_clean_errors (bool): If `True` (the default), any errors
            in the clean process will be suppressed. If `False`, they
            will be raised.

    
__tempfs__NTc                    sP   || _ || _|| _d| _|dd| _ tj|pd|d| _tt	| 
| j d S )NF/-ZfsTempFS)dir)
identifier_auto_clean_ignore_clean_errors_cleanedreplacetempfileZmkdtemp	_temp_dirsuperr	   __init__)selfr   Ztemp_dirZ
auto_cleanZignore_clean_errors	__class__ +/usr/lib/python3/dist-packages/fs/tempfs.pyr   -   s   zTempFS.__init__c                 C   s   dS )NzTempFS()r   r   r   r   r   __repr__?   s   zTempFS.__repr__c                 C   s   d | jS )Nz<tempfs '{}'>)formatr   r   r   r   r   __str__C   s   zTempFS.__str__c                    s    | j r|   tt|   d S )N)r   cleanr   r	   closer   r   r   r   r!   G   s   zTempFS.closec              
   C   sd   | j rdS zt| j W n ty, } z| js"tjd||dW Y d}~nd}~ww d| _ dS )zCClean (delete) temporary files created by this filesystem.
        Nz(failed to remove temporary directory; {})msgexcT)	r   shutilrmtreer   	Exceptionr   r   ZOperationFailedr   )r   errorr   r   r   r    M   s   
zTempFS.clean)r
   NTT)
__name__
__module____qualname____doc__r   r   r   r!   r    __classcell__r   r   r   r   r	      s    r	   )r+   Z
__future__r   r   r$   r   typingZsix r   Zosfsr   ZTYPE_CHECKINGr   r   Zpython_2_unicode_compatibler	   r   r   r   r   <module>   s    