B
    lnd_                 @   s   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZdZdd Z	e
fddZddd	Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )    NzApyarrow.{} is deprecated as of {}, please use pyarrow.{} instead.c                s    fdd}|S )Nc                s    j | _ | S )N)__doc__)g)f 0/tmp/pip-unpacked-wheel-i2z0tf32/pyarrow/util.py	decorator$   s    zimplements.<locals>.decoratorr   )r   r   r   )r   r   
implements#   s    r   c                s"   t | || fdd}|S )Nc                 s   t   | |S )N)warningswarn)argskwargs)apimsgtyper   r   wrapper-   s    z_deprecate_api.<locals>.wrapper)	_DEPR_MSGformat)old_namenew_namer   next_versionr   r   r   )r   r   r   r   _deprecate_api*   s    r   Tc                s&   G  fdddt }| fi S )zM
    Raise warning if a deprecated class is used in an isinstance check.
    c                   s   e Zd Z fddZdS )z)_deprecate_class.<locals>._DeprecatedMetac                s&   t jt jtdd t| S )N   )
stacklevel)r	   r
   r   r   __name__FutureWarning
isinstance)selfother)	new_classr   r   r   r   __instancecheck__9   s
    z;_deprecate_class.<locals>._DeprecatedMeta.__instancecheck__N)r   
__module____qualname__r   r   )r   r   r   r   r   _DeprecatedMeta8   s   r"   )r   )r   r   r   Zinstancecheckr"   r   )r   r   r   r   _deprecate_class3   s    	r#   c             C   s&   yt |  dS  tk
r    dS X d S )NTF)iter	TypeError)objr   r   r   _is_iterableD   s
    r'   c             C   s   t | tpt| dS )N
__fspath__)r   strhasattr)pathr   r   r   _is_path_likeL   s    r,   c             C   sH   t | trtj| S ytj|  S  tk
r:   Y nX tddS )zA
    Convert *path* to a string or unicode path if possible.
    znot a path-like objectN)r   r)   osr+   
expanduserr(   AttributeErrorr%   )r+   r   r   r   _stringify_pathP   s    
r0   c             C   s   t dd | dS )z-
    Return a product of sequence items.
    c             S   s   | | S )Nr   )abr   r   r   <lambda>d       zproduct.<locals>.<lambda>   )	functoolsreduce)seqr   r   r   product`   s    r9   c             C   s   |sd}|t |  }nd}|}x`t| D ]T\}}|dkrBd }}P || }|dkrd|||d  7 }q(|dk r(|||d  7 }q(W || |t |  krtd||fS )z
    Return a contiguous span of N-D array data.

    Parameters
    ----------
    shape : tuple
    strides : tuple
    itemsize : int
      Specify array shape data

    Returns
    -------
    start, end : int
      The span end points.
    r   r5   zarray data is non-contiguous)r9   	enumerate
ValueError)shapestridesitemsizestartendiZdimZstrider   r   r   get_contiguous_spang   s"    rB   c           	   C   sN   t  t jt j} t| *} | d | t jt jd | 	 d S Q R X d S )N) r   r5   )
socketAF_INETSOCK_STREAM
contextlibclosingbind
setsockopt
SOL_SOCKETSO_REUSEADDRgetsockname)sockr   r   r   find_free_port   s
    
rO   c              C   s   ddl m}  |  jS )Nr   )uuid4)uuidrP   hex)rP   r   r   r   guid   s    rS   c             C   sj   t d}t| }xD|rXx$|D ]} | |k	r t| tjr P q W P d }|   t| }qW d  } } }d S )Nr   )sys	_getframegcZget_referrersr   types	FrameTypeclear)frameZ
this_framerefsr   r   r   !_break_traceback_cycle_from_frame   s    


r\   )T)r-   rG   r6   rV   rD   rT   rW   r	   r   r   r   r   r#   r'   r,   r0   r9   rB   rO   rS   r\   r   r   r   r   <module>   s&   

$