a
    ø£Bem
  ã                   @   sv   d Z ddlZddlZddlZddlZddlmZ ddlmZ G dd„ de	ƒZ
G dd	„ d	ejjƒZG d
d„ dejƒZdS )z%A shim module for deprecated imports
é    N)Úimport_moduleé   )Úimport_itemc                   @   s   e Zd ZdZdS )ÚShimWarningzFA warning to show when a module has moved, and a shim is in its place.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r
   r
   ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/IPython/utils/shimmodule.pyr      s   r   c                   @   s*   e Zd ZdZdd„ Zdd„ Zd	dd„ZdS )
ÚShimImporterz¤Import hook for a shim.

    This ensures that submodule imports return the real target module,
    not a clone that will confuse `is` and `isinstance` checks.
    c                 C   s   || _ || _d S ©N©ÚsrcÚmirror)Úselfr   r   r
   r
   r   Ú__init__   s    zShimImporter.__init__c                 C   s   | j |t| jƒd…  S )z#get the name of the mirrored moduleN)r   Úlenr   )r   Úfullnamer
   r
   r   Ú_mirror_name   s    zShimImporter._mirror_nameNc                 C   s*   |  | jd ¡r&|  |¡}tj |¡S d S )NÚ.)Ú
startswithr   r   Ú	importlibÚutilÚ	find_spec)r   r   ÚpathÚtargetZmirror_namer
   r
   r   r   "   s    
zShimImporter.find_spec)N)r   r   r   r	   r   r   r   r
   r
   r
   r   r      s   r   c                       sX   e Zd Z‡ fdd„Zedd„ ƒZedd„ ƒZdd„ Zed	d
„ ƒZdd„ Z	dd„ Z
‡  ZS )Ú
ShimModulec                    sd   |  d¡| _|  dd ¡}|r0| dd¡d |d< tt| ƒj|i |¤Ž |r`tj t	|| jd�¡ d S )Nr   r   r   r   éÿÿÿÿÚnamer   )
ÚpopÚ_mirrorÚrsplitÚsuperr   r   ÚsysÚ	meta_pathÚappendr   )r   ÚargsÚkwargsr   ©Ú	__class__r
   r   r   *   s    ÿzShimModule.__init__c                 C   s   g S r   r
   ©r   r
   r
   r   Ú__path__6   s    zShimModule.__path__c                 C   s   t | jƒjS )z&Don't produce __spec__ until requested)r   r!   Ú__spec__r+   r
   r
   r   r-   :   s    zShimModule.__spec__c                 C   s   t t| jƒƒS r   )Údirr   r!   r+   r
   r
   r   Ú__dir__?   s    zShimModule.__dir__c                 C   s<   t | jƒ}z|jW S  ty6   dd„ t|ƒD ƒ Y S 0 dS )z Ensure __all__ is always definedc                 S   s   g | ]}|  d ¡s|‘qS )Ú_)r   )Ú.0r   r
   r
   r   Ú
<listcomp>I   ó    z&ShimModule.__all__.<locals>.<listcomp>N)r   r!   Ú__all__ÚAttributeErrorr.   )r   Úmodr
   r
   r   r4   B   s
    
zShimModule.__all__c              
   C   sL   d| j |f }z
t|ƒW S  tyF } zt|ƒ|‚W Y d }~n
d }~0 0 d S )Nz%s.%s)r!   r   ÚImportErrorr5   )r   Úkeyr   Úer
   r
   r   Ú__getattr__K   s
    
zShimModule.__getattr__c                 C   s4   z|   d¡ƒ W S  ty.   d| j›d� Y S 0 d S )NÚ__repr__z<ShimModule for ú>)r:   r5   r!   r+   r
   r
   r   r;   S   s    zShimModule.__repr__)r   r   r   r   Úpropertyr,   r-   r/   r4   r:   r;   Ú__classcell__r
   r
   r)   r   r   (   s   


r   )r	   Úimportlib.abcr   Zimportlib.utilr$   Útypesr   Zimportstringr   ÚWarningr   ÚabcÚMetaPathFinderr   Ú
ModuleTyper   r
   r
   r
   r   Ú<module>   s   