
    fm
                         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e	      Z
 G d d	ej                  j                        Z G d
 dej                        Zy)z%A shim module for deprecated imports
    N)import_module   )import_itemc                       e Zd ZdZy)ShimWarningzFA warning to show when a module has moved, and a shim is in its place.N)__name__
__module____qualname____doc__     S/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/utils/shimmodule.pyr   r      s    Pr   r   c                   $    e Zd ZdZd Zd ZddZy)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                      || _         || _        y Nsrcmirror)selfr   r   s      r   __init__zShimImporter.__init__   s    r   c                 L    | j                   |t        | j                        d z   S )z#get the name of the mirrored moduleN)r   lenr   )r   fullnames     r   _mirror_namezShimImporter._mirror_name   s"     {{Xc$((mo666r   Nc                     |j                  | j                  dz         r0| j                  |      }t        j                  j                  |      S y N.)
startswithr   r   	importlibutil	find_spec)r   r   pathtargetmirror_names        r   r"   zShimImporter.find_spec"   sB    txx#~.++H5K>>++K88 /r   r   )r   r	   r
   r   r   r   r"   r   r   r   r   r      s    
7
9r   r   c                   `     e Zd Z fdZed        Zed        Zd Zed        Zd Z	d Z
 xZS )
ShimModulec                    |j                  d      | _        |j                  dd       }|r|j                  dd      d   |d<   t        t        |   |i | |r5t        j                  j                  t        || j                               y y )Nr   r   r   r   namer   )
pop_mirrorrsplitsuperr'   r   sys	meta_pathappendr   )r   argskwargsr   	__class__s       r   r   zShimModule.__init__*   s{    zz(+jj% ZZQ/3F6Nj$($9&9MM  T\\: r   c                     g S r   r   r   s    r   __path__zShimModule.__path__6   s    	r   c                 @    t        | j                        j                  S )z&Don't produce __spec__ until requested)r   r,   __spec__r6   s    r   r9   zShimModule.__spec__:   s     T\\*333r   c                 >    t        t        | j                              S r   )dirr   r,   r6   s    r   __dir__zShimModule.__dir__?   s    =.//r   c                     t        | j                        }	 |j                  S # t        $ r4 t	        |      D cg c]  }|j                  d      r| nc c}w c}cY S w xY w)z Ensure __all__ is always defined_)r   r,   __all__AttributeErrorr;   r   )r   modr*   s      r   r?   zShimModule.__all__B   sV     DLL)	K;; 	K%(XJTT__S5IDJJJ	Ks    # A AA	A A c                 v    | j                   d|}	 t        |      S # t        $ r}t        |      |d }~ww xY wr   )r,   r   ImportErrorr@   )r   keyr*   es       r   __getattr__zShimModule.__getattr__K   s=    ,,,	-t$$ 	- %1,	-s   
 	838c                 n    	  | j                  d             S # t        $ r d| j                  dcY S w xY w)N__repr__z<ShimModule for >)rF   r@   r,   r6   s    r   rH   zShimModule.__repr__S   s@    	8/4##J/11 	8%dll%5Q77	8s    44)r   r	   r
   r   propertyr7   r9   r<   r?   rF   rH   __classcell__)r4   s   @r   r'   r'   (   sU    
   4 40 K K-8r   r'   )r   importlib.abcr    importlib.utilr/   typesr   importstringr   Warningr   abcMetaPathFinderr   
ModuleTyper'   r   r   r   <module>rT      sT   
   
  # %Q' Q99==// 9*18!! 18r   