U
    sVc                     @   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,zt |  W n tk
r*   Y nX d S N)osremoveOSErrorpath r   C/tmp/pip-unpacked-wheel-xj8nt62q/pandas/tests/io/pytables/common.pysafe_remove   s
    r   c                 C   s.   z| d k	r|    W n tk
r(   Y nX d S r   )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
gettempdirr
   r   r   r   create_tempfile    s    r   aFc                 c   s\   z4ttj| st| } t| |||dd}|V  W 5 t | |dksN|dkrVt|  X d S )Nwr   F)mode	complevelcomplib
fletcher32)r   r   lenr   r   dirnamer   r   )r   r   r   r   r   r   r   r   r   ensure_clean_store&   s        
r   c              	   c   sR   z8t| tr"dd | D }|V  nt| g}|d V  W 5 |D ]}t | q>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)r   
isinstancelistr   )r   	filenamesfr   r   r   ensure_clean_path9   s    

r&   c              	   C   s,   z|  | 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    

