
    }tf|                        d dl mZ d dlZd dlmZmZmZmZ d dlm	Z	m
Z
mZ ddlmZmZ ej                  rd dlmZ e G d d	e             Zdd
Zy)    )annotationsN)Magics
cell_magic
line_magicmagics_class)argumentmagic_argumentsparse_argstring   )_VIRTUAL_FILESVirtualFileContents)InteractiveShellc                  x     e Zd ZdZd fdZ e        eded      ed	d                     Z	e
d
d       Z xZS )AnyWidgetMagicsz7A set of IPython magics for working with virtual files.c                2    t         |   |       i | _        y)zInitialize the magics.N)super__init___files)selfshell	__class__s     ^/var/www/html/software/conda/envs/higlass/lib/python3.12/site-packages/anywidget/_cellmagic.pyr   zAnyWidgetMagics.__init__   s    68    	file_namezThe name of the virtual file.)typehelpc                t   t        t        j                  |      }dt        j                  t
        |j                         }t        j                  d| j                        }|j                  |      }|| j                  v r|| j                  |   _
        yt        |      }|| j                  |<   |t        |<   y)z4Create a virtual file with the contents of the cell.zvfile:r   N)r
   r   vfiletypingcaststrr   r   transform_cellr   contentsr   r   )r   linecellargsnamer   coder   s           r   r   zAnyWidgetMagics.vfile   s    
 44d;C89:.

;##D)4;;)-DKK&'-E %DKK#(N4 r   c                8    | j                   j                          y)zClear all virtual files.N)r   clear)r   r$   s     r   clear_vfileszAnyWidgetMagics.clear_vfiles(   s     	r   )r   r   returnNone)r$   r!   r%   r!   r,   r-   )r$   r!   r,   r-   )__name__
__module____qualname____doc__r   r	   r   r!   r   r   r   r+   __classcell__)r   s   @r   r   r      sQ    A9 k*IJ)  K )  r   r   c                .    | j                  t               y)zLoad the IPython extension.

    Parameters
    ----------
    ipython : IPython.core.interactiveshell.InteractiveShell
        The IPython shell instance.
    N)register_magicsr   )ipythons    r   load_ipython_extensionr6   .   s     O,r   )r5   r   r,   r-   )
__future__r   r   IPython.core.magicr   r   r   r   IPython.core.magic_argumentsr   r	   r
   _file_contentsr   r   TYPE_CHECKINGIPython.core.interactiveshellr   r   r6    r   r   <module>r>      sF    "  K K S S ?	> f  >-r   