3
Êb_‡  ã               @   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-build-jkwsxyiy/pandas/pandas/util/_depr_module.pyÚ__init__   s    
z_DeprecatedModule.__init__)Úreturnc             C   s   | j ƒ }t|ƒS )N)Ú_import_deprmodr	   )r   Ú
deprmoduler   r   r   Ú__dir__'   s    z_DeprecatedModule.__dir__c             C   s   | j ƒ }t|ƒS )N)r   Úrepr)r   r   r   r   r   Ú__repr__+   s    z_DeprecatedModule.__repr__)Únamec             C   s<  || j krtj| |ƒS y| j| jƒ}W n, tk
rR   | jd krB‚ | j| jƒ}Y nX t||ƒ}| jd k	r’|| jkr’t	j
| j› d|› d�tdd� n¦| jd k	rÐ|| jkrÐt	j
| j› d|› d| j| › �tdd� nh| j}|dkrþt	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   s@    






z_DeprecatedModule.__getattr__c             C   s>   |d kr| j }tjƒ � tjdtd� tj|ƒ}|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   