U
    -em
                     @   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
   Y/var/www/html/Darija-Ai-Train/env/lib/python3.8/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 )
ShimImporterzImport 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                    s`   | d| _| dd }|r0|ddd |d< tt| j|| |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k
r8   dd t|D  Y S X dS )z Ensure __all__ is always definedc                 S   s   g | ]}| d s|qS )_)r   ).0r   r
   r
   r   
<listcomp>I   s     
 z&ShimModule.__all__.<locals>.<listcomp>N)r   r!   __all__AttributeErrorr.   )r   modr
   r
   r   r3   B   s
    
zShimModule.__all__c              
   C   sJ   d| j |f }z
t|W S  tk
rD } zt||W 5 d }~X Y nX d S )Nz%s.%s)r!   r   ImportErrorr4   )r   keyr   er
   r
   r   __getattr__K   s
    
zShimModule.__getattr__c                 C   s6   z|  d W S  tk
r0   d| jd Y S X d S )N__repr__z<ShimModule for >)r9   r4   r!   r+   r
   r
   r   r:   S   s    zShimModule.__repr__)r   r   r   r   propertyr,   r-   r/   r3   r9   r:   __classcell__r
   r
   r)   r   r   (   s   


r   )r	   importlib.abcr   importlib.utilr$   typesr   Zimportstringr   Warningr   abcMetaPathFinderr   
ModuleTyper   r
   r
   r
   r   <module>   s   