
    Je8{                    z   d Z ddlZddlZddlmZ ddlZddlZddlZddl	m
Z
 ddlmZmZ ddlZddlmZ ddlmZmZ ddlmZ ddlmZ dd	lmZmZmZmZmZmZ dd
l m!Z!m"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l.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmBZBmCZCmDZD ddlEmFZFmGZG ddlHmIZI ddlJmKZK ddlLmMZM ddlNmOZO ddlPmQZQ  ej                  eS      ZTeIj                  ZV G d d      ZW G d d       ZX G d! d"      ZY G d# d$      ZZ G d% d&      Z[ G d' d(e+      Z\y))z1
IPython Console main widget based on QtConsole.
    N)find_connection_file)jupyter_config_dirjupyter_runtime_dir)QtKernelClient)SignalSlot)QColor)	WEBENGINE)QApplicationQHBoxLayoutQLabelQMessageBoxQVBoxLayoutQWidget)Configload_pyconfig_files)tunnel)on_conf_change_)PluginMainWidget)MENU_SEPARATOR)get_conf_pathget_home_dirrunning_under_pytestSpyderKernelSpec)SpyderKernelManager)openssh_tunnel)create_qss_style)ClientWidgetConsoleRestartDialogCOMPLETION_WIDGET_TYPEKernelConnectionDialogPageControlWidgetShellWidget)encodingprograms
sourcecode)get_error_matchremove_backslashes)QStylePalette)FrameWebView)FindReplace)Tabs)StdFilec                   `    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZy)IPythonConsoleWidgetActionsznew tabzcreate cython clientzcreate cympy clientzcreate pylab clientzClear shellz
clear linezconnect to kernelzinterrupt kernelInspect current objectRestart kernelzreset namespaceShow environment variableszshow system pathztoggle elapsed timeexitz
rename tabzenter array inlinezenter array tablezipython documentationzconsole helpzquick referenceN)__name__
__module____qualname__CreateNewClientCreateCythonClientCreateSymPyClientCreatePyLabClientClearConsole	ClearLineConnectToKernel	InterruptInspectObjectRestartResetNamespaceShowEnvironmentVariablesShowSystemPathToggleElapsedTimeQuit	RenameTabArrayInline
ArrayTableIPythonDocumentationConsoleHelpQuickReference     S/usr/lib/python3/dist-packages/spyder/plugins/ipythonconsole/widgets/main_widget.pyr2   r2   A   sy    O/-- !LI)O"I,MG&N;'N-D I 'K$J 3 K&NrP   r2   c                       e Zd ZdZdZy) IPythonConsoleWidgetOptionsMenusspecial_consoles_submenudocumentation_submenuN)r7   r8   r9   SpecialConsolesDocumentationrO   rP   rQ   rS   rS   b   s    0O+MrP   rS   c                       e Zd ZdZdZdZy)'IPythonConsoleWidgetOptionsMenuSectionsconsoles_sectionedit_sectionview_sectionN)r7   r8   r9   ConsolesEditViewrO   rP   rQ   rY   rY   g   s    !HDDrP   rY   c                       e Zd ZdZy)IPythonConsoleWidgetMenustabs_context_menuN)r7   r8   r9   TabsContextMenurO   rP   rQ   ra   ra   m   s    )OrP   ra   c                       e Zd ZdZdZy)+IPythonConsoleWidgetTabsContextMenuSectionstabs_consoles_sectiontabs_edit_sectionN)r7   r8   r9   r]   r^   rO   rP   rQ   re   re   q   s    &HDrP   re   c            
           e Zd ZdZ eee      Z	  ee      Z	  e       Z	  e       Z		  eee
efee
eef      Z	  ee      Z	  eee      Z	  ee      Z	  ee      Z	  ee      Z	  ee      Z	  ee      Z	  eee      Z	  ee      Z	  ee      Z	  ed      Zd fd	Zd Zd Zd Zd Zd Z d	 Z! e"d
d      d        Z# e"dddg      d        Z$ e"d      d        Z% e"d      d        Z& e"d      d        Z' e"d      d        Z( e"d      d        Z) e"d      d        Z* e"d      d         Z+ e"d!      d"        Z, e"d#      d$        Z- e"d%      d&        Z. e"d'      d(        Z/ e"d)      d*        Z0 e"d+      d,        Z1 e"d-      d.        Z2 e"d/      d0        Z3 e"g d1      d2        Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z: e;       d9        Z<d: Z=dd;Z>dd<Z?d= Z@d> ZAd? ZBd@ ZCdA ZDdB ZE e;ee      dC        ZFdD ZGdE ZHddFZIdG ZJdH ZKdI ZLdJ ZM e;        e;e       e;e       e;ee       e;ee       e;eee      	 	 	 ddK                                          ZNdL ZOdM ZPdN ZQdO ZR	 	 ddPZSdQ ZTddRZUdS ZV e;e      dT        ZWddUZXdV ZYddWZZddXZ[dY Z\dZ Z]dd[Z^d\ Z_d] Z`d^ Zad_ Zbd` Zcda Zddb Zedc Zfdd Zgde Zhdf Zi	 	 ddgZj	 	 ddhZkdi Zldj Zmdk Zndl Zodm Zpdn Zqdo Zrdp Zsdq Ztdr Zuds Zvdt Zwdu Zx	 ddvZydw Zzdx Z{dy Z|dz Z}d{ Z~d| Zd} Zd~ Zd Zd Zd Z	 	 ddZd Z e;       d        Z e;       d        Z e;       d        Z xZS )IPythonConsoleWidgetzb
    IPython Console plugin

    This is a widget with tabs where each one is a ClientWidget.
    zhThe directory {} is not writable and it is required to create IPython consoles. Please make it writable.c           
      
    t         	   |||       d  _        d _        g  _        g  _        d _        d  _        d _         j                  dd       _
        d  _        d  _         j                          _        i  _        d _        |r#|j#                         }|j$                  rd _        t'        t(        j*                  j-                  d             _        t(        j*                  j-                  d       _        t(        j*                  j-                  d	       _         j0                  rdt5        j6                  t5        j8                   j0                              s2t)        j:                  t5        j8                   j0                               t=               }|j?                  d       tA         dd
d       _!        tE         jB                  d      r.tF        jH                  dk(  s jB                  jK                  d        jB                  jL                  jO                   fd        jB                  jQ                         jR                  jO                   jT                          jB                  jQ                         jV                  jO                   jX                          jB                  j[                   j\                         tF        jH                  dk(  rgt_               }|ja                  d       tc        |      }|je                  dddd       |jg                   jB                         |jg                  |       n|jg                   jB                          j                   rti                _5        tl        r7 jj                  jo                         jq                  ts        tt                     n. jj                  jw                  djy                  tt                     |jg                   jj                         nd  _5        t{        t}        d              _?        t        j                  j                         } |j                  di t        j                   t        j                   dddd  j~                  jw                  |j                                 j~                  j                          |jg                   j~                         t                _J         j                  j                          |jg                   j                          j                  |        j                  d        j                          d  _N        t                _P        y )Nr   FTcss_path
appearancesectionIPYCONSOLE_TESTINGIPYCONSOLE_TEST_DIRIPYCONSOLE_TEST_NO_STDERR/)rename_tabs
split_charsplit_indexsetDocumentModedarwinc                 (    j                  d      S )NT
give_focus)refresh_container)idxselfs    rQ   <lambda>z/IPythonConsoleWidget.__init__.<locals>.<lambda>P  s    ..$.? rP   ztab-containerzbackground:{}zPress <b>Q</b> to exit pagerz0px 1px 4px 1px5pxAlignCenter)zbackground-colorcolormarginpaddingzqproperty-alignmentrO   )Qsuper__init__menu_actionsmaster_clientsclients	filenamesmainwindow_closeactive_project_pathcreate_new_client_if_emptyget_confrk   run_cell_filenameinterrupt_actionget_conf_optionsinitial_conf_options!registered_spyder_kernel_handlersenable_infowidgetget_command_line_optionsno_web_widgetsboolosenvironget_testing	_test_dir_test_no_stderrospisdirjoinmakedirsr   
setSpacingr/   	tabwidgethasattrsysplatformrv   currentChangedconnecttabBartabMovedmove_tabsig_name_changedrename_tabs_after_changeset_close_functionclose_clientr   setObjectNamer   setContentsMargins	addWidgetr-   
infowidgetr
   pagesetBackgroundColorr	   MAIN_BG_COLORsetStyleSheetformatr   r   pager_label	qstylizerstyle
StyleSheet	setValuesr,   COLOR_ACCENT_2COLOR_TEXT_1toStringhider.   find_widget	setLayoutsetAcceptDrops_init_asyncio_patch_cached_kernel_propertiesr   _current_working_directory)
r}   namepluginparentcli_optionslayouttab_container
tab_layoutpager_label_css	__class__s
   `        rQ   r   zIPythonConsoleWidget.__init__#  s   vv.  %#' *.'j,G!% $$($9$9$;!13. "& 99;K))).& RZZ^^,@AB(=>!zz~~.IJ >>99SXXdnn56CHHT^^45!d*+-DNN$560 NN**40%%--?	A((00?0088))	+))$*;*;<<<8##IM''8$]3J))!Q15  0]+T^^, !!*40DO$$&99=)+ --#**=9;T__-"DO "!$B"CTJ#//446!!! 	#0#?#?"@%223'#0%
 	 	&&'?'?'AB))* 't,))*v 	D! 	  " *.& +7.'rP   c                 2    d| _         | j                          y )NT)r   close_all_clientsr}   s    rQ   on_closezIPythonConsoleWidget.on_close  s     $ rP   c                     t        d      S )NzIPython Consoler   r   s    rQ   	get_titlezIPythonConsoleWidget.get_title  s    "##rP   c                 \    | j                   j                         }||j                         S y N)r   currentWidgetget_controlr}   clients     rQ   get_focus_widgetz%IPythonConsoleWidget.get_focus_widget  s.    --/%%'' rP   c           	      t     j                  t        j                  t        d       j	                  d       j
                  d       _         j                  t        j                  t        d       j	                  d       j                  d       _	         j                  t        j                  t        d       j	                  d       j                  d       _         j                  t        j                  t        d	       j	                  d
       j                         _         j                  t        j                   t        d      t        d       j"                         _         j                  t        j&                  t        d       j	                  d       j(                         _         j                  t        j,                  t        d       j	                  d       fd       _         j                  t        j0                  t        d       j	                  d       fd       _         j                  t        j4                  t        d       j6                   j9                  d             _         j                  t        j<                  t        d       j	                  d       j>                  d       _          j                  t        jB                  t        d       jD                  d       _#         j                  t        jH                  t        d       jJ                  d       _&         j                  t        jN                  t        d       j	                  d        jP                  !       _)         j                  t        jT                  t        d"       jV                  d       _,         j                  t        jZ                  t        d#       j\                  d       _/        t`         j@                   jF                   jL                   j                   jX                   j^                  t`         jR                  f	 _1         je                         } jg                  th        jj                  t        d$             _6         j                   jl                   j$                  fD ]$  } jo                  ||tp        jr                  %       &  j                   j                   j                   j*                  fD ]$  } jo                  ||tp        jt                  %       &  j.                   j2                   j:                  fD ]$  } jo                  ||tp        jv                  %       &  j                  t        jx                  t        d&       j	                  d       jz                        } j                  t        j|                  t        d'       j	                  d       j~                        } j                  t        j                  t        d(       j	                  d       j                  !      }|||fD ]  } jo                  | jl                  )       !  j                  d*t        d      t        d+       j	                  d       j                  ,       _C         j                  d-t        d	      t        d	       j	                  d
       j                  ,       _D        t        d.       _F         j                  d/ j                          j                  d* j                          j                  d0 j                          jg                  t        j                        } j                   jl                   j$                  fD ]$  } jo                  ||t        jr                  %       &  j                   j                   j                   j*                  fD ]$  } jo                  ||t        jt                  %       & | j                  _L         jg                  th        j                  t        d1      2       _N         j                  t        j                  t        d3       j                  4      } j                  t        j                  t        d5       j                  4      } j                  t        j                  t        d6       j                  4      }	||	|fD ]  }
 j                  j                  |
        y )7NzNew console (default settings)ipython_consoleT)texticon	triggeredregister_shortcutr4   restartzRemove all variables
editdeletezInterrupt kernelstop)r   r   r   zConnect to an existing kernelz:Open a new IPython console connected to an existing kernel)r   tipr   z
Rename tabrenamer5   r   c                  d     j                         r j                         j                         S d S r   )get_current_shellwidgetrequest_envr   s   rQ   r~   z,IPythonConsoleWidget.setup.<locals>.<lambda>  s3    //1 ,,.::< 7; rP   zShow sys.path contentssyspathc                  d     j                         r j                         j                         S d S r   )r   request_syspathr   s   rQ   r~   z,IPythonConsoleWidget.setup.<locals>.<lambda>  s3    //1 ,,.>>@ 7; rP   zShow elapsed timeshow_elapsed_time)r   toggledinitialr3   MessageBoxInformationzClear line or block)r   r   r   zClear consolez&Quitr6   )r   r   zEnter array tablezEnter array inlinezSpecial consoles)menurn   z!New Pylab console (data plotting)z!New SymPy console (symbolic math)z-New Cython console (Python with C extensions))r   resetz*Remove all variables from kernel namespace)r   r   r   r   	interrupt timerstart_interruptzIPython documentation)menu_idtitlezIntro to IPython)r   r   zQuick referencezConsole help)Vcreate_actionr2   r:   r   create_iconcreate_new_clientcreate_client_actionrC   restart_kernelrestart_actionrD   reset_namespacereset_actionrA   interrupt_kernelr   r@   _create_client_for_kernelconnect_to_kernel_actionrI   tab_name_editorrename_tab_actionrE   
env_actionrF   syspath_actionrG   $set_show_elapsed_time_current_clientr   show_time_actionrB   current_client_inspect_objectinspect_actionr?   current_client_clear_lineclear_line_actionr>   current_client_clear_consoleclear_console_actionrH   current_client_quitquit_actionrK    current_client_enter_array_tablearray_table_actionrJ   !current_client_enter_array_inlinearray_inline_actionr   context_menu_actionsget_options_menucreate_menurS   rV   special_console_menuadd_item_to_menurY   r]   r^   r_   r=   create_pylab_clientr<   create_sympy_clientr;   create_cython_clientcreate_toolbuttonreset_buttonstop_buttonr   
time_labeladd_corner_widgetra   rc   re   r   r   rW   ipython_menurL   
show_introrN   show_quickrefrM   show_guiref
add_action)r}   options_menuitemcreate_pylab_actioncreate_sympy_actioncreate_cython_actionrb   intro_actionquickref_actionguiref_actionhelp_actions   `          rQ   setupzIPythonConsoleWidget.setup  s   $($6$6'7734!!"34,," %7 %
! #00'//#$!!),))" 1 
 !..'66)*!!,/**" / 
 !% 2 2'11%&!!&)++	 !3 !
 )-(:(:'7723  44 ); )
% "&!3!3'11<!!(+**	 "4 "
 ,,'@@/0!!),<	 - 
 #00'66+,!!),<	 1 
 !% 2 2'99&'==MM"56	 !3 !
 #00'55+,!!"9:88" 1 $ "&!3!3'11()44"	 "4 "$ %)$6$6'44?#77"	 %7 %$!  --',,gJ!!&)..	 . 0 #'"4"4'22&';;"	 #5 #$ $(#5#5'33'(<<"	 $6 $$  ""%%##$$
%
! ,,.$($4$4,<< !%#!
 ))))--/ 	D !!!?HH " 		 %%##!!&&	( 		D
 !!!?DD " 		 ##%%' 	D !!!?DD " 		 #00'9967!!"34..	 1 
 #00'9967!!"34..	 1 
  $11'::=>!!"34//	  2  
 $#$& 	D !!.. " 		 !22)*>?!!,/** 3 
  11%&$%!!&)++ 2 
 !* 	w8w(9(9:0$2B2BC !,,%557 ))))--/ 	D !!&CLL " 		 %%##!!&&	( 		D
 !!&CHH " 		 0 !,,4BB+, - . ))'<<%&oo * 

 ,,'66$%(( - 

 **'33>"&& + 
 m_> 	6K((5	6rP   c                     | j                         r2| j                         }|j                  |       | j                          y y r   )get_current_clientset_show_elapsed_timer{   )r}   stater   s      rQ   r	  z9IPythonConsoleWidget.set_show_elapsed_time_current_client  s;    ""$,,.F((/""$ %rP   c                 6   | j                         }||j                         }| j                  j                  |       | j                  j                  |       |j
                  |j                  |j                  |j                  k7  }| j                  j                  |        | j                  j                  |        | j                  j                  |        | j                  j                  |        | j                  j                  |        y y y y r   )r4  is_client_executingr   
setEnabledr!  r   	info_page
blank_pager   r  r  r  r
  )r}   r   	executingerror_or_loadings       rQ   update_actionsz#IPythonConsoleWidget.update_actions  s   ((*224I!!,,Y7''	2 !!-$$0#)#3#3v7H7H#H ##..3C/CD!!,,1A-AB**/?+?@##..3C/CD%%005E1EF 1 . rP   helpzconnect/ipython_console)rn   optionc                     t        | j                        D ]0  \  }}| j                  ||j                         j                  |       2 y r   )	enumerater   _change_client_confr   set_help_enabledr}   valuer|   r   s       rQ   change_clients_help_connectionz3IPythonConsoleWidget.change_clients_help_connection  sD    $T\\2 	KC$$""$55	rP   rl   selectedui_themec                     |dk(  r| j                  dd      }t        | j                        D ]"  \  }}| j                  ||j                  |       $ y )NrI  rH  rl   rm   )r   rB  r   rC  set_color_scheme)r}   r@  rF  r|   r   s        rQ   change_clients_color_schemez0IPythonConsoleWidget.change_clients_color_scheme  sU    ZMM*lMCE$T\\2 	KC$$''	rP   r   )r@  c                     t        | j                        D ]"  \  }}| j                  ||j                  |       $ | j	                         r| j                          y y r   )rB  r   rC  r5  r4  r{   rE  s       rQ    change_clients_show_elapsed_timez5IPythonConsoleWidget.change_clients_show_elapsed_time  sZ    $T\\2 	KC$$,,	
 ""$""$ %rP   show_reset_namespace_warningc                 t    t        | j                        D ]  \  }|ffd	}| j                  ||       ! y )Nc                     | _         y r   )reset_warningrF  r   s    rQ   change_client_reset_warningzeIPythonConsoleWidget.change_clients_show_reset_namespace_warning.<locals>.change_client_reset_warning  s    ',$rP   rB  r   rC  )r}   rF  r|   rT  r   s       @rQ   +change_clients_show_reset_namespace_warningz@IPythonConsoleWidget.change_clients_show_reset_namespace_warning  s>    $T\\2 	KC27 -$$+	rP   ask_before_restartc                 t    t        | j                        D ]  \  }|ffd	}| j                  ||       ! y )Nc                     | _         y r   )rW  rS  s    rQ    change_client_ask_before_restartz`IPythonConsoleWidget.change_clients_ask_before_restart.<locals>.change_client_ask_before_restart      ,1)rP   rU  )r}   rF  r|   rZ  r   s       @rQ   !change_clients_ask_before_restartz6IPythonConsoleWidget.change_clients_ask_before_restart  >    $T\\2 	KC7< 2$$0	rP   ask_before_closingc                 t    t        | j                        D ]  \  }|ffd	}| j                  ||       ! y )Nc                     | _         y r   )r^  rS  s    rQ    change_client_ask_before_closingz`IPythonConsoleWidget.change_clients_ask_before_closing.<locals>.change_client_ask_before_closing  r[  rP   rU  )r}   rF  r|   ra  r   s       @rQ   !change_clients_ask_before_closingz6IPythonConsoleWidget.change_clients_ask_before_closing  r]  rP   show_calltipsc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  shellwidgetset_show_calltipsrE  s       rQ   change_clients_show_calltipsz1IPythonConsoleWidget.change_clients_show_calltips  sA    $T\\2 	KC$$""44	rP   buffer_sizec                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_buffer_sizerE  s       rQ   change_clients_buffer_sizez/IPythonConsoleWidget.change_clients_buffer_size  sA    $T\\2 	KC$$""22	rP   completion_typec                     t        | j                        D ]3  \  }}| j                  ||j                  j                  t
        |          5 y r   )rB  r   rC  re  _set_completion_widgetr#   rE  s       rQ   change_clients_completion_typez3IPythonConsoleWidget.change_clients_completion_type  sF    $T\\2 	/KC$$""99&u-/	/rP   	in_promptc                     t        |      rEt        | j                        D ],  \  }}| j                  ||j                  j
                  |       . y y r   )r   rB  r   rC  re  set_in_promptrE  s       rQ   change_clients_in_promptz-IPythonConsoleWidget.change_clients_in_prompt  sM    ;(6 V((&&44 rP   
out_promptc                     t        |      rEt        | j                        D ],  \  }}| j                  ||j                  j
                  |       . y y r   )r   rB  r   rC  re  set_out_promptrE  s       rQ   change_clients_out_promptz.IPythonConsoleWidget.change_clients_out_prompt  sM    ;(6 V((&&55 rP   greedy_completerc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_greedy_completerrE  s       rQ   change_clients_greedy_completerz4IPythonConsoleWidget.change_clients_greedy_completer"  sA    $T\\2 	KC$$""77	rP   jedi_completerc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_jedi_completerrE  s       rQ   change_clients_jedi_completerz2IPythonConsoleWidget.change_clients_jedi_completer*  A    $T\\2 	KC$$""55	rP   autocallc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_autocallrE  s       rQ   change_clients_autocallz,IPythonConsoleWidget.change_clients_autocall2  sA    $T\\2 	KC$$""//	rP   pdb_ignore_libc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_pdb_ignore_librE  s       rQ   change_clients_pdb_ignore_libz2IPythonConsoleWidget.change_clients_pdb_ignore_lib;  r  rP   pdb_execute_eventsc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_pdb_execute_eventsrE  s       rQ   !change_clients_pdb_execute_eventsz6IPythonConsoleWidget.change_clients_pdb_execute_eventsC  sA    $T\\2 	KC$$""99	rP   pdb_use_exclamation_markc                     t        | j                        D ],  \  }}| j                  ||j                  j                  |       . y r   )rB  r   rC  re  set_pdb_use_exclamation_markrE  s       rQ   'change_clients_pdb_use_exclamation_markz<IPythonConsoleWidget.change_clients_pdb_use_exclamation_markK  sA    $T\\2 	KC$$""??	rP   )symbolic_mathhide_cmd_windowsstartup/run_linesstartup/use_run_filestartup/run_filepylabpylab/backendpylab/autoloadpylab/inline/figure_formatpylab/inline/resolutionpylab/inline/widthpylab/inline/heightpylab/inline/bbox_inchesc                      j                   s*| j                  v r j                  j                  |       yd}g }d}d}d}d} j                  |      }	d}
d}d	}||||||gz  }||v }d
}d}dgt	         j
                        z  } j                         }d}|	r|
|k(  r|r j                  |
      }g } j
                  D ]  }|j                  j                         }||k7  rX|V||k7  rQ||k7  rL|j                  d       t        |      t        |      k(  sWd} j                   sfdt        j                  d<   z|j                  d        t        |      }|s|rjt               s` j                          _         j                  j                  |       t!               }|j#                          |j%                         \  }}}nd}d}d}||i}t'         j
                        D ]  \  }}|xr ||   xs |}|r|r|ra|j                  j)                         r2j*                  r&||f fd	j,                  j/                         g j1                  ||       z|s}|s|j2                  }d|_        |j5                          ||_         |r|s|r1|r.|r+|j2                  }d|_        |j5                          ||_        yyyy)z
        Apply options that possibly require a kernel restart or related to
        Matplotlib inline backend options.
        NFr  r  r  r  r  r  r  r   TtrueBACKEND_REQUIRE_RESTARTc                 `    j                  | |       j                  j                         y r   )_change_client_mpl_confsig_pdb_prompt_ready
disconnect)occhange_client_mpl_confr}   sws     rQ   r  zYIPythonConsoleWidget.change_possible_restart_and_mpl_conf.<locals>.change_client_mpl_conf  s*    44Q://::24rP   )r   r   remover   lenr   r4  re  get_mpl_interactive_backendappendidr   r   anyr   r   r"   exec_get_action_valuerB  is_debugging
_executingr  r   r  rW  r   ) r}   r@  rF  restart_neededrestart_optionsrun_lines_nuse_run_file_n
run_file_npylab_npylab_opylab_backend_nsymbolic_math_nhide_cmd_windows_ninline_backendpylab_restartclients_backend_require_restartcurrent_client&current_client_backend_require_restartpylab_backend_or   interactive_backendrestart_dialogrestart_allrestart_current
no_restartoptionsr|   r   current_ask_before_restart!current_client_ask_before_restartr  r  s    `                             @@rQ   $change_possible_restart_and_mpl_confz9IPythonConsoleWidget.change_possible_restart_and_mpl_confS  s    }}222))008)/'
 --() */K+-?A 	A?2+0'C4E*E'00216.&0^"mmO<O /1+,, B&&BBD $
 $~5 (3 (>9 (?:3::4@ &zR%77AE>  ==DJBJJ'@A3::5A9B<   ?@Mm5I5K(,(=(=(?D%%%,,V41$7N  ")::<[/K#OJ 5/$T\\2 	GKCG#B3#G  
 
''??$18F 4
 ++334JK00&A[-3-F-F*,1)%%',F)-	G0  FO11 .05N-))+1 - 9GOrP   c                    |j                   }|j                         s	 ||       y|j                   j                         r%|||ffd	|j                  j	                         y|||ffd	|j
                  j	                         y)a  
        Change a client configuration option, taking into account if it is
        in a debugging session.

        Parameters
        ----------
        client : ClientWidget
            Client to update configuration.
        client_conf_func : Callable
            Client method to use to change the configuration.
        value : any
            New value for the client configuration.

        Returns
        -------
        None.

        c                 `     ||       | j                   j                  j                         y r   )re  r  r  r  ccfrF  change_confs      rQ   r  z=IPythonConsoleWidget._change_client_conf.<locals>.change_conf  s"    E
22==kJrP   c                 `     ||       | j                   j                  j                         y r   )re  sig_prompt_readyr  r  s      rQ   r  z=IPythonConsoleWidget._change_client_conf.<locals>.change_conf  s"    E
..99+FrP   N)re  r8  r  r  r   r  )r}   r   client_conf_funcrF  r  r  s        @rQ   rC  z(IPythonConsoleWidget._change_client_conf  s~    & ))+U#,,.$*:% K ##++K8$*:% G ''4rP   c                 :   d}| j                  |      }d}d}d}d}d}	d}
d}|j                  }|r||v s||v r4| j                  |      }| j                  |      }|j                  ||       ||v r"| j                  |      }|j                  |       ||v r"| j                  |      }|j	                  |       |	|v s|
|v r4| j                  |	      }| j                  |
      }|j                  ||       ||v r#| j                  |      }|j                  |       y	y	y	)
z4Apply Matplotlib related configurations to a client.r  r  r  r  r  r  r  r  N)r   re  set_matplotlib_backendset_mpl_inline_figure_formatset_mpl_inline_resolutionset_mpl_inline_figure_sizeset_mpl_inline_bbox_inches)r}   r  r   r  r  pylab_autoload_nr  inline_backend_figure_format_ninline_backend_resolution_ninline_backend_width_ninline_backend_height_ninline_backend_bbox_inches_nr  pylab_autoload_or  inline_backend_figure_format_oinline_backend_resolution_oinline_backend_width_oinline_backend_height_oinline_backend_bbox_inches_os                       rQ   r  z,IPythonConsoleWidget._change_client_mpl_conf  s]    --(+))E&&?#!5"7'A$ ')-=-H#'==1A#B "&--"@))/;KL-815224.//0NO*g5.2mm//1+,,-HI&'1+w6)-**,&*.--++-'--*,CE+w6/3}}002,--.JK 7+ rP   c                    t         j                  dk(  rjt        j                  dd dk\  rSddl}|j                  dk\  ryddl}	 ddlm}m} t        |j                         |      r|j                   |              yyyy# t        $ r Y yw xY w)a  
        - This was fixed in Tornado 6.1!
        - Same workaround fix as ipython/ipykernel#564
        - ref: tornadoweb/tornado#2608
        - On Python 3.8+, Tornado 6.0 is not compatible with the default
          asyncio implementation on Windows. Pick the older
          SelectorEventLoopPolicy if the known-incompatible default policy is
          in use.
        - Do this as early as possible to make it a low priority and
          overrideable.
        ntN   )      r   )      )WindowsProactorEventLoopPolicyWindowsSelectorEventLoopPolicy)r   r   r   version_infotornadoasyncior  r  
isinstanceget_event_loop_policyset_event_loop_policyImportError)r}   r  r  r  r  s        rQ   r   z(IPythonConsoleWidget._init_asyncio_patch!  s     77d?s//3v=##v-: 55768 1168:8!  >?  s   A? ?	B
Bc                    t        j                  t                     s	 t        j                  t                      d}|st        t        j                               j                  d      d   }t        j                  j                  t               d|z        }t        j                  j                  |      s|nd}|s|S # t
        t        f$ r Y yw xY w)z
        Generate a new connection file

        Taken from jupyter_client/console_app.py
        Licensed under the BSD license
        Nr   -zkernel-%s.json)r   r   r   r   r   IOErrorOSErrorstruuiduuid4splitpathr   exists)r}   cfidents      rQ   _new_connection_filez)IPythonConsoleWidget._new_connection_fileF  s     yy,.//12 

%++C04E135E5MNB77>>"-2B  	 W% s   C CCc                 N    | j                   j                  |j                         y r   )sig_shellwidget_createdemitre  r   s     rQ   _shellwidget_startedz)IPythonConsoleWidget._shellwidget_startedZ  s    $$))&*<*<=rP   c                 n    	 | j                   j                  |j                         y # t        $ r Y y w xY wr   )sig_shellwidget_deletedr  re  RuntimeErrorr   s     rQ   _shellwidget_deletedz)IPythonConsoleWidget._shellwidget_deleted]  s3    	((--f.@.@A 		s   %( 	44c                 l    t        j                  |       }|\  }}}}}|sy| j                  ||||       y)z/Create a client connected to an existing kernelN)r$   get_connection_parameterscreate_client_for_kernel)r}   connect_outputconnection_filehostnamesshkeypasswordoks          rQ   r  z.IPythonConsoleWidget._create_client_for_kernelc  sA     0II$O<J9(FHb))/8V*24rP   c                     || _         || _        | j                  r| j                  j	                  |       | j
                  D ]  }|j	                  |        y r   )_font
_rich_fontr   r   set_fontr   )r}   font	rich_fontr   s       rQ   update_fontz IPythonConsoleWidget.update_fonts  sJ    
#!!OO$$Y/ll 	"FOOD!	"rP   c                    d}| j                   j                         r| j                  D ]'  }	 |j                  j                  j                          ) | j                   j                         }|j                  |j                  k7  rv| j                  rj|j                          |j                  j                          |j                  j!                  | j"                         | j"                  j%                          nA| j                  r	 | j"                  j                          |j                  j%                          |j'                         }|r|j)                          t+        |t,              r| j.                  j%                          n| j.                  j                          |j0                  }| j2                  j5                  |       |j                  j                  j7                  |j8                         nd}| j:                  j=                  |       |r|j                  }| j>                  jA                  |jC                         |jE                                | jF                  jA                  |       |jI                         | jK                         k7  r| jM                  |jI                                | jO                          | jQ                          y# t        t        f$ r Y w xY w# t        $ r d| _        d| _        Y w xY w)z
        Refresh interface depending on the current widget client available.

        Refreshes corner widgets and actions as well as the info widget and
        sets the shellwdiget and client signals
        NF))r   countr   r   timeoutr  r
  	TypeErrorr   r:  r;  r   set_info_pagere  r   r   r   r   showr   setFocusr  r%   r   r   r
  
setCheckedr   	show_timer   
set_editorsig_pdb_state_changedr  is_waiting_pdb_inputget_pdb_last_stepsig_shellwidget_changedget_cwdget_working_directoryon_working_directory_changedupdate_tabs_textr>  )r}   rz   r   instance_clientcontrolr   r  s          rQ   r{   z&IPythonConsoleWidget.refresh_container}  sh    >>!#'<< #))11<<> ^^113F   F$5$55**$$&""'')''8$$&))/,,. ""'') ((*G  "'#45  %%'  %%' !' 8 8!!,,->?LL  (()9)9:G##G,##B&&++'')2+?+?+AC((--b1 zz|t99;;11"**,?y %i0 " ( /
 27.*./s#   $K
K1 K.-K.1LLc                    t        |t              sy| j                  j                  |       | j                  j                  ||      }| j                  j                  ||       | j                  j                  |       | j                  r|r| j                  j                          | j                          |j                         j                          | j                          y)zAdd tab.N)r  r!   r   r  r   addTabr   insertsetCurrentIndex
dockwidgetsig_switch_to_plugin_requestedr  activateWindowr   r"  r-  )r}   r   r   filenamerz   indexs         rQ   add_tabzIPythonConsoleWidget.add_tab  s    &,/F#%%fd3eX.&&u-??z//446%%'rP   c                     | j                   j                  |      }| j                  j                  |      }| j                   j                  ||       | j                  j                  ||       | j	                          y)zV
        Move tab (tabs themselves have already been moved by the tabwidget).
        N)r   popr   r2  r-  )r}   
index_fromindex_tor7  r   s        rQ   r   zIPythonConsoleWidget.move_tab  s`     >>%%j1!!*-h1Hf-rP   c                 n    | j                   D cg c]  }|r| }}t        j                  ||      S c c}w )z)Generate a file name without ambiguation.)r   r)   disambiguate_fname)r}   fnamer7  files_path_lists       rQ   r?  z'IPythonConsoleWidget.disambiguate_fname  s=    48NN (& $ ( (,,_eDD(s   2c                     	 t        | j                        D ]J  \  }}| j                  |   }|r"| j                  || j	                  |             9| j                  |d       L y# t
        $ r Y yw xY w)zUpdate the text from the tabs.N)rB  r   r   rename_client_tabr?  
IndexError)r}   r8  r@  r   s       rQ   r-  z%IPythonConsoleWidget.update_tabs_text  sy    		 )$.. 9 9ue,**6+/+B+B5+IK **6489  		s   A"A% %	A10A1c                     | j                  t        |            }|||_        | j                  j	                  ||j                                y)zRename a client's tab.N)get_client_index_from_idr  
given_namer   
setTabTextget_name)r}   r   rG  r8  s       rQ   rC  z&IPythonConsoleWidget.rename_client_tab  s?    --bj9! *F!!%):;rP   c                    | j                         }d}| j                  D ]-  }t        |      t        |      k7  s||j                  k(  s+d} n |j                  rd|vr|s| j                  ||       n| j                  |d       |j                  r1d|vr,|s)| j                  |      D ]  }| j                  ||        yyyy)z#Rename tabs after a change in name.FTrr   N)r4  r   r  rG  allow_renamerC  get_related_clients)r}   rG  r   repeatedcls        rQ   r   z-IPythonConsoleWidget.rename_tabs_after_change  s    ((* ,, 	B&zRV#
bmm(C	 4z#9(""6:6""640 4z#9(..v6 7&&r:67 CK#9rP   c                     | j                   j                         }| j                   j                         j                  j	                  |       y)zTrigger the tab name editor.N)r   currentIndexr   r  edit_tab)r}   r8  s     rQ   r  z$IPythonConsoleWidget.tab_name_editor  s5    ++-//88?rP   c                     t        j                  |      s| j                  j                  |       t	        j
                  |      r| j                  j                  |dd       yy)zHandle %edit magic petitions.r  r   N)r   isfilesig_edit_newr  r'   is_text_filesig_edit_goto_requested)r}   r7  lines      rQ   	edit_filezIPythonConsoleWidget.edit_file  sQ     zz(#""8,  * ((--h2> +rP   c                    	 t        dgt                     }t        d|j                  i      }t               }d|j                  _        | j                  d      }t        }||   |j                  _        | j                  d      }||j                  _	        | j                  d      }||j                  _
        | j                  d      }| j                  d      }	t        |      r||j                  _        t        |	      r|	|j                  _        | j                  d	d
      }
t        |
      d   }||j                  _        |
|j                  _        |j#                  |       |S # t        $ r t               }Y Pw xY w)z
        Generate a Trailets Config instance for shell widgets using our
        config system

        This lets us create each widget with its own config
        zjupyter_qtconsole_config.pyJupyterWidgetrichrl  rc  rh  rp  rt  rH  rl   rm   r   )r   r   r   rZ  	Exceptionkindr   r#   gui_completionenable_calltipsrh  r   rp  rt  r    style_sheetsyntax_style_merge)r}   full_cfgcfgspy_cfgcompletion_type_ocompletions
calltips_obuffer_size_oin_prompt_oout_prompt_ocolor_schemer`  s               rQ   config_optionsz#IPythonConsoleWidget.config_options)  sj   	*,I+J+=+?AH
 /8+A+ABCC
 ( &," !MM*;<,/:;L/M, ]]?3
0:- m4,9) mmK0}}\2.9G!!+/;G!!, }}Z}F&|4Q7,7)-9* 	

7
O  	(C	s   ,E( (E?>E?c                    | j                  dd      r-ddlm} t        t        j
                  |j
                        }|S ddl}i }| j                  dd      }d	|z  }d
|z  }||fD ]l  }	 t        j                  |i       }|j                         \  }	}
|	j                         j                  d      d   j                         }	d|v r|	|d<   h|	|d<   n |S # |j                  $ r d}	Y Vw xY w)z+Python and IPython versions used by clientsdefaultmain_interpreterrm   r   )release)python_versionipython_versionN
executablez&%s -c "import sys; print(sys.version)"z:%s -c "import IPython.core.release as r; print(r.version)")envr   
IPythonrs  rr  )r   IPython.corerq  dictr   version
subprocessr(   run_shell_commandcommunicateCalledProcessErrordecoder  strip)r}   rq  versionsr{  pyexecpy_cmdipy_cmdcmdprocoutput_errs              rQ   interpreter_versionsz)IPythonConsoleWidget.interpreter_versionsa  s   ==,>=?,"{{ 'H4 + H]]<9K]LF>GFM  ( 8 #55crBD#'#3#3#5LFD  ..t4Q7==?#28H./17H-.8  "44  F s   ,*CC-,C-c                     t        | j                  d      | j                  d      | j                  d      | j                  d            }|du r
d|d<   d|d	<   |du r
d|d<   d|d	<   |S )
zs
        Additional options for shell widgets that are not defined
        in JupyterWidget config options
        r  r  r  show_banner)r  autoload_pylabsympyr  Tr  Fr  )ry  r   )r}   is_pylabis_sympyr  s       rQ   additional_optionsz'IPythonConsoleWidget.additional_options  s    
 --(==)9:--0m4	
 t(,G$%$GGt(-G$%#GGrP   c                    | j                  |      }|D ]k  }|j                  |j                  |_        |j                  j                  j	                  |j
                         |j                  j                  d        y y)z#Set elapsed time for slave clients.Ni  )rL  r   t0r  r   r$  start)r}   r   related_clientsrN  s       rQ   set_client_elapsed_timez,IPythonConsoleWidget.set_client_elapsed_time  si    226:! 	Bxx#EE	$$,,V-=-=>""4(	rP   c                     t        j                         }| j                  D ]  }||u s||j                         u s|c S  y)z(Return current client with focus, if anyN)r   focusWidgetr   r   )r}   widgetr   s      rQ   get_focus_clientz%IPythonConsoleWidget.get_focus_client  s@    ))+ll 	F6V-?-?-A#A	rP   c                 @    | j                   j                         }||S y)z$Return the currently selected clientN)r   r   r   s     rQ   r4  z'IPythonConsoleWidget.get_current_client  s$    --/M rP   c                 @    | j                         }||j                  S y)z,Return the shellwidget of the current clientN)r4  re  r   s     rQ   r   z,IPythonConsoleWidget.get_current_shellwidget  s'    ((*%%% rP   c	           	         | xj                   dz  c_         t        t        | j                         d      }	| j                  r| j                  nd}
| j	                  ||||
|      \  }}}}}|t        |d|
      }nd}| j                  d      }| j                  d      }| j                  d	      }| j                  d
      }t        | fi d|	dt        d      d| j                         d| j                  ||      d| j                         d|d| j                  d|d|d|d|d	|d
|d| j                  d| j                  d|d|d|d|}| j                  ||j!                         ||       |5| j"                  j%                  t'                     }|j)                  |       y|j+                         sy| j-                  |||       |j.                  j0                  y| j3                  ||       |S )zCreate a new clientr  Aint_idstr_idN)std_dircachez.faultr   rO  rW  r^  id_history_filename
history.pyrm  r  )r  r  r  r  r  rR  rG  rz   rk   handlers
stderr_obj
stdout_obj	fault_objinitial_cwd)r   r7  rz   ry   )r   ry  r  r   get_new_kernelr0   r   r!   r   rm  r  r  r  rk   r   r9  rI  PERMISSION_ERROR_MSGr   r   show_kernel_errorhas_spyder_kernelsconnect_client_to_kernelre  kernel_managerregister_client)r}   rz   r7  	is_cythonr  r  rG  r  r  	client_idr  r  kmkcr  r  r  r   rR  rW  r^  r   	error_msgs                          rQ   r   z&IPythonConsoleWidget.create_new_client  sp    	q D$7$7 8 #%	$(NN$..-1-@-@x7% .A .I*BJ
 >Hg6II MM*=>&DE!]]+?@!]]+?@d 7	 7/<\/J7-1-@-@-B7 261H1H/7/7 2I 297 483L3L3N7 /17 483L3L7 1B7 -:7 *47 *47 2D7 2D7 (,}}7  (,'M'M!7" *4#7$ *4%7& )2'7( +6)7, 	*X! 	 	# :11889L9NOI$$Y/ ((*%%fb"5,,4V
;rP   c           	      
    	 t        j                  |      }t        j                  |      }|r|nd}t        ||      }t        j
                  j                  |      d   dk7  rt        |dz   |      }d}d}d}	d}
t        d	      dz
  }d}d}d}d} j                  D ]  }||j                  v s|j                         |j                         }|j                  }||j                   d
   }|j"                  j$                  }	|j"                  j&                  }
|j(                  r|j(                  j+                         }|j,                  r|j,                  j+                         }|j.                  r|j.                  j+                         }|j0                  }t        |j                   d         }||kD  s|} |* xj2                  dz  c_        t5         j2                        }t7        |t9        |dz               } j;                  d      } j;                  d      } j;                  d      }t=         fi d|d|dt?        d      d jA                         d jC                         d jE                         d|d jF                  d|d|	d|
d|d|d|d jH                  d jJ                  d|d |d!|}tM        |"      }	 |jO                          ||	 t7        |jR                  |jT                  |jV                  |jX                  |jZ                  %      } j]                  ||||      }|\  |_*        |_+        |_,        |_-        |||f|_/        |ja                          |j"                  jc                  ||       jd                  jg                   jd                         |
s5jh                  jg                   jj                         jm                           jn                  jq                         |jr                  jg                   fd'       |	s ju                  |        jw                  ||jy                         (        j{                  |       y# t        t        f$ r/ t        j                   t        d      t        d      |z         Y yw xY w# tP        $ r?}t        j                   t        d#      t        d$      t5        |      z          Y d}~yd}~ww xY w# tP        $ r?}t        j                   t        d#      t        d&      t5        |      z          Y d}~yd}~ww xY w))z0Create a client connected to an existing kernel.N)r7  r  r  z.jsonrw  zUnable to connect to <b>%s</b>TFr  r  r  r  r   rO  rW  r  rG  r  r  rm  r  r  r  r  r  is_external_kernelis_spyder_kernelrR  rk   r  r  r  r  )r  zConnection errorzSAn error occurred while trying to load the kernel connection file. The error was:

)ip
shell_port
iopub_port
stdin_porthb_portz+Could not open ssh tunnel. The error was:

c                  :     j                   j                        S r   )r	  r  r}   re  s   rQ   r~   z?IPythonConsoleWidget.create_client_for_kernel.<locals>.<lambda>  s    D0055kB rP   )r   )>r   dirnamebasenamer   r   r  splitextr  UnboundLocalErrorr   criticalr   ordr   r  
get_kernelr  re  r  r  r  copyr  r  rG  r   r  ry  chrr   r!   r   rm  r  r  r  rk   r   r   load_connection_filer\  r  r  r  r  r  tunnel_to_kernelssh_parametersstart_channelsset_kernel_client_and_managersig_exception_occurredr   sig_is_spykernelconnect_external_spyder_kernelcheck_spyder_kernelr  r  stopped_channelsr  r9  rI  r  )r}   r  r  r  r  cf_pathcf_filename	master_idrG  r  known_spyder_kernel	slave_ordr  r  r  r  rN  new_slave_ordr  r   rR  rW  r   kernel_clienteconnection_infonewportsre  s   `                          @rQ   r  z-IPythonConsoleWidget.create_client_for_kernel  sg   	kk/2G,,7K!(gdG2K8?AOww03w>"6(72#B 	
!#HqL	

	,, 	.B""4"44==?.%']]_N"$"4"4$ "x 0I)+)J)J&*,..*I*I'}}%']]%7%7%9
}}%']]%7%7%9
||$&LL$5$5$7	]]
 #BFF8$4 5 9, -I%	., 1$D//0I 	 #IM 24	 !MM*=>&DE!]]+?@d 3"+3)33 0=\/J3 .2-@-@-B	3
 261H1H1J3 483L3L3N3 />3 483L3L3 (03 2D3 0C3 1B3 -:3 2D3 (,}}3  (,'M'M!3" *4#3$ *4%3& )2'3, 'G	..0 "&$'',77,77,77)11#3  00(17C
 +3()))&08&(/K, 	$$&((11>	+**22''	) #((00335++-$$))+6&&..B	D "((0 	V&//"34 	V$K *+ 	  q|!" $/ "02A"BC 		^  	  q);'<!" $. "/14Q"89 	.  $$T1-?+@%& (8 &9;>q6&BC 	sC   A2Q/ R0 *A;S; /;R-,R-0	S895S33S8;	U5T>>Uc                 *    | j                  dd       y)zForce creation of Pylab clientTPylab)r  rG  Nr   r   s    rQ   r  z(IPythonConsoleWidget.create_pylab_client      ArP   c                 *    | j                  dd       y)zForce creation of SymPy clientTSymPy)r  rG  Nr  r   s    rQ   r  z(IPythonConsoleWidget.create_sympy_client  r  rP   c                 *    | j                  dd       y)zForce creation of Cython clientTCython)r  rG  Nr  r   s    rQ   r  z)IPythonConsoleWidget.create_cython_client  s    (CrP   c                    | j                  |||      }| j                  ||      }|d   |s| j                          |S d}| j                  | j                  \  }	}
}}}|j                   |	j                   ||k(  xr; |	j
                  |j
                  k(  xr  |j                  |k(  xr |j                  |
k(  }|s| j                          d}||j                  |j                  ||f| _        || j                  ||      S |S )z.Get a new kernel, and cache one for next time.r  r  r  r  N)create_kernel_speccreate_new_kernelclose_cached_kernelr   interrupt_mode__dict__argvru  )r}   r  r  r  r  r  kernel_spec
new_kernelcached_kernelcached_spec
cached_envcached_argv
cached_dirvalids                 rQ   r  z#IPythonConsoleWidget.get_new_kernel  s?    -- . 
 ++KA
a= $$& ))5
 #<<	[&&&&
* 7$--1E1EE7$))[87 %J6  ((* $ OO*&  ))+w??rP   c                     | j                   y| j                   d   }|\  }}}}}|j                          |j                  d       d| _         |r|j                          |r|j                          yy)zClose the cached kernel.Nr  T)now)r   stop_restartershutdown_kernelr  )r}   r  r   r  r  r  s         rQ   r  z(IPythonConsoleWidget.close_cached_kernel  sy    ))166r:7D4>1j*%%'&&4&0)-& rP   c                     | j                         }|yd}d}d}d}| j                  s2t        |d|      }|j                  }t        |d|      }|j                  }| j	                  ||||      \  }}	|||	||fS )zCreate a new kernel.N)NNNNNz.stderrz.stdout)r  r   r0   handle'create_kernel_manager_and_kernel_client)
r}   r  r  r  r  stderr_handler  stdout_handler  r  s
             rQ   r  z&IPythonConsoleWidget.create_new_kernel  s    335"/

## )WEJ&--M )WEJ&--M==	
B B
J>>rP   c                     t        |t              r%|#d|j                  _        |j	                  |       y j
                  s |j                  j                  |f fd	       |j                  dd       |j                  }|j                  ||       |j                  j                   j                          j                  |       y)zConnect a client to its kernel.Nc                 &    j                  |       S r   )r  )r  r}   s    rQ   r~   z?IPythonConsoleWidget.connect_client_to_kernel.<locals>.<lambda>  s    !:!:1!= rP   T)shelliopub)r  r  re  r  r  r   r  r   r  r  r  r  )r}   r   r  r  re  s   `    rQ   r  z-IPythonConsoleWidget.connect_client_to_kernel  s     b#2:04F-$$R( }}''=? 	D1((11"b9**22''	)& 	!!&)rP   c                 (    | j                  |       y)z.Create a client with its cwd pointing to path.)r  Nr  )r}   r  s     rQ   create_client_from_pathz,IPythonConsoleWidget.create_client_from_path  s     	40rP   c                     | j                  ||      }| xj                  dz  c_        d|_        | j                  |      }| j	                  ||       |S )z2Create a client to execute code related to a file.)r7  r  r  F)r   r   rK  r?  rC  )r}   r7  r  r   tab_texts        rQ   create_client_for_filez+IPythonConsoleWidget.create_client_for_file  s`     '' ( 4 	q  $**84vx0rP   c                     d}t        | j                        D ]7  \  }}| j                  |   |k(  s| j                  j	                  |       |} |S  |S )z(Get client associated with a given file.N)rB  r   r   r   r3  )r}   r7  r   r|   rN  s        rQ   get_client_for_filez(IPythonConsoleWidget.get_client_for_file/  sZ     . 	GC~~c"h...s3	
 rP   c                     |j                  |       |j                  }|j                  }|j                  j	                   j
                         |j                  j	                   j                         |j                  j	                   j                         |j                  j	                  |f fd	       |j                  j	                   j                         |j                  j	                   j                          j                  j                  |j                         |j                   j	                   j                          |j#                   j$                          j&                  j)                  |       |j*                  j	                   j,                         |j.                  j	                   j0                         |j2                  j	                   j4                  j6                         y)zRegister new clientry   c                 *    j                  | ||      S r   )pdb_has_stopped)r@  linenore  r}   s      rQ   r~   z6IPythonConsoleWidget.register_client.<locals>.<lambda>K  s      < rP   N)configure_shellwidgetre  _controlsig_new_clientr   r   sig_go_to_error_requestedgo_to_errorsig_help_requestedsig_pdb_stepr&  custom_edit_requestedrX  sig_history_requestedr  r  sig_append_to_history_requestedr  r  r   r%  sig_working_directory_changedr,  sig_execution_state_changedr>  sig_time_labelr"  setText)r}   r   rz   re  r/  s   `    rQ   r  z$IPythonConsoleWidget.register_client9  s   $$
$; ((&& 	""**4+A+AB 	))11$2B2BC 	""**4+B+BC  ((.9 =	> 	))11$2L2LM 	))11$..A 	""''(?(?@..6600	2 	

# 	##G, 	1199--	/ 	**2243F3FG 	%%doo&=&=>rP   c                 :   | j                   j                         sy|0|| j                  vry| j                   j                  |      }|dk(  ry||| j                   j	                         }|| j                   j                  |      }| j                  s|rd}|j                  rlt        j                  | | j                  j                         t        d      t        j                  t        j                  z        }|t        j                  k(  ryt        | j!                  |            dkD  rXt        j                  | | j                  j                         t        d      t        j                  t        j                  z        }|t        j                  k(  r| j#                  |       | j                   j%                  | j                   j                  |             | j                  j'                  |       t        | j!                  |            dk(  }|j)                  |       	 | j*                  j-                  |       | j1                          | j                   j                         s| j2                  r| j5                          yyy# t.        $ r Y Tw xY w)z<Close client tab from index or widget (or close current tab)Nr  Tz"Do you want to close this console?r   zQDo you want to close all other consoles connected to the same kernel as this one?)r   r  r   indexOfrP  r  r   r^  r   question_pluginrI  r   YesNor  rL  close_related_clients	removeTabr  r   r   r;  rD  r-  r   r   )r}   r8  r   ask_recursive	close_allcloseis_last_clients          rQ   r   z!IPythonConsoleWidget.close_clientg  s    ~~##%T\\)NN**62E {=V^NN//1E^^**51F $$I((#,,LL))+:;OOknn4	6
 KNN*4++F34q8'00LL))+ 8 9OOknn46	 KOO+**62 	  !7!7!?@F#T55f=>!CN+	NNu% 	 ~~##%$*I*I""$ +J%  		s   *J 	JJc                 0   | j                   j                         }| j                   D ]B  }t        | j                  ||            dk(  }|j	                  |       |j                  |       D t        j                          | j                          g | _	        y)z
        Perform close actions for each running client.

        Returns
        -------
        bool
            If the closing action was succesful.
        r   T)
r   r  r  rL  r   r  r&   wait_all_shutdownr  r   )r}   open_clientsr   r'  s       rQ   r   z&IPythonConsoleWidget.close_all_clients  s     ||((*ll 	(FD,,V\BCqH /'		( 	%%' 	  "rP   c                 b    t        | j                        D ]  \  }}t        |      |k(  s|c S  y)zReturn client index from idN)rB  r   r  )r}   r  r8  r   s       rQ   rF  z-IPythonConsoleWidget.get_client_index_from_id  s/    &t||4 	ME6&zY&	rP   c                     || j                   }g }|D ]2  }|j                  |j                  k(  s||us"|j                  |       4 |S )zY
        Get all other clients that are connected to the same kernel as `client`
        )r   r  r  )r}   r   clients_listr  rN  s        rQ   rL  z(IPythonConsoleWidget.get_related_clients  sY     <<L 	+B""f&<&<<f$&&r*	+ rP   c                 Z    | j                  |      }|D ]  }| j                  |d        y)z4Close all clients related to *client*, except itselfFr   r$  N)rL  r   )r}   r   r  s      rQ   r"  z*IPythonConsoleWidget.close_related_clients  s6    226:% 	BFV5A	BrP   c                     d| _         d| _        t        t        | j                              D ]$  }| j                  d   }| j                  |d       & | j                  dd       d| _        y)z
        Restart the console

        This is needed when we switch projects to update PYTHONPATH
        and the selected interpreter
        r   Fr  r/  )rz   r  TN)r   r   ranger  r   r   r   )r}   ir   s      rQ   r   zIPythonConsoleWidget.restart  sq      */'s4<<() 	BA\\"%FV5A	B 	%u=*.'rP   c                 J    | j                         }|r|j                          y y r   )r4  inspect_objectr   s     rQ   r  z2IPythonConsoleWidget.current_client_inspect_object  s$    ((*!!# rP   c                 J    | j                         }|r|j                          y y r   )r4  
clear_liner   s     rQ   r  z.IPythonConsoleWidget.current_client_clear_line  s$    ((* rP   c                 J    | j                         }|r|j                          y y r   )r4  clear_consoler   s     rQ   r  z1IPythonConsoleWidget.current_client_clear_console  $    ((*  " rP   c                 J    | j                         }|r|j                          y y r   )r4  exit_callbackr   s     rQ   r  z(IPythonConsoleWidget.current_client_quit  r9  rP   c                 J    | j                         }|r|j                          y y r   )r4  enter_array_inliner   s     rQ   r  z6IPythonConsoleWidget.current_client_enter_array_inline  s$    ((*%%' rP   c                 J    | j                         }|r|j                          y y r   )r4  enter_array_tabler   s     rQ   r  z5IPythonConsoleWidget.current_client_enter_array_table   s$    ((*$$& rP   c                 "    || j                   |<   y)a  
        Register a callback for it to be available for newly created
        client kernels.

        Parameters
        ----------
        handler_id : str
            Handler name to be registered and that will be used to
            call the respective handler from the Spyder kernel.
        handler : func
            Callback function that will be called when the kernel request
            the handler_id identifier.

        Returns
        -------
        None.
        N)r   )r}   
handler_idhandlers      rQ   #register_spyder_kernel_call_handlerz8IPythonConsoleWidget.register_spyder_kernel_call_handler  s    $ >E..z:rP   c                 <    | j                   j                  |d       y)aQ  
        Unregister and remove a handler to not be added to newly created
        client kernels.

        Parameters
        ----------
        handler_id : str
            Handler name that was registered and will be removed from
            the Spyder kernel available handlers.

        Returns
        -------
        None.
        N)r   r;  )r}   rA  s     rQ   %unregister_spyder_kernel_call_handlerz:IPythonConsoleWidget.unregister_spyder_kernel_call_handler  s     	..22:tDrP   c                 p    t         j                  dk(  rt        j                  |i |S t	        | g|i |S )Nr  )r   r   	zmqtunnelparamiko_tunnelr   )r}   argskwargss      rQ   
ssh_tunnelzIPythonConsoleWidget.ssh_tunnel,  s8    77d?,,d=f==!$8888rP   c           
          t        j                  d      }|d   |d   |d   |d   f}|d   }t        ||      D ]  \  }	}
| j                  |	|
|||||        t	        |      S )zx
        Tunnel connections to a kernel via ssh.

        Remote ports are specified in the connection info ci.
           r  r  r  r  r  )rG  select_random_portsziprK  tuple)r}   r  r  r  r  r  lportsrports	remote_iplprps              rQ   r  z%IPythonConsoleWidget.tunnel_to_kernel2  s     ..q1!,/1N!,/1KM#D)	&&) 	%FBOOBHi#%	% V}rP   c                     t        |||      S )z(Create a kernel spec for our own kernelsr  r   )r}   r  r  r  s       rQ   r  z'IPythonConsoleWidget.create_kernel_specB  s      ))1)13 	3rP   c                    	 t        |dd      }||_        	 |j                  |||j                         |j                         }d|j                  _        ||fS # t        $ r3 t        d      j                  t	        j
                               }|dfcY S w xY w# t        $ r3 t        d      j                  t	        j
                               }|dfcY S w xY w)z!Create kernel manager and client.NT)r  configautorestartz The error is:<br><br><tt>{}</tt>)stderrstdoutru  g      9@)r   r\  r   r   	traceback
format_exc_kernel_specstart_kernelru  r   
hb_channeltime_to_dead)r}   r  r  r  r  r  r  r  s           rQ   r  z<IPythonConsoleWidget.create_kernel_manager_and_kernel_clientI  s    		%0 / N '2#	%''}/<,7OO ( = '--/ 15  -},,1  	% ( ))/	0D0D0F)G t$$	%  	% ( ))/	0D0D0F)G t$$	%s"   A B 9BB9CCc                 ~    | j                         }|+| j                  j                          |j                          yy)z!Restart kernel of current client.N)r4  r5  r  r   r   s     rQ   r   z#IPythonConsoleWidget.restart_kernelo  s9    ((*//446!!# rP   c                 ~    | j                         }|+| j                  j                          |j                          yy)z"Reset namespace of current client.N)r4  r5  r  r   r   s     rQ   r   z$IPythonConsoleWidget.reset_namespacev  s9    ((*//446""$ rP   c                 ~    | j                         }|+| j                  j                          |j                          yy)z#Interrupt kernel of current client.N)r4  r5  r  stop_button_click_handlerr   s     rQ   r  z%IPythonConsoleWidget.interrupt_kernel}  s9    ((*//446,,. rP   c                     d|_         |j                  j                  |j                         | j                  j                  |       | j                  j                  |       y)z%Connect to an external Spyder kernel.TN)r  spyder_kernel_comm	open_commr  r)  r  $sig_external_spyder_kernel_connectedr  s     rQ   r  z3IPythonConsoleWidget.connect_external_spyder_kernel  sL    '+$&&001J1JK$$))+61166{CrP   c                     | j                   t        t        t        t        f   j	                  ||dd       |j
                  rd|_        y| j                          |j                  j                          y)z9Python debugger has just stopped at frame (fname, lineno)r   FN)	rV  r  intr   r  _pdb_focus_to_editorr6  r  r"  )r}   r@  r  re  s       rQ   r  z$IPythonConsoleWidget.pdb_has_stopped  s`    
 	$$S#sD%89>>62u	& ++/4K,!  ))+rP   c                 Z    | j                   D ]  }|j                  j                           y)z'Set Spyder breakpoints into all clientsN)r   re  set_spyder_breakpoints)r}   rN  s     rQ   rn  z+IPythonConsoleWidget.set_spyder_breakpoints  s%    ,, 	4BNN113	4rP   c                 n    | j                         }|	 |j                  ||       yy# t        $ r Y yw xY w)z=
        Send command to the pdb kernel if possible.
        N)r   pdb_execute_commandAttributeError)r}   commandfocus_to_editorr  s       rQ   rp  z(IPythonConsoleWidget.pdb_execute_command  sE     ))+>&&w@	 
 " s   ( 	44c                 J    | j                         }||j                          yy)zStop debuggingN)r   stop_debuggingr}   r  s     rQ   ru  z#IPythonConsoleWidget.stop_debugging  s&    ))+> rP   c                 H    | j                         }||j                         S y)z+Get debugging state of the current console.F)r   r'  rv  s     rQ   get_pdb_statez"IPythonConsoleWidget.get_pdb_state  s'    ))+>**,,rP   c                 J    | j                         }||j                         S i S )z)Get last pdb step of the current console.)r   r(  rv  s     rQ   r(  z&IPythonConsoleWidget.get_pdb_last_step  s)    ))+>''))	rP   c                     | j                         }|rF| j                         }| j                         }d|v r!||d   }|d   }| j                  |||       yyyy)zP
        Check if actions need to be taken checking the last pdb state.
        r@  Nr  )rx  r(  r   r  )r}   	pdb_statepdb_last_stepr  r@  rW  s         rQ   check_pdb_statez$IPythonConsoleWidget.check_pdb_state  sp     &&(	 224M--/B-'BN%g.$X.$$UD"5 -;' rP   c                 p    t        d      }| j                         j                  j                  |d       y)zAPrint message in the current console when a file can't be closed.z>The current file cannot be closed because it is in debug mode.T)before_promptN)r   r4  re  append_html_message)r}   	debug_msgs     rQ   print_debug_file_msgz)IPythonConsoleWidget.print_debug_file_msg  s9     ' (	!--AAT 	B 	+rP   c           	         d }|| _         | j                  |      }|| j                         }||j                         ]|s[t	        d      j                  t	        |      t        |       ||      j                  dd            }	|dk(  r"||j                  _	        n|j                         }		 | j                  |	|        |s| j                  j                          yyt        j                   | t#        d      t#        d	      j                  t%        j&                  |            t        j(                         y# t        $ r Y w xY w)
z(Run cell in current or dedicated client.c                 *    t        t        |             S r   r+   r  r   s    rQ   normz+IPythonConsoleWidget.run_cell.<locals>.norm  s    %c$i00rP   Nz{}({}, '{}')'z\'	debugcell	set_focusWarningzgNo IPython console is currently available to run <b>{}</b>.<br><br>Please open a new one and try again.)r   r	  r4  r  r  r   reprreplacere  rl  r  execute_coderq  r5  r  r   warningr   r   r  Ok)
r}   code	cell_namer7  run_cell_copyrs  functionr  r   rW  s
             rQ   run_cellzIPythonConsoleWidget.run_cell  s;   	1 "* ))(3>,,.F  ".}&((. #H $Y $X 6 6sE B)D  {*>MF&&; zz|!!$o2E!F #3388: # ) ' ((.s||H/E(F " s   .D; ;	EEc                 0    | j                  |||||d       y)zDebug current cell.r  N)r  )r}   r  r  r7  r  rs  s         rQ   
debug_cellzIPythonConsoleWidget.debug_cell	  s     	dIx%{	4rP   c
                 *   	 d }
t        j                  |      d   dk(  }|rdd}r j                         n( j                  |       j	                  ||      d}Nj
                  j                  rY|rdnd	d
 |
|      d|rd |
|      z  z  |rd |
|      z  z  |rdz  |rdz  dz  |r<	j
                  _        n*d|rdz  dt        |      z  z  |rd |
|      z  z  	 j
                  j                  rnr j                  	        nf|rj
                  j                  d       nj
                  j                  d       j
                  j                  j                  	 fd       	s j                   j#                          yyt%        j&                   t)        d      t)        d      t        j*                  |      z  t$        j,                         y# t        $ r Y xw xY w)z)Run script in current or dedicated clientc                 *    t        t        |             S r   r  r  s    rQ   r~   z1IPythonConsoleWidget.run_script.<locals>.<lambda>	  s    .s4y9 rP   r  z.pyxFN)r  T	debugfilerunfilez('r  z, args='%s'z, wdir='%s'z, post_mortem=Truez, current_namespace=True)z%run z-d z"%s"z %sr  z%clearc                  F    j                    j                        S )N)r  re  )r  re  )clear_variablesr   r  rs  rW  r}   s   rQ   r~   z1IPythonConsoleWidget.run_script.<locals>.<lambda>T	  s-     1 1 ./*9&9(.(:(: !2 ! rP   r  zgNo IPython console is currently available to run <b>%s</b>.<br><br>Please open a new one and try again.)r   r  r4  r	  r  re  r  rl  r  r  r  silent_executeexecuter  r   rq  r5  r  r   r  r   r  r  )r}   r7  wdirrI  debugpost_mortemr  r  console_namespacers  r  r  is_new_clientr   rW  s   `     `` `   @@rQ   
run_scriptzIPythonConsoleWidget.run_script	  s@    : LL*1-7	"N ,,.F--h7F~44	 5 3 $!!2238Ki$G$(N4MDJ66DMDJ66D00D$66D>MF&&;EMD3x=00EDJ..D%%00 #%%dNO4C0C & E %**99(C**228<&&77??  #3388: # ) A ll8,-  " s   BH 	HHc                 f    t        j                  |      r| j                  j                  |       yy)zc
        Set current working directory in the Working Directory and Files
        plugins.
        Nr   r   sig_current_directory_changedr  r}   r  s     rQ   set_working_directoryz*IPythonConsoleWidget.set_working_directoryl	  s)    
 99W..33G< rP   c                     || _         y)zf
        Save current working directory when changed by the Working Directory
        plugin.
        Nr   r  s     rQ   save_working_directoryz+IPythonConsoleWidget.save_working_directoryt	  s    
 +2'rP   c                     | j                   S )z-Get saved value of current working directory.r  r   s    rQ   r+  z*IPythonConsoleWidget.get_working_directory{	  s    ...rP   c                 L    | j                         }||j                  |       yy)z%Set current client working directory.N)r   set_cwd)r}   	directoryre  s      rQ   $set_current_client_working_directoryz9IPythonConsoleWidget.set_current_client_working_directory	  s)    224"	* #rP   c                 l    |r2t        j                  |      r| j                  j                  |       yyy)zp
        Notify that the working directory was changed in the current console
        to other plugins.
        Nr  r  s     rQ   r,  z1IPythonConsoleWidget.on_working_directory_changed	  s-    
 syy)..33G< *7rP   c                 J    | j                         }||j                          yy)z(Update working directory to console cwd.N)r   
update_cwdr  s     rQ   update_working_directoryz-IPythonConsoleWidget.update_working_directory	  s'    224"""$ #rP   c                     t         j                  d       | j                  D ]#  }|j                  }||j	                  ||       % y)zUpdate path on consoles.z&Update sys.path in all console clientsN)loggerr  r   re  update_syspath)r}   	path_dictnew_path_dictr   r  s        rQ   update_pathz IPythonConsoleWidget.update_path	  sC    =>ll 	?F&&E $$Y>	?rP   c                     | j                   S )zGet the active project path.r   r   s    rQ   get_active_project_pathz,IPythonConsoleWidget.get_active_project_path	  s    '''rP   c                     || _         y)aB  
        Update the active project path attribute used to set the current
        working directory on the shells in case a project is active

        Parameters
        ----------
        active_project_path : str
            Root path of the active project if any.

        Returns
        -------
        None.
        Nr  )r}   r   s     rQ   update_active_project_pathz/IPythonConsoleWidget.update_active_project_path	  s     $7 rP   c                    |r| j                         }n|}||s0	 |j                  j                          |r)|j	                  d       n|r|r|j	                  d       	 |j                  t        |             |r4| j                          | j                         }|r|j                          yyyy# t        $ r Y w xY w# t        $ r Y Rw xY w)zExecute code instructions.NF)r  )r   r  r  r  r   r  r  rq  r6  r   r"  )r}   linesr  r  r  re  r  focus_widgets           rQ   r  z!IPythonConsoleWidget.execute_code	  s     --/BB>!''224 #&&u&5O""5"1

3u:&  ##%  $446 ))+   +  !  " s#   B3 !C 3	B?>B?	CCc                 T   t        t        |            }|r|j                         \  }}d|v r| j                  | j                  }d|v rt	        j
                  |      }	 | j                  j                  t	        j                  |      t        |      d       yy# t        $ r Y yw xY w)zGo to error if relevantz<ipython-input-N~r   )r*   r  groupsr   r   
expanduserrV  r  abspathrk  
ValueError)r}   r   matchr@  lnbs        rQ   r  z IPythonConsoleWidget.go_to_error	  s    D	*JE3!U***6.. e|u-,,11KK&C"6 "  s    9B 	B'&B'c                 H    ddl m} | j                  j                  |d       y)zShow intro to IPython helpr   )interactive_usageFN)IPython.core.usager  sig_render_rich_text_requestedr  )r}   r  s     rQ   r%  zIPythonConsoleWidget.show_intro	  s     	9++001BEJrP   c                 H    ddl m} | j                  j                  |d       y)zShow qtconsole helpr   )gui_referenceTN)qtconsole.usager  r  r  )r}   r  s     rQ   r'  z IPythonConsoleWidget.show_guiref	  s     	2++00ErP   c                 F    ddl m} | j                  j                  |       y)zShow IPython Cheat Sheetr   )quick_referenceN)r  r  sig_render_plain_text_requestedr  )r}   r  s     rQ   r&  z"IPythonConsoleWidget.show_quickref	  s     	7,,11/BrP   )NNN)F)r   T)FF)Tr   FFFNTN)FFFNTr   )T)NNT)NN
   )FFF)runcell)TFTN)r7   r8   r9   __doc__r   r  r  r  sig_focus_changedr5  rk  r   rV  rT  ry  r&  objectr  r	  r)  ri  r  r  r  r  r   r  r   r   r   r   r2  r	  r>  r   rG  rL  rN  rV  r\  rb  rg  rk  ro  rs  rw  r{  r  r  r  r  r  r  rC  r  r   r  r  r  r   r  r  r{   r9  r   r?  r-  rC  r   r  rX  rm  r  r  r  r  r4  r   r   r  r  r  r  r  r  r  r  r  r  r	  r  r   r   rF  rL  r"  r   r  r  r  r  r  r  rC  rE  rK  r  r  r  r   r   r  r  r  rn  rp  ru  rx  r(  r}  r  r  r  r  r  r  r+  r  r,  r  r  r  r  r  r  r%  r'  r&  __classcell__)r   s   @rQ   ri   ri   x   s    '-S#&6#
 #3K  &,X" %c3_sCd6KL" #;L #4.
 %Vn %Vn %Vn ,2&>( '-Sk# &,C%6"
   %+3K!  1 2j9X!$(
A6F%G* F+DE F L*j1IJ K ./% 0% 9: ; /0 1 /0 1 ?+ , =) * ,-/ ./ ;' ( <( ) -. / +, - :& ' +, - /0 1 56 7  $ %y3%y3z5B'LR#:J(> 
V4 4"HX  E<7.@ 
&&? ?6p@,& 
V	$Z	#Y	$_	$	$THMEI26<      <|T%lBBD 8=;?0d ?0&*P 
#Y1 1 ,?\:%x8B/$
 
#
#
(
'E(E"9 BF02  ,1493$-L$%/D, 4
 6+ ,52h4Tn=2/+=%?(7" HM15',T2 
VK K
 
VF F
 
VC CrP   ri   )]r  loggingr   os.pathr  r   r   r\  r  jupyter_client.connectr   jupyter_core.pathsr   r   qstylizer.styler   qtconsole.clientr   qtpy.QtCorer   r   
qtpy.QtGuir	   qtpy.QtWebEngineWidgetsr
   qtpy.QtWidgetsr   r   r   r   r   r   traitlets.config.loaderr   r   zmq.sshr   rG  spyder.api.config.decoratorsr   spyder.api.translationsr   spyder.api.widgets.main_widgetr   spyder.api.widgets.menusr   spyder.config.baser   r   r   .spyder.plugins.ipythonconsole.utils.kernelspecr   +spyder.plugins.ipythonconsole.utils.managerr   'spyder.plugins.ipythonconsole.utils.sshr   )spyder.plugins.ipythonconsole.utils.styler    %spyder.plugins.ipythonconsole.widgetsr!   r"   r#   r$   r%   r&   spyder.utilsr'   r(   r)   spyder.utils.miscr*   r+   spyder.utils.paletter,   spyder.widgets.browserr-   spyder.widgets.findreplacer.   spyder.widgets.tabsr/   +spyder.plugins.ipythonconsole.utils.stdfiler0   	getLoggerr7   r  COLOR_BACKGROUND_1r   r2   rS   rY   ra   re   ri   rO   rP   rQ   <module>r     s   
  	  
   8 F  + $  -J J ? ' 8 % ; 37 7 K K B F< < 8 7 A . / 2 $ ? 
		8	$ 00' 'B, ,
 * * K&C+ K&CrP   