a
    d                     @   s,   d dl Z d dlZG dd dZdddZdS )    Nc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )_CatchDisplayz*Class to temporarily catch sys.displayhookc                 C   s
   d | _ d S Noutputself r   ^/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/altair/utils/execeval.py__init__   s    z_CatchDisplay.__init__c                 C   s   t j| _| t _| S r   )sysdisplayhookold_hookr   r   r   r	   	__enter__   s    z_CatchDisplay.__enter__c                 C   s   | j t_dS )NF)r   r   r   )r   typevalue	tracebackr   r   r	   __exit__   s    z_CatchDisplay.__exit__c                 C   s
   || _ d S r   r   )r   r   r   r   r	   __call__   s    z_CatchDisplay.__call__N)__name__
__module____qualname____doc__r
   r   r   r   r   r   r   r	   r      s
   r   <string>c           	      C   s   t j| ddd}|du ri }t }t|jd t jrT|jdd |jdd  }}n|jg  }}|D ]&}tt |gg |dd}t|| qd|: |D ]$}tt 	|g|dd}t|| qW d   n1 s0    Y  |j
S )z
    Execute a multi-line block of code in the given namespace

    If the final statement in the code is an expression, return
    the result of the expression.
    z<ast>exec)filenamemodeNsingle)astparser   
isinstancebodyExprcompileModuler   Interactiver   )	code	namespacer   treeZcatch_displayZto_execZto_evalnodeZcompiledr   r   r	   
eval_block   s"     *r*   )Nr   )r   r   r   r*   r   r   r   r	   <module>   s   