m
fIc           @   s  d  k  Z  d  k Z  d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d  k	 Z	 d  k
 Z
 d  k Z d  k Z d k l Z y d k TWn- e j
 o! e i d IJe i d  n Xd  k Z d k l Z l Z d k l Z d k l Z d k l Z d	 k l Z d
 k l Z d  k Z d  k Z d  k Z d  k Z e i  e i! d Z" d Z# y d k$ l% Z% Wn e j
 o d Z% n Xe i a& y d  k' Z' Wn e j
 o n& Xd   Z( e( e' _) d   Z* e* e' _+ e, e i- d  Z. e. e _- d e f d     YZ/ d e f d     YZ0 d e f d     YZ1 d e f d     YZ2 d e i3 f d     YZ4 d e f d     YZ5 d e f d     YZ6 d  f  d!     YZ7 d" Z8 d#   Z9 e: d$ j o e i; d$ e i; d <e9   n d  S(%   N(   s   InteractiveInterpreter(   t   *sK   ** IDLE can't import Tkinter.  Your Python may not be configured for Tk. **i   (   s   EditorWindows   fixwordbreaks(   s   FileList(   s   ColorDelegator(   s   UndoDelegator(   s   OutputWindow(   s   idleConft   _s	   127.0.0.1(   s   SIGTERMi   c         C   sC   t  } y# | i t i |  | | |   Wn t	 j
 o n Xd  S(   N(
   t   warning_streamt   filet   writet   warningst   formatwarningt   messaget   categoryt   filenamet   linenot   IOError(   R   R   R	   R
   R   (    (    t,   /mit/python/lib/python2.4/idlelib/PyShell.pyt   idle_showwarning:   s
    #c         C   sf   d } | d | | f 7} t i | |  i   } | o | d | 7} n | d | i |  f 7} | S(   s   Format warnings the IDLE ways!   
Warning (from warnings module):
s     File "%s", line %s
s       %s
s   %s: %s
>>> N(
   t   sR	   R
   t	   linecachet   getlinet   stript   lineR   t   __name__R   (   R   R   R	   R
   R   R   (    (    R   t   idle_formatwarningA   s     c         C   si   t  i } h  } x? | i   D]1 }  |  d  |  d d j o | |  | |  <q q W|   | i |  d S(   sv  Extend linecache.checkcache to preserve the <pyshell#...> entries

    Rather than repeating the linecache code, patch it to save the
    <pyshell#...> entries, call the original linecache.checkcache()
    (which destroys them), and then restore the saved entries.

    orig_checkcache is bound at definition time to the original
    method, allowing it to be patched.

    i   is   <>N(   R   t   cachet   savet   keysR	   t   orig_checkcachet   update(   R	   R   R   R   (    (    R   t   extended_linecache_checkcacheL   s     	 t   PyShellEditorWindowc           B   sz   t  Z d  Z d   Z d d g Z d   Z e d  Z e d  Z d	   Z	 d
   Z
 d   Z d   Z d   Z d   Z RS(   s6   Regular text edit window in IDLE, supports breakpointsc         G   s   g  |  _ t i |  |  |  i i d |  i  |  i i d |  i  |  i i d |  i	 i
  t i i t i   d  |  _ |  i i o |  i   n |  i i |  d  } |  i i |  d  S(   Ns   <<set-breakpoint-here>>s   <<clear-breakpoint-here>>s   <<open-python-shell>>s   breakpoints.lstc         C   s   | i   |    d  S(   N(   t   selft   restore_file_breakst   old_hook(   R   R   (    (    R   t   filename_changed_hookr   s    
(   R   t   breakpointst   EditorWindowt   __init__t   argst   textt   bindt   set_breakpoint_heret   clear_breakpoint_heret   flistt
   open_shellt   ost   patht   joint   idleConft   GetUserCfgDirt   breakpointPatht   ioR	   R   t   filename_change_hookR   t   set_filename_change_hook(   R   R#   R   (    (    R   R"   g   s    	 s   Set Breakpoints   <<set-breakpoint-here>>s   Clear Breakpoints   <<clear-breakpoint-here>>c         C   s   |  i } |  i i } | i d d | d | d  y |  i i |  } Wn# t	 j
 o |  i i
 |  n Xy& |  i i i i } | i | |  Wn n Xd  S(   Nt   BREAKs   %d.0i   (   R   R$   R0   R	   t   tag_addR
   R    t   indext   it
   ValueErrort   appendR(   t   pyshellt   interpt   debuggert   debugR&   (   R   R
   R6   R$   R	   R<   (    (    R   t   set_breakpoint{   s    	c         C   sZ   |  i } |  i i } | p | i   d  Sn t t | i d    } |  i	 |  d  S(   Nt   insert(
   R   R$   R0   R	   t   bellt   intt   floatR5   R
   R=   (   R   t   eventR$   R	   R
   (    (    R   R&      s    	
c         C   s   |  i } |  i i } | p | i   d  Sn t t | i d    } y |  i	 i
 |  Wn n X| i d d d  y& |  i i i i } | i | |  Wn n Xd  S(   NR>   R3   s   insert linestarts   insert lineend +1char(   R   R$   R0   R	   R?   R@   RA   R5   R
   R    t   removet
   tag_removeR(   R9   R:   R;   R<   R'   (   R   RB   R$   R	   R
   R<   (    (    R   R'      s"    	
c         C   s   |  i o{ |  i } |  i i } | p | i   d  Sn g  |  _ | i d d t  y# |  i i	 i
 i } | i |  Wq q Xn d  S(   NR3   s   1.0(   R   R    R$   R0   R	   R?   RD   t   ENDR(   R9   R:   R;   R<   t   clear_file_breaks(   R   R<   R$   R	   (    (    R   RF      s    
	
	c         C   s   |  i } |  i i } y t |  i d  i   } Wn t	 j
 o g  } n Xt |  i d  } x3 | D]+ } | i | d  p | i |  qf qf W|  i   |  i } | o# | i | d t |  d  n | i   d S(   s#   Save breakpoints when file is savedt   rt   wt   =s   
N(   R   R    t   breaksR0   R	   t   openR/   t	   readlinest   linesR   t   new_fileR   t
   startswithR   t   update_breakpointst   strt   close(   R   RN   RM   R	   R   RJ   (    (    R   t   store_file_breaks   s"     	 
	#c         C   s   |  i i   |  i i } | d  j o d  Sn t i i |  i	  o} t
 |  i	 d  i   } xb | D]V } | i | d  o< t | t |  d  } x | D] } |  i |  q Wqc qc Wn d  S(   NRG   RI   i   (   R   R$   R   R0   R	   t   NoneR*   R+   t   isfileR/   RK   RL   RM   R   RO   t   evalt   lent   breakpoint_linenumberst   breakpoint_linenumberR=   (   R   RY   RM   R	   R   RX   (    (    R   R      s      c         C   s4   |  i } | i d  } |  i |  } | |  _ d S(   s3   Retrieves all the breakpoints in the current windowR3   N(   R   R$   t
   tag_rangest   rangest   ranges_to_linenumberst   linenumber_listR    (   R   R[   R$   R]   (    (    R   RP      s
     	c         C   s   g  } x| t d t |  d  D]b } t t | |   } t t | | d   } x) | | j  o | i	 |  | d 7} qX Wq W| S(   Ni    i   i   (
   RM   t   rangeRW   R[   R5   R@   RA   R
   t   endR8   (   R   R[   R5   R_   RM   R
   (    (    R   R\      s      c         C   s   |  i   t i |   d S(   s7   Extend base method - clear breaks when module is closedN(   R   RF   R!   t   _close(   R   (    (    R   R`      s     
(   s   Set Breakpoints   <<set-breakpoint-here>>(   s   Clear Breakpoints   <<clear-breakpoint-here>>(   R   t
   __module__t   __doc__R"   t   rmenu_specsR=   RT   R&   R'   RF   RS   R   RP   R\   R`   (    (    (    R   R   d   s    					'			t   PyShellFileListc           B   s&   t  Z d  Z e Z e Z e d  Z RS(   s8   Extend base class: IDLE supports a shell and breakpointsc         C   sZ   |  i o |  i i i   n6 t |   |  _ |  i o |  i i   p d  SqS n |  i S(   N(   R   R9   t   topt   wakeupt   PyShellt   beginRT   (   R   RB   (    (    R   R)     s    

(   R   Ra   Rb   R   R!   RT   R9   R)   (    (    (    R   Rd     s    t   ModifiedColorDelegatorc           B   s)   t  Z d  Z d   Z d   Z d   Z RS(   s8   Extend base class: colorizer for the shell window itselfc         C   s   t  i |   |  i   d  S(   N(   t   ColorDelegatorR"   R   t   LoadTagDefs(   R   (    (    R   R"     s    c         C   s7   |  i d d d  |  i d d d  t i |   d  S(   Nt   TODOs   1.0t   iomarkt   SYNC(   R   RD   R4   Rj   t   recolorize_main(   R   (    (    R   Ro   !  s    c         C   s   t  i |   t i d d d  } |  i i h  d h  d d  <d d  <<d t i	 | d  <d t i	 | d  <d	 t i	 | d	  <d  t i	 | d
  < d  S(   Nt   maint   Themet   namet   stdint
   backgroundt
   foregroundt   stdoutt   stderrt   consolet   normal(
   Rj   Rk   R   R-   t	   GetOptiont   themet   tagdefsR   RT   t   GetHighlight(   R   R{   (    (    R   Rk   &  s    (   R   Ra   Rb   R"   Ro   Rk   (    (    (    R   Ri     s    		t   ModifiedUndoDelegatorc           B   s&   t  Z d  Z e d  Z e d  Z RS(   s;   Extend base class: forbid insert/delete before the I/O markc         C   sb   y2 |  i i | d d  o |  i i   d  Sn Wn t j
 o n Xt i |  | | |  d  S(   Nt   <Rm   (
   R   t   delegatet   compareR5   R?   t   TclErrort   UndoDelegatorR>   t   charst   tags(   R   R5   R   R   (    (    R   R>   4  s    c         C   s_   y2 |  i i | d d  o |  i i   d  Sn Wn t j
 o n Xt i |  | |  d  S(   NR   Rm   (	   R   R   R   t   index1R?   R   R   t   deletet   index2(   R   R   R   (    (    R   R   =  s    (   R   Ra   Rb   RT   R>   R   (    (    (    R   R~   1  s    	t   MyRPCClientc           B   s   t  Z d   Z RS(   Nc         C   s
   t   d S(   s0   Override the base class - just re-raise EOFErrorN(   t   EOFError(   R   (    (    R   t
   handle_EOFI  s     (   R   Ra   R   (    (    (    R   R   G  s   t   ModifiedInterpreterc           B   s@  t  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 d  d  Z d   Z d   Z d   Z d  d  Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d   Z% d    Z& RS(!   Nc         C   sQ   | |  _  t i d i } t i |  d | d  |  _	 t
 |  _ |  i   |  _ d  S(   Nt   __main__t   locals(   t	   tkconsoleR   t   syst   modulest   __dict__R   t   InteractiveInterpreterR"   RT   t   save_warnings_filterst   Falset
   restartingt   build_subprocess_arglistt   subprocess_arglist(   R   R   R   (    (    R   R"   P  s    			i"  c         C   s+   |  i } t i t i t i |  |  _ d  S(   N(	   R   R   R#   R*   t   spawnvt   P_NOWAITR   t
   executablet   rpcpid(   R   R#   (    (    R   t   spawn_subprocess\  s    	c         C   s   g  } t i D] } | d | q ~ } t i d d d d t d d } t	 d j o d	 | f } n d
 | f } t i d  d j o! d t i j o d t i } n
 t i } | g | d | t |  i  g S(   Ns   -WRp   t   Generals   delete-exitfunct   defaultt   typet   bools   idlelib.PyShells&   __import__('idlelib.run').run.main(%r)s   __import__('run').main(%r)i   t   wint    s   "%s"s   -c(   t   _[1]R   t   warnoptionsR   RH   R-   Rz   R   t	   del_exitfR   t   commandt   platformR   t   decorated_execRQ   R   t   port(   R   R   R   R   RH   R   R   (    (    R   R   `  s    ($	c         C   si  |  i   t |  i f } x^ t d  D]B } t i |  y t	 |  |  _
 PWq& t i j
 o	 } q& Xq& W|  i   d  S|  i
 i i d  y |  i
 i   Wn& t i j
 o } |  i   d  Sn X|  i
 i d |  i  |  i
 i d |  i i  |  i
 i d |  i i  |  i
 i d |  i i  |  i
 i d t  |  i
 i d |   |  i   |  i   |  i
 S(	   Ni   i
   Rs   Rv   Rw   R(   R   R:   (   R   R   t	   LOCALHOSTR   t   addrR^   R6   t   timet   sleepR   t   rpccltt   sockett   errort   errt   display_port_binding_errorRT   t   listening_sockt
   settimeoutt   acceptt   timeoutt   display_no_subprocess_errort   registerR   Rv   Rw   R(   R   t   transfer_patht   poll_subprocess(   R   R   R   R6   (    (    R   t   start_subprocessr  s6    
 	

	

c         C   s  |  i o |  i Sn t |  _ |  i   } | o" y t i |  i  WqS qS Xn |  i i   |  i	   |  i
 } | i } t | _ |  i   y |  i i   Wn& t i j
 o } |  i   d  Sn X|  i   | i i d d  | o | i d  | i   n t | i  d d d } | i | d |  | i i d d  | i i d d	  | i   | o  t i  |  i  } | i"   n t |  _ |  i S(
   NRm   s   end-1cs   
i   i   RI   s	    RESTART t   restartt   left(#   R   R   R   t   Truet   getdebuggerR<   t   RemoteDebuggert   close_subprocess_debuggerRR   t   unix_terminateR   Rx   t	   executingt   was_executingR   R   R   R   R   R   R   RT   R   R$   R   R   t
   showpromptR@   t   widtht   halfbart   mark_sett   mark_gravityt   restart_subprocess_debuggert   guit   load_breakpoints(   R   Rx   R   R   R<   R   R   (    (    R   t   restart_subprocess  sF    
	
			

	

	c         C   s   |  i i d d f  h   d  S(   Nt   exect   interrupt_the_server(   R   R   t
   remotecall(   R   (    (    R   t   __request_interrupt  s    c         C   s   t  i d |  i  i   d  S(   Nt   target(   t	   threadingt   ThreadR   t'   _ModifiedInterpreter__request_interruptt   start(   R   (    (    R   t   interrupt_subprocess  s    c         C   sJ   y |  i i   Wn t j
 o n X|  i   t |  i _ d  |  _ d  S(   N(	   R   R   RR   t   AttributeErrorR   R   R   R   RT   (   R   (    (    R   t   kill_subprocess  s    
c         C   sz   t  t d  of y t i |  i t  Wn t j
 o d Sqv Xy t i |  i d  Wqv t j
 o d Sqv Xn d S(   s;   UNIX: make sure subprocess is terminated and collect statust   killNi    (   t   hasattrR*   R   R   R   t   SIGTERMt   OSErrort   waitpid(   R   (    (    R   R     s     	c         C   s   |  i d t i f  d  S(   Ns   if 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        _msg = 'Use File/Exit or your end-of-file key to quit IDLE'
        __builtins__.quit = __builtins__.exit = _msg
        del _msg
        
(   R   t
   runcommandR   R+   (   R   (    (    R   R     s    c         C   s  |  i } | d  j o d  Sn y | i |  i d d } WnA t t t	 f j
 o, |  i
 i o d  Sn d  } |  i   n X| o |  i
 i   d  |  _ | \ } } |  i
 i } | d j o% | d  j	 o | t |  IJqQnm | d j o% |  i
 i d  o |  i   qQn; | d j o- d } t i | I| IJ| | I| IJn |  i
 i   n |  i
 i p# |  i
 i i |  i
 i |  i  n d  S(   Nt   waitf0.050000000000000003t   OKt	   EXCEPTIONs   <<toggle-jit-stack-viewer>>t   ERRORs/   PyShell.ModifiedInterpreter: Subprocess ERROR:
(   R   R   t   cltRT   t   pollresponset
   active_seqt   responseR   R   t   KeyboardInterruptR   t   closingR   t   resetoutputt   howt   whatRx   t   reprt   getvart   remote_stack_viewert   errmsgR   t
   __stderr__t   endexecutingR$   t   aftert   pollintervalR   (   R   R   Rx   R   R   R   R   (    (    R   R     s:    		c         C   s   | |  _  d  S(   N(   R;   R   (   R   R;   (    (    R   t   setdebugger  s    c         C   s   |  i S(   N(   R   R;   (   R   (    (    R   R     s    c         C   s   |  i i i d |  i  d S(   s  Initiate the remote stack viewer from a separate thread.

        This method is called from the subprocess, and by returning from this
        method we allow the subprocess to unblock.  After a bit the shell
        requests the subprocess to open the remote stack viewer which returns a
        static object looking at the last exceptiopn.  It is queried through
        the RPC mechanism.

        i,  N(   R   R   R$   R   R   (   R   (    (    R   t   open_remote_stack_viewer  s    	 c         C   s  d  k  } |  i i d d d h   } | d  j o |  i i i   d  Sn | i	 |  i |  } d k l } l } t |  i i  }
 t i d d d  } t i | d  d	 } | |
 d
 | d d }	 |	 i i d d d d  | |	 i d  |  } | i   d  S(   NR   t   stackviewerR(   (   s   ScrolledCanvass   TreeNodeRp   Rq   Rr   Ry   Rt   t   bgt   highlightthicknessi    t   expandi   t   fillt   both(   s   flist(   t   RemoteObjectBrowserR   R   t   remotequeuet   oidRT   R   t   rootR?   t   StubObjectTreeItemt   itemt
   TreeWidgett   ScrolledCanvast   TreeNodet   ToplevelRe   R-   Rz   R{   R}   Rt   t   sct   framet   packt   canvast   nodeR   (   R   R  R  R  Rt   R   R  R{   R   R  Re   (    (    R   R      s    	i    c         C   s#   |  i |  } |  i | |  d S(   s1   Like runsource() but assumes complete exec sourceN(   R   t   stuffsourcet   sourceR	   t   execfile(   R   R  R	   (    (    R   t
   execsource3  s     c         C   s   | d j o t | d  i   } n y t | | d  } Wnc t t f j
 oQ |  i
 i   |  i
 i } | d IJ| d IJt i |  |  |  i
 i   n X|  i |  d S(   s   Execute an existing fileRG   R   s    *** Error in script or command!
s"   Traceback (most recent call last):N(   R  RT   RK   R	   t   readt   compilet   codet   OverflowErrort   SyntaxErrorR   R   R   Rw   t   tkerrR   t   showsyntaxerrorR   t   runcode(   R   R	   R  R  R  (    (    R   R  8  s     

c         C   s   |  i |  } d |  _ t i |  _ t i d d d t	  t
 | t i  oW d k } y | i | i  } Wq t j
 o% |  i i   |  i d  d Sq Xn z t i |  | |  SWd |  i d j	 o |  i t i (d |  _ n Xd S(   sB   Extend base class method: Stuff the source in the line cache firsti    t   actionR   R   Ns   Unsupported characters in input(   R   R  R  R	   t   moreR   t   filtersR   t   filterwarningst   SyntaxWarningt
   isinstancet   typest   UnicodeTypet	   IOBindingt   encodet   encodingt   UnicodeErrorR   R   R   R   t	   runsourceRT   (   R   R  R	   R!  (    (    R   R%  H  s&     		 c         C   sS   d |  i } |  i d |  _ | i d  } t |  d d | | f t i | <| S(   s"   Stuff source in the filename caches   <pyshell#%d>i   s   
i    N(	   R   t   gidR	   R  t   splitRM   RW   R   R   (   R   R  RM   R	   (    (    R   R  ]  s     #c         C   s   |  i d | f  d S(   s>   Prepend sys.path with file's directory if not already includeds(  if 1:
            _filename = %r
            import sys as _sys
            from os.path import dirname as _dirname
            _dir = _dirname(_filename)
            if not _dir in _sys.path:
                _sys.path.insert(0, _dir)
            del _filename, _sys, _dirname, _dir
            
N(   R   R   R	   (   R   R	   (    (    R   t   prepend_syspathe  s     c   
      C   s  |  i i } |  i   } | o | \ } } } }	 | d j o d | d } n d | d | d f } | i
 d |  | i |  | i |  } | o( | t j o | i
 d | d |  n |  i i   |  i d t |   n |  i i   t i |  |  |  i i   d S(   s   Extend base class method: Add Colorizing

        Color the offending position instead of printing it and pointing at it
        with a caret.

        i   s   iomark + %d charss&   iomark linestart + %d lines + %d charsR   s
    wordstarts   SyntaxError: %s
N(   R   R   R$   t   unpackerrort   stufft   msgR
   t   offsetR   t   posR4   t   seet   gett   chart
   IDENTCHARSR   R   RQ   R   R  R	   R   (
   R   R	   R$   R-  R0  R*  R
   R,  R+  R   (    (    R   R  q  s$     c   
      C   s   t  i   \ } } }	 | t j } | oA y- | \ } \ } } } } | p
 d } n Wqi d } qi Xn | o | | | | f Sn d  Sd  S(   Ni    (   R   t   exc_infoR   t   valuet   tbR  t   okR+  t   dummy_filenameR
   R,  R   RT   (
   R   R5  R   R   R3  R
   R,  R+  R6  R4  (    (    R   R)    s    c         C   sL   |  i i   |  i   t i |   |  i i d  o |  i i   n d S(   s1   Extend base class method to reset output properlys   <<toggle-jit-stack-viewer>>N(   R   R   R   t   checklinecacheR   t   showtracebackR   t   open_stack_viewer(   R   (    (    R   R8    s     
c         C   sH   t  i } x8 | i   D]* } | d  | d d j o | | =q q Wd  S(   Ni   is   <>(   R   R   t   cR   t   key(   R   R:  R;  (    (    R   R7    s
    	 c         B   sX   |  i i o |  i   d Sn |  i o  |  i i d d | f h   n | |  i Ud S(   s*   Run the code without invoking the debuggeri    R   R  i   N(   R   R   R   t   display_executing_dialogR   R   R  R   (   R   R  (    (    R   R     s     

 c         B   sR  |  i i o |  i i   n |  i   |  i d j	 o |  i e i	 (d |  _ n |  i
 } z |  i i   yj | o5 |  i d j	 o% |  i i d d | f h   |  _ n* | o | i | |  i  n | |  i UWnY e j
 o= e i d d d d d |  i i o   q1|  i   n |  i   n XWd e p |  i i   n Xd S(	   s   Override base class methodR   R  s   Exit?s   Do you want to exit altogether?R   t   yest   masterN(   R   R   R   R:   R   R7  R   RT   R   R  R;   t   beginexecutingR   t
   asyncqueueR  R   t   runR   t
   SystemExitt   tkMessageBoxt   askyesnoR$   R8  t   use_subprocessR   (   R   R  R;   (    (    R   R    s:     
		 c         C   s   |  i i i |  d S(   s   Override base class methodN(   R   R   Rw   R   R   (   R   R   (    (    R   R     s     c         C   s    t  i d d d |  i i d  S(   Ns   Port Binding Errorsg  IDLE can't bind TCP/IP port 8833, which is necessary to communicate with its Python execution server.  Either no networking is installed on this computer or another process (another IDLE?) is using the port.  Run IDLE with the -n command line switch to start without a subprocess and refer to Help/IDLE Help 'Running without a subprocess' for further details.R>  (   RC  t	   showerrorR   R   R$   (   R   (    (    R   R     s    	c         C   s    t  i d d d |  i i d  S(   Ns   Subprocess Startup Errors   IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.R>  (   RC  RF  R   R   R$   (   R   (    (    R   R     s    	c         C   s    t  i d d d |  i i d  S(   Ns   Already executingsY   The Python Shell window is already executing a command; please wait until it is finished.R>  (   RC  RF  R   R   R$   (   R   (    (    R   R<    s    	('   R   Ra   R"   R   RT   R   R   R   R   R   R   R   R   R   R   R   R   R   R;   R   R   R   R   R&  R  R  R%  R  R(  R  R)  R8  R7  R   R  R   R   R   R<  (    (    (    R   R   N  sH   				!	,						
	#													"			Rg   c           B   s  t  Z d Z e Z e Z d1 d2 d3 d4 d5 d6 g Z d k l	 Z	 d  d  Z d   Z e Z e Z e Z e Z e Z d   Z d   Z d  d  Z d   Z d  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  d$  Z& d%   Z' d&   Z( d'   Z) d(   Z* d)   Z+ d*   Z, d  d+  Z- d  d,  Z. d  d-  Z/ d.   Z0 d/   Z1 f  d0  Z2 RS(7   Ns   Python ShellR   t   _Filet   editt   _EditR<   t   _Debugt   optionst   _Optionst   windowst   _Windowst   helpt   _Help(   s   Historyc         C   sv  t  o6 |  i } | d d d j o | i d d  q= n t |   |  _ | d  j o- t	   } t |  | i   t |  } n t i |  | d  d   d  k } d | _ | _ |  i d d d d	 d
 d  |  i } | i d d  | i d |  i  | i d |  i  | i d |  i  | i d |  i  | i d |  i  | i d |  i  | i d |  i  | i d |  i  t  o* | i d |  i  | i d |  i   n t! i" |  _# t! i$ |  _% t! i& |  _' d  k( } t) |  d | i*  |  _" t) |  d | i*  |  _$ t) |  d | i*  |  _+ t  p% |  i" t! _" |  i$ t! _$ |  t! _& n |  i, |  i  |  _- d |  _. d  S(   Ni   i    t   shellt   _Shells   To exit, type Ctrl-D.t   usetabsi   t   indentwidthi   t   context_use_ps1t   wrapR0  s   <<newline-and-indent>>s   <<plain-newline-and-indent>>s   <<interrupt-execution>>s   <<beginning-of-line>>s   <<end-of-file>>s   <<open-stack-viewer>>s   <<toggle-debugger>>s   <<toggle-jit-stack-viewer>>s   <<view-restart>>s   <<restart-shell>>Rv   Rw   Rx   i2   (   s   shellRR  (/   RE  R   t
   menu_specst   msR>   R   R:   R(   RT   t   TkR  t   fixwordbreakst   withdrawRd   t   OutputWindowR"   t   __builtin__t   quitt   exitt   configR$   t	   configureR%   t   enter_callbackt   linefeed_callbackt   cancel_callbackt   home_callbackt   eof_callbackR9  t   toggle_debuggert   toggle_jit_stack_viewert   view_restart_markt   restart_shellR   Rv   t   save_stdoutRw   t   save_stderrRs   t
   save_stdinR!  t
   PseudoFileR#  Rx   t   Historyt   historyR   (   R   R(   R$   R]  RX  R  R!  (    (    R   R"     sP    		

			c         C   s   t  i d t  S(   Nt
   shell_only(   R-   t   GetExtensionsR   (   R   (    (    R   t   get_standard_extension_names>  s    c         C   s
   | a d  S(   N(   t   streamR   (   R   Rt  (    (    R   t   set_warning_streamG  s     c         C   s   t  S(   N(   R   (   R   (    (    R   t   get_warning_streamK  s    c         C   sg   |  i o+ t i d d d |  i |  i   d Sn/ |  i i   } | o |  i	   n |  i
   d  S(   Ns   Don't debug nows*   You can only toggle the debugger when idleR>  t   break(   R   R   RC  RF  R$   t   set_debugger_indicatorR:   R   t   dbt   close_debuggert   open_debugger(   R   RB   Ry  (    (    R   Rg  N  s    
	
c         C   s%   |  i i   } |  i d |  d  S(   Ns   <<toggle-debugger>>(   R   R:   R   Ry  t   setvar(   R   Ry  (    (    R   Rx  \  s    c         C   s   d  S(   N(    (   R   RB   (    (    R   Rh  `  s    c         C   s   |  i i   } | oo |  i i d   | i   |  i i o t i	 |  i i  n |  i
   |  i i d  d t _ |  i   n |  i   d  S(   Ns   [DEBUG OFF]
s   >>> (   R   R:   R   Ry  R   RT   RR   R   R   t   close_remote_debuggerR   Rx   R   R   t   ps1R   Rx  (   R   Ry  (    (    R   Rz  c  s    

	c         C   ss   |  i i o t i |  i i |   } n t i |   } |  i i |  | i   d t	 _
 |  i   |  i   d  S(   Ns   [DEBUG ON]
>>> (   R   R:   R   R   t   start_remote_debuggert   dbg_guit   DebuggerR   R   R   R~  R   Rx  (   R   R  (    (    R   R{  p  s    
	
c         C   s   |  i   d |  _ d S(   s   Helper for ModifiedInterpreteri   N(   R   R   R   (   R   (    (    R   R?  |  s     
c         C   s    d |  _ d |  _ |  i   d S(   s   Helper for ModifiedInterpreteri    N(   R   R   t   canceledR   (   R   (    (    R   R     s     		c         C   s   |  i o: t i d d d d d |  i } | t j o d SqD n |  i o |  i i	   n t
 |  _ t
 |  _ |  i i d |  i |  i  d S(	   s   Extend EditorWindow.close()s   Kill?s6   The program is still running!
 Do you want to kill it?R   R5  t   parentt   canceli   N(   R   R   RC  t   askokcancelR$   R   R   t   readingRe   R^  R   R  R   R   R   t   close2(   R   R   (    (    R   RR     s     
	
		c         C   s   t  i |   S(   N(   R!   RR   R   (   R   (    (    R   R    s    c         C   s~   |  i   t o |  i i   n |  i t _ |  i t _	 |  i
 t _ d |  _ d |  _ d |  i _ d |  _ t i |   d S(   sE   Extend EditorWindow._close(), shut down debugger and execution serverN(   R   Rz  RE  R:   R   Rk  R   Rv   Rl  Rw   Rm  Rs   RT   Rx   R(   R9   Rp  R!   R`   (   R   (    (    R   R`     s     
			c         C   s   t  S(   s8   Override EditorWindow method: never remove the colorizerN(   R   (   R   R	   (    (    R   t   ispythonsource  s     c         C   s   |  i S(   N(   R   t   shell_title(   R   (    (    R   t   short_title  s    s@   Type "copyright", "credits" or "license()" for more information.s  
    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
    c         C   s   |  i   t o2 d } |  i i   } | p |  i   t SqI n d } |  i	 d t
 i t
 i |  i |  i t i | f  |  i   d  k } d  | _ t S(   Nt    s   ==== No Subprocess ====s&   Python %s on %s
%s
%s
IDLE %s      %s
(   R   R   RE  t   nosubR:   R   t   clientRR   R   R   R   t   versionR   t	   COPYRIGHTt   firewallmessaget   idlevert   IDLE_VERSIONR   t   TkinterRT   t   _default_rootR   (   R   R  R  R  (    (    R   Rh     s    

2
		c         C   s   |  i } z d |  _ |  i i   Wd  | |  _ X|  i i d d  } t |  d j o
 d } n t	 | t
  o9 d  k } y | i | i  } Wq t j
 o q Xn |  i   |  i o d |  _ t p
 t  q n |  i o d |  _ d } n | S(   Ni   Rm   s   end-1ci    s   
R  (   R   R  R   Re   t   mainloopR$   R/  R   RW   R  t   unicodeR!  R"  R#  R$  R   R  RE  R   t	   endoffile(   R   R   R   R!  (    (    R   t   readline  s0    		 

		

	
	
c         C   s   t  S(   N(   R   (   R   (    (    R   t   isatty  s    c         C   s   y% |  i i d d d  o d  Sn Wn n X|  i p |  i p, |  i   |  i i d  |  i   d Sn d |  _	 d |  _
 |  i o? |  i i o2 |  i i   o |  i i   q |  i i   n |  i o |  i i   n d S(   Ns	   sel.firsts   !=s   sel.lasts   KeyboardInterrupt
Rw  i    i   (   R   R$   R   R   R  R   R:   R   R   R  R  R   R   R   R   Re   R^  (   R   RB   (    (    R   Rd    s&    

		
c         C   s   |  i o |  i o d  Sn |  i i d d d  o |  i i d d d  p d  Sn |  i p |  i   |  i   n  d |  _ d |  _ |  i	 i
   d S(   NRm   s   ==R>   s   end-1ci    i   Rw  (   R   R   R  R$   R   R   RR   R  R  Re   R^  (   R   RB   (    (    R   Rf    s    2

		c         C   s   | i d j o | i d j o d  Sn |  i i d d d  oZ |  i i d d d  oA |  i i d d  |  i i d d d	  |  i i d  d
 Sn d  S(   Ni    t   HomeRm   s   <=R>   s   insert linestartt   sels   1.0R_   Rw  (	   RB   t   statet   keysymR   R$   R   R   RD   R.  (   R   RB   (    (    R   Re    s     2c         C   sB   |  i o' |  i i d d  |  i i d  n |  i |  d S(   NR>   s   
Rw  (   R   R  R$   R>   R.  t   newline_and_indent_eventRB   (   R   RB   (    (    R   Rc    s
    
c         C   s  |  i o |  i o d  Sn yR |  i i d d  } | o2 |  i i d d d  o |  i |  d Sqn n Wn n X|  i i d d d  o.|  i i d	 d  } | oI |  i i d d | d
  o, |  i |  i i | d | d
   d Sn |  i i
 d	 d  } | oI |  i i d d | d  o, |  i |  i i | d | d
   d Sn |  i i d d  } t i i d  d } | i |  o | t |  } n |  i |  d Sn |  i i d d d  o |  i i d d  n |  i i d d  } | o% | i   o |  i i d d  n |  i i d d d  o |  i |  d Sn |  i i d d  |  i o' |  i i d d  |  i i d  n |  i |  |  i i d	 d d  |  i i   |  i o |  i i   n |  i   d S(   Ns	   sel.firsts   sel.lasts   <=Rm   Rw  R>   R   s   iomark linestartRs   i   i    s   insert lineends   >=s   insert linestarts   
is   end-1cs   end-1c linestart(    R   R   R  R$   R/  R  R   t   recallt   tag_prevranget   prevt   tag_nextranget   nextR   R   R~  R'  t   last_line_of_promptRO   RW   R   R   R   R   R  RB   R>   R.  R4   t   update_idletasksRe   R^  t   runit(   R   RB   R  R  R  R   R   R  (    (    R   Rb  %  sX    $$$$


c         C   s"   |  i o |  i i |  n d  S(   N(   R   Rp  R  R   (   R   R   (    (    R   R  c  s    
c         C   s   |  i i d d  } t |  } x1 | d j o# | | d d j o | d } q$ W| d j o# | | d d j o | d } n x1 | d j o# | | d d j o | d } q W| |  } |  i i |  } d  S(   NRm   s   end-1ci    i   s    	s   
(	   R   R$   R/  R   RW   R6   R:   R%  R  (   R   R6   R   R  (    (    R   R  g  s     "" "
c         C   sv   |  i i o |  i i   Sn y t i Wn$ t i d d d |  i d  Sn Xd k	 l
 } | |  i |  i  } d  S(   Ns   No stack traces@   There is no stack trace yet.
(sys.last_traceback is not defined)R>  (   s   StackBrowser(   R   R:   R   R   R   t   last_tracebackRC  RF  R$   t   StackViewert   StackBrowserR  R(   t   sv(   R   RB   R  R  (    (    R   R9  u  s    	c         C   s$   |  i i d  |  i i d  d  S(   NRm   R   (   R   R$   R.  (   R   RB   (    (    R   Ri    s    c         C   s   |  i i   d  S(   N(   R   R:   R   (   R   RB   (    (    R   Rj    s    c         C   sk   |  i   y t t i  } Wn d } n X|  i i |  |  i i	 d d  |  i
   |  i i   d  S(   NR  R>   s   end-1c(   R   R   RQ   R   R~  R   Rx   R   R$   R   t   set_line_and_columnR0   t
   reset_undo(   R   R   (    (    R   R     s    


c         C   s   |  i i d d  } |  i o |  i i |  n |  i i d  d j o |  i i d d  n |  i i d d  |  i   d t	 i
 _ d  S(   NRm   s   end-1cs   end-2cs   
i    (   R   R$   R/  R  Rp  t   history_storeR>   R   R  R   Rv   t	   softspace(   R   R  (    (    R   R     s    

c         C   sv   y@ |  i i d d  t i |  | | d  |  i i d d  Wn n X|  i o d |  _ t p
 t	  qr n d  S(   NRm   t   rightR   i    (
   R   R$   R   R\  R   R   R   R  RE  R   (   R   R   R   (    (    R   R     s    
	(   s   fileRG  (   RH  RI  (   s   debugRJ  (   RK  RL  (   RM  RN  (   s   helpRP  (3   R   Ra   R  Ri   Rj   R~   R   RW  t   IdleHistoryRo  RT   R"   Rs  R   R  R   R  R  R   Ru  Rv  Rg  Rx  Rh  Rz  R{  R?  R   RR   R  R`   R  R  R  R  Rh   R  R  Rd  Rf  Re  Rc  Rb  R  R  R9  Ri  Rj  R   R   R   (    (    (    R   Rg     sX   
1																			
			>				
Rn  c           B   s8   t  Z d  d  Z d   Z d   Z d   Z d   Z RS(   Nc         C   s(   | |  _  | |  _ d |  _ | |  _ d  S(   Ni    (   RQ  R   R   R  R#  (   R   RQ  R   R#  (    (    R   R"     s    			c         C   s   |  i i | |  i  d  S(   N(   R   RQ  R   R   R   (   R   R   (    (    R   R     s    c         C   s   t  |  i |  d  S(   N(   t   mapR   R   t   l(   R   R  (    (    R   t
   writelines  s    c         C   s   d  S(   N(    (   R   (    (    R   t   flush  s    c         C   s   t  S(   N(   R   (   R   (    (    R   R    s    (   R   Ra   RT   R"   R   R  R  R  (    (    (    R   Rn    s
   			s  
USAGE: idle  [-deins] [-t title] [file]*
       idle  [-dns] [-t title] (-c cmd | -r file) [arg]*
       idle  [-dns] [-t title] - [arg]*

  -h         print this help message and exit
  -n         run IDLE without a subprocess (see Help/IDLE Help for details)

The following options will override the IDLE 'settings' configuration:

  -e         open an edit window
  -i         open a shell window

The following options imply -i and will open a shell:

  -c cmd     run the command in a shell, or
  -r file    run script from file

  -d         enable the debugger
  -s         run $IDLESTARTUP or $PYTHONSTARTUP before anything else
  -t title   set title of shell window

A default edit window will be bypassed when -c, -r, or - are used.

[arg]* are passed to the command (-c) or script (-r) in sys.argv[1:].

Examples:

idle
        Open an edit window or shell depending on IDLE's configuration.

idle foo.py foobar.py
        Edit the files, also open a shell if configured to start with shell.

idle -est "Baz" foo.py
        Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell
        window with the title "Baz".

idle -c "import sys; print sys.argv" "foo"
        Open a shell window and run the command, passing "-c" in sys.argv[0]
        and "foo" in sys.argv[1].

idle -d -s -r foo.py "Hello World"
        Open a shell window, run a startup script, enable the debugger, and
        run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in
        sys.argv[1].

echo "import sys; print sys.argv" | idle - "foobar"
        Open a shell window, run the script piped in, passing '' in sys.argv[0]
        and "foobar" in sys.argv[1].
c          C   s  t  a t } t } t } d  } d  } t }  y t
 i Wn t j
 o d t
 _ n Xy# t i t
 i d d  \ } } WnO t i j
 o@ } t
 i i d t |   t
 i i t  t
 i d  n XxB| D]:\ } }
 | d j o |
 } t  } n | d j o t  } t  } n | d j o
 t  } n | d	 j o t
 i i t  t
 i   n | d
 j o
 t  } n | d j o
 t a n | d j o: |
 } t i i |  o n d G| GHt
 i   t  } n | d j o t  }  t  } n | d j o |
 t _ t  } q q W| o* | d d j o t
 i  i!   } t  } n x= t" t# t
 i   D]& } t i i% t
 i |  t
 i | <qUW| o) | d d j o d g | d t
 _ n | o d g | t
 _ n | o | g | t
 _ n | o t  } g  } x' | D] } | i( t i i) |   qWx~ | D]? } t i i% |  } | t
 i j o t
 i i+ d |  q)q)Wn4 t i,   } | t
 i j o t
 i i+ d |  n t- i. d d d d d }	 | p |	 } | p |	 } t0 d d  a1 t2 t1  t1 i3   t4 t1  a5 | oI | p | p7 x | D] } t5 i6 |  q$W| p t5 i7   qTqXn | o t5 i8   p d  Sqxn t5 i9 } | o | i;   n |  oW t i< i= d  p t i< i= d  } | o' t i i |  o | i> i? |  qn | o | p | od | i> i@ d t
 i f  | o | i> iA |  qm| o$ | i> iB |  | i> i? |  qmn t1 iC   t1 iD   d  S(   Ns   >>> i   s   c:deihnr:st:s
   Error: %s
i   s   -cs   -ds   -es   -hs   -is   -ns   -rs   No script file: s   -ss   -ti    t   -R  Rp   R   s   editor-on-startupR   R   t	   classNamet   Idlet   IDLESTARTUPt   PYTHONSTARTUPsb   if 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
(E   R   RE  R   t   enable_shellt   enable_editR<   RT   t   cmdt   scriptt   startupR   R~  R   t   getoptt   argvt   optsR#   R   R+  Rw   R   RQ   t	   usage_msgR_  t   ot   aRv   R*   R+   RU   Rg   R  Rs   R  R^   RW   R6   t   abspatht   pathxR	   R8   t   dirnamet   dirR>   t   getcwdR-   Rz   t
   edit_startRY  R  RZ  R[  Rd   R(   RK   t   newR)   R9   RQ  R{  t   environR/  R:   R  R   R  R(  R  t   destroy(   R  R  R  R  R	   R+  RQ  R#   R  R  R  R6   R  R  R  R<   R  (    (    R   Rp     s     # 




	


	
 $  

 	%
R   (<   R*   t   os.pathR   t   stringR  t   reR   R   R   t	   tracebackR  t
   exceptionsR   R  R   R  t   ImportErrorR   R_  RC  R!   RZ  t   FileListRj   R   R\  t   configHandlerR-   R  t   rpcR  R   t   ascii_letterst   digitsR1  R   t   signalR   R   R   R   t   showwarningR   R   RT   t
   checkcacheR   R   Rd   Ri   R~   t	   RPCClientR   R   Rg   Rn  R  Rp   R   R   (*   RZ  R   Ri   R  R~   R   R1  R   R   R  R   R  Rg   R   R   R  R   Rp   R  Rd   R   R  R   R  R!   R   R   R   R\  R  R  Rn  R   R   R  R-   R   Rj   RC  R   R  R*   (    (    R   t   ?   s|   																		 							  5	u