ó
c’?[c           @  s”  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z m Z d d l	 m
 Z
 m Z d d l m Z m Z m Z m Z d d l m Z m Z m Z d d l m Z d d	 l m Z d
 Z e e ƒ Z e e ƒ Z e j e ƒ e j e d d d d ƒ ƒ e e ƒ Z e e ƒ Z e j e ƒ e  e j! ƒ  ƒ Z e  e j! ƒ  ƒ Z d e e f d „  ƒ  YZ" e" j# Z$ Z% e& d k re$ ƒ  n  d S(   sØ    A minimal application using the ZMQ-based terminal IPython frontend.

This is not a complete console app, as subprocess will not be able to receive
input, there is no real readline support, among other limitations.
iÿÿÿÿ(   t   print_functionN(   t   Dictt   Any(   t   catch_config_errort   boolean_flag(   t
   JupyterAppt   base_aliasest
   base_flagst   NoStart(   t   JupyterConsoleAppt   app_aliasest	   app_flags(   t   ZMQTerminalInteractiveShell(   t   __version__ss   
jupyter console # start the ZMQ-based console
jupyter console --existing # connect to an existing ipython session
s   simple-prompts)   ZMQTerminalInteractiveShell.simple_prompts-   Force simple minimal prompt using `raw_input`s1   Use a rich interactive prompt with prompt_toolkitt   ZMQTerminalIPythonAppc           B  sº   e  Z d  Z e Z d Z e Z e g e	 j
 Z
 e e ƒ Z e e ƒ Z e e ƒ Z e e ƒ Z e ƒ  Z e Z d	 d „ Z d „  Z d „  Z d „  Z e d	 d „ ƒ Z d „  Z d „  Z RS(
   s   jupyter-consolesî  
        The Jupyter terminal-based Console.

        This launches a Console application inside a terminal.

        The Console supports various extra features beyond the traditional
        single-process Terminal IPython shell, such as connecting to an
        existing ipython session, via:

            jupyter console --existing

        where the previous session could have been created by another ipython
        console, an ipython qtconsole, or by opening an ipython notebook.

    c         C  s*   t  t |  ƒ j | ƒ |  j |  j ƒ d  S(   N(   t   superR   t   parse_command_linet   build_kernel_argvt
   extra_args(   t   selft   argv(    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyR   h   s    c         C  s^   t  j |  ƒ t j t j |  j ƒ t j d |  d |  j d |  j ƒ |  _	 |  j
 |  j	 _ d  S(   Nt   parentt   managert   client(   R	   t
   initializet   signalt   SIGINTt   handle_sigintR   t   instancet   kernel_managert   kernel_clientt   shellt   existingt
   own_kernel(   R   (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyt
   init_shelll   s    	c         C  s   d  S(   N(    (   R   (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyt   init_gui_pylabv   s    c         G  sE   |  j  j r; |  j r% |  j j ƒ  qA t d d t j ƒn t ‚ d  S(   Ns0   ERROR: Cannot interrupt kernels we didn't start.t   file(   R   t
   _executingR   t   interrupt_kernelt   printt   syst   stderrt   KeyboardInterrupt(   R   t   args(    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyR   z   s    		c         C  s;   t  t |  ƒ j | ƒ |  j r# d S|  j ƒ  |  j ƒ  d S(   s8   Do actions after construct, but before starting the app.N(   R   R   R   t   _dispatchingR"   t   init_banner(   R   R   (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyR   †   s
    	
c         C  s-   |  j  j ƒ  |  j t j k r) t ƒ  n  d S(   s   optionally display the bannerN(   R   t   show_bannert	   log_levelt   loggingt   INFOR'   (   R   (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyR-   ‘   s     c         C  s4   t  t |  ƒ j ƒ  |  j j d ƒ |  j j ƒ  d  S(   Ns(   Starting the jupyter console mainloop...(   R   R   t   startt   logt   debugR   t   mainloop(   R   (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyR2   —   s    N(   t   __name__t
   __module__t   nameR   t   versiont   descriptiont	   _examplest   examplesR   R	   t   classesR   t   flagst   aliasesR   t   frontend_aliasest   frontend_flagst   subcommandst   Truet   force_interactt   NoneR   R"   R#   R   R   R   R-   R2   (    (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyR   H   s&   		
		
	t   __main__('   t   __doc__t
   __future__R    R0   R   R(   t	   traitletsR   R   t   traitlets.configR   R   t   jupyter_core.applicationR   R   R   R   t   jupyter_client.consoleappR	   R
   R   t   jupyter_console.ptshellR   t   jupyter_consoleR   R;   t   dictR>   RA   t   updateR?   R@   t   sett   keysR   t   launch_instancet   maint   launch_new_instanceR6   (    (    (    s2   lib/python2.7/site-packages/jupyter_console/app.pyt   <module>   s6   "		
V