U
    f/e                     @   s2   d Z ddlZddlmZ ddlZG dd dZdS )z
This module houses a utility class for mocking deprecated modules.
It is for internal use only and should not be used beyond this purpose.
    N)Iterablec                   @   sV   e Zd ZdZdddZee dddZeddd	ZeZ	ed
ddZ
dddZdS )_DeprecatedModulea  
    Class for mocking deprecated modules.

    Parameters
    ----------
    deprmod : name of module to be deprecated.
    deprmodto : name of module as a replacement, optional.
                If not given, the __module__ attribute will
                be used when needed.
    removals : objects or methods in module that will no longer be
               accessible once module is removed.
    moved : dict, optional
            dictionary of function name -> new location for moved
            objects
    Nc                 C   sD   || _ || _|| _| jd k	r(t| j| _|| _ttt| | _d S N)deprmod	deprmodtoremovals	frozensetmoveddirtypeself_dir)selfr   r   r   r	    r   </tmp/pip-unpacked-wheel-tiezk1ph/pandas/util/_depr_module.py__init__   s    
z_DeprecatedModule.__init__)returnc                 C   s   |   }t|S r   )_import_deprmodr
   r   
deprmoduler   r   r   __dir__'   s    z_DeprecatedModule.__dir__c                 C   s   |   }t|S r   )r   reprr   r   r   r   __repr__+   s    z_DeprecatedModule.__repr__)namec              	   C   s<  || j krt| |S z| | j}W n, tk
rR   | jd krB | | j}Y nX t||}| jd k	r|| jkrt	j
| j d| dtdd n| jd k	r|| jkrt	j
| j d| d| j|  tdd nh| j}|dkrt	j
| j d| dtdd n:|d kr|j}t	j
| j d| d| d| d	tdd |S )
N.z7 is deprecated and will be removed in a future version.   )
stacklevelzG is deprecated and will be removed in a future version.
You can access z as Fz is deprecated. Please use z	 instead.)r   object__getattribute__r   r   ImportErrorr   getattrr   warningswarnFutureWarningr	   
__module__)r   r   r   objr   r   r   r   __getattr__1   sH    



z_DeprecatedModule.__getattr__c              
   C   sJ   |d kr| j }t * tjdtd t|}|W  5 Q R  S Q R X d S )Nignore)category)r   r    catch_warningsfilterwarningsr"   	importlibimport_module)r   modr   r   r   r   r   d   s    

z!_DeprecatedModule._import_deprmod)NNN)N)__name__r#   __qualname____doc__r   r   strr   r   __str__r%   r   r   r   r   r   r      s   
3r   )r/   r*   typingr   r    r   r   r   r   r   <module>   s   