o
    g                     @   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   s2   | d urzt |  W d S  ty   Y d S w d S N)osremoveOSErrorpath r   ]/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pandas/tests/io/pytables/common.pysafe_remove   s   r   c                 C   s2   z| d ur|    W d S W d S  ty   Y d S w 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    z-t tj| st| } t| |||dd}|V  W t| |dks'|dkr-t|  d S d S t| |dks;|dkr@t|  w w )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   sd    z&t | trdd | D }|V  n
t| g}|d V  W |D ]}t| qdS |D ]}t| q*w )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*   z|  | W dS  ttfy   Y dS w )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   pytestpandas.io.pytablesr   importorskipr   
parametersMAX_NUMEXPR_THREADSMAX_BLOSC_THREADSMAX_THREADSr   r   r   r   r&   r*   r   r   r   r   <module>   s"    

