B
    Z0d                 @   s   d dl mZ d dlZd dlZd dlZd dlmZ edZdej	_
dej	_dej	_dd Zdd	 Zd
d ZedddZedd Zdd ZdS )    )contextmanagerN)HDFStoretables   c             C   s0   | d k	r,yt |  W n tk
r*   Y nX d S )N)osremoveOSError)path r
   Q/var/www/html/venv/lib/python3.7/site-packages/pandas/tests/io/pytables/common.pysafe_remove   s
    r   c             C   s.   y| d k	r|    W n tk
r(   Y nX d S )N)closer   )storer
   r
   r   
safe_close   s
    r   c             C   s   t jt | S )z'create an unopened named temporary file)r   r	   jointempfile
gettempdir)r	   r
   r
   r   create_tempfile    s    r   aFc             c   s\   z4t tj| st| } t| |||dd}|V  W d t| |dksN|dkrVt|  X d S )NF)mode	complevelcomplib
fletcher32wr   )lenr   r	   dirnamer   r   r   r   )r	   r   r   r   r   r   r
   r
   r   ensure_clean_store&   s    
r   c          	   c   sV   z8t | tr"dd | D }|V  nt| g}|d V  W dx|D ]}t| q@W X dS )z
    return essentially a named temporary file that is not opened
    and deleted on exiting; if path is a list, then create and
    return list of filenames
    c             S   s   g | ]}t |qS r
   )r   ).0pr
   r
   r   
<listcomp>B   s    z%ensure_clean_path.<locals>.<listcomp>r   N)
isinstancelistr   r   )r	   	filenamesfr
   r
   r   ensure_clean_path9   s    


r$   c          	   C   s,   y|  | W n ttfk
r&   Y nX dS )z
    For tests using tables, try removing the table to be sure there is
    no content from previous tests using the same table name.
    N)r   
ValueErrorKeyError)r   keyr
   r
   r   _maybe_removeL   s    r(   )r   NNF)
contextlibr   r   r   ZpytestZpandas.io.pytablesr   Zimportorskipr   
parametersZMAX_NUMEXPR_THREADSZMAX_BLOSC_THREADSZMAX_THREADSr   r   r   r   r$   r(   r
   r
   r
   r   <module>   s   
