U
    -el                     @   s|   d Z ddlZddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ d	d
 add Zdd Zdd ZdS )a  Global IPython app to support test running.

We must start our own ipython object and heavily muck with it so that all the
modifications IPython makes to system behavior don't send the doctest machinery
into a fit.  This code should be considered a gross hack, but it gets the job
done.
    N)Path   )tools)page)io)TerminalInteractiveShellc                   C   s   t  S )N)start_ipython r	   r	   \/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/IPython/testing/globalipapp.pyget_ipython   s    r   c                 C   s.   t | j|ddd dtjd tj  dS )zFReplace the default system call with a capturing one for doctest.
    Fr   )splitdepth )endfileN)print	getoutputrstripsysstdoutflush)selfcmdr	   r	   r
   xsys"   s     r   c                 C   s   t | j|tjd dS )zDPrint the traceback purely on stdout for doctest to capture it.
    )r   N)r   ZInteractiveTBZstb2textr   r   )r   etypeZevalueZstbr	   r	   r
   _showtraceback+   s    r   c                  C   s   t tdrdS dt_tj} tj}tjd}t	 }d|j
_t
j|d}|jt|jj |j  tt||_tt||_|tjd< | t_|t_|}|ja|t_|t_tt_d	dd}tjt_|t_|S )
zMStart a global IPython shell, which we need for IPython-specific syntax.
    already_calledNT__main__)configr   c                 S   s"   t | tr| dd} t|  d S )Nz
text/plainr   )
isinstancedictgetr   )ZstrngstartZscreen_linesZ	pager_cmdr	   r	   r
   nopagej   s    
zstart_ipython.<locals>.nopage)r   r   N) hasattrr   r   r   displayhook
excepthookmodulesr!   r   Zdefault_configr   Zsimple_promptinstanceZ	tempfilesappendr   ZHistoryManagerZ	hist_fileZbuiltin_trapactivatetypes
MethodTyper   systemr   r   builtin_mod_ipipr   Z
pager_pageZ	orig_page)Z_displayhook_excepthook_mainr   shellr/   r#   r	   r	   r
   r   1   s2    



r   )__doc__builtinsr.   r   r+   pathlibr   r   r   ZIPython.corer   ZIPython.utilsr   Z!IPython.terminal.interactiveshellr   r   r   r   r   r	   r	   r	   r
   <module>   s   		