
    ` Ie*                         d Z ddlZddlmZ ddlZddlZddlmZ ddl	Z	ddl
mZ ddlmZmZ ej                  d   dk(  Ze	j"                  d   dk\  Zd Zd	 Zd
 Zd Zd Zedk(  r e        yy)z4
File used to start kernels for the IPython Console
    N)DottedObjectName)is_module_installed)MPL_BACKENDS_FROM_SPYDERINLINE_FIGURE_FORMATS26c                     t        j                  t              } t        j                  |       }t        j                  |d      }dt        j
                  v r2t        j
                  j                  d       dt        j
                  v r2t        j                  |       ddl	}	 t        j
                  j                  |       y# t        $ r Y yw xY w)z*Import our customizations into the kernel.	customize r   N)ospdirname__file__joinsyspathremovesite
addsitedirspydercustomize
ValueError)hereparentcustomize_dirr   s       >/usr/lib/python3/dist-packages/spyder_kernels/console/start.pyimport_spydercustomizer       s    ;;x D[[FHHV[1M . . 	OOM"& s   #C 	CCc                 4    | dj                  |       }|S d}|S )zSympy configurationzK
from sympy.interactive import init_session
init_session()
%matplotlib {0}
z;
from sympy.interactive import init_session
init_session()
)format)mpl_backendliness     r   sympy_configr    8   s3     F;	 	 L
 L    c                     ddl m}  ddlm}m} 	 t        j                   |        d      } |ddg|      } |       }t        j                  j                  d      dk(  }|rd	|j                  _        d
|j                  _        t        j                  j                  d      dk(  }t        s||j                  _        d}|g|j"                  _        t        s%|j"                  j$                  j'                  d       t(        j*                  dd dk\  r%|j"                  j$                  j'                  d       t        j                  j                  d      }	|	J|j"                  xj$                  |	j-                  d      D 
cg c]  }
|
j/                          c}
z  c_        |j"                  j$                  j'                  d       |j"                  j$                  j'                  d       ddddddd|j0                  _        d}t5        d      rt        j                  j                  d      }t        j                  j                  d      }|dk(  rO|Lt6        |   }|dk(  r?t        j                  j                  d       }t8        }|||   |j0                  _        t        j                  j                  d!      }|"t=        |      |j0                  j2                  d"<   t=        t        j                  j                  d#            }t=        t        j                  j                  d$            }||||f|j0                  j2                  d%<   t        j                  j                  d&      }|dk(  rd'nd}|j0                  j>                  jA                  d(|i       nd}t        j                  j                  d)      dk(  }d*}|j"                  j$                  j'                  |jC                  ||             t        j                  j                  d+      dk(  }|r0t5        d,      r%|j"                  j$                  j'                  d-       t        j                  j                  d.      }t        j                  j                  d/      }|dk(  r(|&t        jD                  |      r||j"                  _#        t        j                  j                  d0      }|tI        |      |jJ                  _&        d1|jJ                  _'        t        j                  j                  d2      dk(  }||j                  _(        t        j                  j                  d3      dk(  }|r;t5        d4      r0tS        |      }|j"                  j$                  j'                  |       t        sd	|j"                  _*        |jW                  |       |S #   |       }Y xY wc c}
w )5z3Create a config object with IPython kernel options.r   )get_ipython_dir)Configload_pyconfig_filesprofile_defaultzipython_config.pyzipython_kernel_config.pySPY_TESTINGTrueFPlain
SPY_JEDI_Oz$import sys; sys.argv = ['']; del syszfimport builtins; builtins.runfile = builtins.spyder_runfile; del builtins.spyder_runfile; del builtins   )      zLimport sys; import pdb; sys.breakpointhook = pdb.set_trace; del sys; del pdbSPY_RUN_LINES_ON;z-get_ipython().kernel._load_autoreload_magic()z&get_ipython().kernel._load_wurlitzer())g      @g      @H   
   g      ?white)figure.figsize
figure.dpiz	font.sizezfigure.subplot.bottomzfigure.facecolorzfigure.edgecolor
matplotlibSPY_PYLAB_OSPY_BACKEND_OinlineSPY_FORMAT_OSPY_RESOLUTION_Or4   SPY_WIDTH_OSPY_HEIGHT_Or3   SPY_BBOX_INCHES_Otightbbox_inchesSPY_AUTOLOAD_PYLAB_Oz1get_ipython().kernel._set_mpl_backend('{0}', {1})SPY_RUN_CYTHONCythonz%reload_ext CythonSPY_USE_FILE_OSPY_RUN_FILE_OSPY_AUTOCALL_Or   SPY_GREEDY_OSPY_SYMPY_Osympy),IPython.core.applicationr#   traitlets.config.loaderr$   r%   r   r   osenvirongetHistoryAccessorenabledInteractiveShellxmodePY2IPCompleteruse_jediIPKernelApp
exec_linesappendr   version_infosplitstripInlineBackendrcr   r   r   figure_formatfloatprint_figure_kwargsupdater   existsfile_to_runintZMQInteractiveShellautocallbanner1greedyr    capture_fd_output_merge)r#   r$   r%   profile_pathcfgspy_cfgtestingjedi_o
clear_argvrun_lines_oxr   pylab_o	backend_oformat_oformatsresolution_owidth_oheight_obbox_inches_or?   autoload_pylab_ocommand
run_cython
use_file_o
run_file_o
autocall_ogreedy_osympy_or   s                                 r   kernel_configr   I   s   8Cxx 13DE!#6#=#?".0 hG jjnn]+v5G*/' &-G" ZZ^^L)V3F'-$ 8J&0\G" &&--8	
 !&&&--	
 **..!23K&& + 1 1# 671QWWY7	
&
 ""))79 ""))02 % !%## G K<(**../JJNN?3	f!629=Kh&::>>.9/':A(:KG))7  "zz~~.@A+=B$>&G)),,\:  

} => !?@&8+?BIBJBLG)),,-=> !#

/B C)6&)@gd%%99@@"K02
 #K ::>>*@AVKE&&--NN;(89	;  01V;J)(3&&--.BC  01J 01JV
 6::j!.8G+  01J/2:##, +-G' zz~~n-7H!)G jjnn]+v5G&w/[)&&--e4 05- JJwJIhb 8s   &W  W	Wc                    t               }| j                         \  }}	 ddlm} |j                           t        ||dd       |j                  j                         |          |j                          y#  ddlm} Y [xY w)z
    Spyder's variable explorer magic

    Used to generate plots, histograms and images of the variables displayed
    on it.
    r   Nr+   )
get_ipythonrY   guiqwt.pyplotpyplotmatplotlib.pyplotfiguregetattrkernel_get_current_namespaceshow)lineipfuncnamenamer   s        r   varexpr      si     
BZZ\NHd+& MMO!GFHQRL!"))"B"B"DT"JK
KKM	+*s   A6 6B c                     	 t         j                  j                  t        j                  t
                     	 t               j                  d       d} d}t                dt         j                  v r2t         j                  j                  d       dt         j                  v r2ddlm} ddlm}  G d d|      }|j                         }||_        	 t#               |_        |j'                          |j(                  j+                  t,               dd l}|j0                  |j(                  j2                  _        |j7                          y # t        $ r Y w xY w# t        $ r Y w xY w#  Y xY w)	Nr   r   __main__r   )rU   )SpyderKernelc                   &    e Zd Zer ed      Zd Zy)main.<locals>.SpyderKernelAppz-spyder_kernels.console.outstream.TTYOutStreamc                      y)a  
            This method was added in IPykernel 5.3.1 and it replaces
            the debugger used by the kernel with a new class
            introduced in IPython 7.15 during kernel's initialization.
            Therefore, it doesn't allow us to use our debugger.
            N )selfs    r   init_pdbz&main.<locals>.SpyderKernelApp.init_pdb/  s     r!   N)__name__
__module____qualname__IPYKERNEL_6r   outstream_classr   r   r!   r   SpyderKernelAppr   )  s    .?AO	r!   r   )r   r   r   r   r   r   r   localspopKeyErrorr   ipykernel.kernelapprU   spyder_kernels.console.kernelr   instancekernel_classr   config
initializeshellregister_magic_functionr   pdbPdbInteractiveTBdebugger_clsstart)__doc__r   rU   r   r   r   r   s          r   mainr     s%   H-.Z  GH  . . 0:+   %%'F&F%  LL((0
 .1ggFLL+ LLNu  
  Ns.   6E E E+ 	EE	E('E(+E/r   )r   rK   os.pathr   r   r   r   	traitletsr   	ipykernelspyder_kernels.utils.miscr   spyder_kernels.utils.mplr   r   versionrR   __version__r   r   r    r   r   r   r   r   r!   r   <module>r      s   
 
  
  &  :5 
kk!n##A&#-0"od$>B zF r!   