
"Ic        (   @   s6  d  d k  Z  d  d k Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k	 Z	 d  d k
 Z
 d  d k Z d  d k Z d  d k l Z y d  d k TWn- e j
 o! e i d IJe i d  n Xd  d k Z d  d k l Z l Z d  d k l Z d  d k l Z d  d	 k l Z d  d
 k l Z d  d k l Z d  d k Z d  d k Z d  d k Z d  d k Z e i  e i! d Z" d Z# y d  d k$ l% Z% Wn e j
 o d Z% n Xe i a& y d  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! e7 f d"     YZ8 d# Z9 d$   Z: e; d% j o e i< d% e i< d <e:   n d S(&   iN(   t   InteractiveInterpreter(   t   *sK   ** IDLE can't import Tkinter.  Your Python may not be configured for Tk. **i   (   t   EditorWindowt   fixwordbreaks(   t   FileList(   t   ColorDelegator(   t   UndoDelegator(   t   OutputWindow(   t   idleConft   _s	   127.0.0.1(   t   SIGTERMi   c      	   C   sC   t  } y# | i t i |  | | |   Wn t j
 o n Xd  S(   N(   t   warning_streamt   writet   warningst   formatwarningt   IOError(   t   messaget   categoryt   filenamet   linenot   file(    (    s,   /mit/python/lib/python2.6/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
>>> (   t	   linecachet   getlinet   stript   __name__(   R   R   R   R   t   st   line(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   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   keyst   update(   R   t   orig_checkcacheR   t   save(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   extended_linecache_checkcacheL   s    	 t   PyShellEditorWindowc           B   sz   e  Z d  Z d   Z d d g Z d   Z d d  Z d 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         S   s   | i    |    d  S(   N(   t   restore_file_breaks(   t   old_hookt   self(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   filename_changed_hookr   s    
(   t   breakpointsR   t   __init__t   textt   bindt   set_breakpoint_heret   clear_breakpoint_heret   flistt
   open_shellt   ost   patht   joinR   t   GetUserCfgDirt   breakpointPatht   ioR   R$   t   filename_change_hookt   set_filename_change_hook(   R&   t   argsR'   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR)   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*   R5   R   t   tag_addR(   t   indext
   ValueErrort   appendR.   t   pyshellt   interpt   debuggerR,   (   R&   R   R*   R   t   it   debug(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   set_breakpoint{   s    	c         C   sW   |  i  } |  i i } | p | i   d  St t | i d    } |  i |  d  S(   Nt   insert(   R*   R5   R   t   bellt   intt   floatR;   RC   (   R&   t   eventR*   R   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR,      s    	
c      	   C   s   |  i  } |  i i } | p | i   d  St t | i d    } y |  i i |  Wn n X| i	 d d d  y& |  i
 i i i } | i | |  Wn n Xd  S(   NRD   R9   s   insert linestarts   insert lineend +1char(   R*   R5   R   RE   RF   RG   R;   R(   t   removet
   tag_removeR.   R>   R?   R@   R-   (   R&   RH   R*   R   R   RB   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR-      s"    	
c         C   s   |  i  ox |  i } |  i i } | p | i   d  Sg  |  _  | i d d t  y# |  i i i	 i
 } | i |  Wq q Xn d  S(   NR9   s   1.0(   R(   R*   R5   R   RE   RJ   t   ENDR.   R>   R?   R@   t   clear_file_breaks(   R&   R*   R   RB   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRL      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(   R5   R   t   openR4   t	   readlinesR   t
   startswithR   t   update_breakpointst   strt   close(   R&   t   breaksR   t   linest   new_fileR   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   store_file_breaks   s     	 
	#c         C   s   |  i  i   |  i i } | d  j o d  St i i |  i  o} t	 |  i d  i
   } xb | D]V } | i | d  o< t | t |  d  } x | D] } |  i |  q Wq` q` Wn d  S(   NRM   RO   i   (   R*   R   R5   R   t   NoneR0   R1   t   isfileR4   RP   RQ   RR   t   evalt   lenRC   (   R&   R   RW   R   t   breakpoint_linenumberst   breakpoint_linenumber(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR$      s      c         C   s4   |  i  } | i d  } |  i |  } | |  _ d S(   s3   Retrieves all the breakpoints in the current windowR9   N(   R*   t
   tag_rangest   ranges_to_linenumbersR(   (   R&   R*   t   rangest   linenumber_list(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRS      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   (   t   rangeR]   RF   RG   R=   (   R&   Rb   RW   R;   R   t   end(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRa      s      c         C   s   |  i    t i |   d S(   s7   Extend base method - clear breaks when module is closedN(   RL   R   t   _close(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRf      s    
(   s   Set Breakpoints   <<set-breakpoint-here>>(   s   Clear Breakpoints   <<clear-breakpoint-here>>N(   R   t
   __module__t   __doc__R)   t   rmenu_specsRC   RZ   R,   R-   RL   RY   R$   RS   Ra   Rf   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR#   d   s   						'			t   PyShellFileListc           B   s&   e  Z d  Z e Z d Z d d  Z RS(   s8   Extend base class: IDLE supports a shell and breakpointsc         C   sW   |  i  o |  i  i i   n3 t |   |  _  |  i  o |  i  i   p d  Sn |  i  S(   N(   R>   t   topt   wakeupt   PyShellt   beginRZ   (   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR/     s    

	N(   R   Rg   Rh   R#   R   RZ   R>   R/   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRj     s   t   ModifiedColorDelegatorc           B   s)   e  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(   R   R)   t   LoadTagDefs(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR)     s    c         C   s7   |  i  d d d  |  i d d d  t i |   d  S(   Nt   TODOs   1.0t   iomarkt   SYNC(   RJ   R:   R   t   recolorize_main(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRt   !  s    c         C   s   t  i |   t i d d d  } |  i i h h d  d 6d  d 6d 6t i | d  d 6t i | d  d 6t i | d	  d	 6 d  S(
   Nt   maint   Themet   namet
   backgroundt
   foregroundt   stdint   stdoutt   stderrt   console(   R   Rp   R   t	   GetOptiont   tagdefsR   RZ   t   GetHighlight(   R&   t   theme(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRp   &  s    (   R   Rg   Rh   R)   Rt   Rp   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRo     s   		t   ModifiedUndoDelegatorc           B   s&   e  Z d  Z d d  Z d d  Z RS(   s;   Extend base class: forbid insert/delete before the I/O markc         C   s_   y/ |  i  i | d d  o |  i  i   d  SWn t j
 o n Xt i |  | | |  d  S(   Nt   <Rr   (   t   delegatet   compareRE   t   TclErrorR   RD   (   R&   R;   t   charst   tags(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRD   3  s    	c         C   s\   y/ |  i  i | d d  o |  i  i   d  SWn t j
 o n Xt i |  | |  d  S(   NR   Rr   (   R   R   RE   R   R   t   delete(   R&   t   index1t   index2(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR   <  s    	N(   R   Rg   Rh   RZ   RD   R   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR   0  s   	t   MyRPCClientc           B   s   e  Z d    Z RS(   c         C   s
   t   d S(   s0   Override the base class - just re-raise EOFErrorN(   t   EOFError(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt
   handle_EOFH  s    (   R   Rg   R   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR   F  s   t   ModifiedInterpreterc           B   s@  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 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(!   c         C   sQ   | |  _  t i d i } t i |  d | d  |  _ t |  _	 |  i
   |  _ d  S(   Nt   __main__t   locals(   t	   tkconsolet   syst   modulest   __dict__R    R)   RZ   t   save_warnings_filterst   Falset
   restartingt   build_subprocess_arglistt   subprocess_arglist(   R&   R   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR)   O  s    			i"  c         C   s+   |  i  } t i t i t i |  |  _ d  S(   N(   R   R0   t   spawnvt   P_NOWAITR   t
   executablet   rpcpid(   R&   R8   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   spawn_subprocess[  s    	c      
   C   s   g  } t  i D] } | d | q ~ } d d d j o | i d  n 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   -Wi   i   i    s   -QnewRu   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(   R   t   warnoptionsR=   R   R~   R   R   t   platformR   RT   t   port(   R&   t   _[1]R   RN   t	   del_exitft   commandt   decorated_exec(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR   _  s    ($	c         C   sf  |  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  S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
   Rz   R{   R|   R.   R   R?   (   R   t	   LOCALHOSTR   Rd   t   timet   sleepR   t   rpccltt   sockett   errort   display_port_binding_errorRZ   t   listening_sockt
   settimeoutt   acceptt   timeoutt   display_no_subprocess_errort   registerR   R{   R|   R.   R   t   transfer_patht   poll_subprocess(   R&   t   addrRA   t   err(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   start_subprocesss  s6    
 	



c      	   C   s  |  i  o |  i St |  _  |  i   } | o" y t i |  i  WqP qP Xn |  i i   |  i   |  i } | i	 } t
 | _	 |  i   y |  i i   Wn# t i j
 o } |  i   d  S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(
   NRr   s   end-1cs   
i   i   RO   s	    RESTART t   restartt   left(   R   R   t   Truet   getdebuggert   RemoteDebuggert   close_subprocess_debuggerRU   t   unix_terminateR   t	   executingR   R   R   R   R   R   RZ   R   R*   R   R   t
   showpromptRF   t   widtht   mark_sett   mark_gravityt   restart_subprocess_debuggert   load_breakpoints(   R&   RB   R}   t   was_executingR   t   halfbart   gui(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   restart_subprocess  sF    
	
			



	c         C   s   |  i  i d d d h   d  S(   Nt   exect   interrupt_the_server(    (   R   t
   remotecall(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   __request_interrupt  s    c         C   s   t  i d |  i  i   d  S(   Nt   target(   t	   threadingt   Threadt'   _ModifiedInterpreter__request_interruptt   start(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   interrupt_subprocess  s    c         C   sJ   y |  i  i   Wn t j
 o n X|  i   t |  i _ d  |  _  d  S(   N(   R   RU   t   AttributeErrorR   R   R   R   RZ   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   kill_subprocess  s    
c      	   C   st   t  t d  o` y t i |  i t  Wn t j
 o d SXy t i |  i d  Wqp t j
 o d SXn d S(   s;   UNIX: make sure subprocess is terminated and collect statust   killNi    (   t   hasattrR0   R   R   R
   t   OSErrort   waitpid(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s    c         C   s   |  i  d t i f  d  S(   NsR   if 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
(   t
   runcommandR   R1   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s    c      	   C   s  |  i  } | d  j o d  Sy | i |  i d d } Wn> t t t f j
 o) |  i i o d  Sd  } |  i	   n X| o |  i i
   d  |  _ | \ } } |  i i } | d j o% | d  j	 o | t |  IJqKnm | d j o% |  i i d  o |  i   qKn; | d j o- d } t i | I| IJ| | I| IJn y |  i i   Wqvt j
 o qvXn |  i i p# |  i i i |  i i |  i  n d  S(   Nt   waitg?t   OKt	   EXCEPTIONs   <<toggle-jit-stack-viewer>>t   ERRORs/   PyShell.ModifiedInterpreter: Subprocess ERROR:
(   R   RZ   t   pollresponset
   active_seqR   R   t   KeyboardInterruptR   t   closingR   t   resetoutputR}   t   reprt   getvart   remote_stack_viewerR   t
   __stderr__t   endexecutingR   R*   t   aftert   pollintervalR   (   R&   t   cltt   responset   howt   whatR}   t   errmsg(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s@    			c         C   s   | |  _  d  S(   N(   R@   (   R&   R@   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   setdebugger  s    c         C   s   |  i  S(   N(   R@   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     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&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   open_remote_stack_viewer  s    
c         C   s  d d  k  } |  i i d d d h   } | d  j o |  i i i   d  S| i |  i |  } d 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(   NiR   t   stackviewerR.   (   t   ScrolledCanvast   TreeNodeRu   Rv   Rw   t   normalRx   t   bgt   highlightthicknessi    t   expandi   t   fillt   both(   s   flist(   t   RemoteObjectBrowserR   t   remotequeueRZ   R   t   rootRE   t   StubObjectTreeItemt
   TreeWidgetR   R   t   ToplevelR   R~   R   t   framet   packt   canvasR   (   R&   R  t   oidt   itemR   R   Rk   R   Rx   t   sct   node(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR   !  s    i    c         C   s#   |  i  |  } |  i | |  d S(   s1   Like runsource() but assumes complete exec sourceN(   t   stuffsourcet   execfile(   R&   t   sourceR   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt
   execsource4  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 fileRM   R   s    *** Error in script or command!
s"   Traceback (most recent call last):N(   RZ   RP   t   readt   compilet   OverflowErrort   SyntaxErrorR   R   R|   R    t   showsyntaxerrorR   t   runcode(   R&   R   R  t   codet   tkerr(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR  9  s    

c         C   s   |  i  |  } d |  _ t i |  _ t i d d d t  t | t i	  oW d d k
 } y | i | i  } Wq t j
 o" |  i i   |  i d  d S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   iNs    Unsupported characters in input
(   R  t   moreR   t   filtersR   t   filterwarningst   SyntaxWarningt
   isinstancet   typest   UnicodeTypet	   IOBindingt   encodet   encodingt   UnicodeErrorR   R   R   R    t	   runsourceRZ   (   R&   R  R   R#  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR'  I  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    (   t   gidt   splitR]   R   R   (   R&   R  R   RW   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR  `  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   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   prepend_syspathh  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*   t   unpackerrorR:   t   seet   gett
   IDENTCHARSR   R   RT   R    R  R   (
   R&   R   R*   t   stufft   msgR   t   offsetR   t   post   char(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR  t  s$    c   
      C   s   t  i   \ } } } | t j } | oA y- | \ } \ } } } }	 | p
 d } n Wqi d } qi Xn | o | | | |	 f Sd  Sd  S(   Ni    (   R   t   exc_infoR  RZ   (
   R&   R   t   valuet   tbt   okR0  t   dummy_filenameR   R1  R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR+    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   t   checklinecacheR    t   showtracebackR   t   open_stack_viewer(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR:    s
    
c         C   sH   t  i } x8 | i   D]* } | d  | d d j o | | =q q Wd  S(   Ni   is   <>(   R   R   R   (   R&   t   ct   key(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR9    s
    	 c         B   sU   |  i  i o |  i   d S|  i o  |  i i d d | f h   n | |  i Ud S(   s*   Run the code without invoking the debuggeri    R   R  i   (   R   R   t   display_executing_dialogR   R  R   (   R&   R  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s    

 c         B   s  |  i  i o |  i i   n |  i   |  i d
 j	 o |  i e i (d
 |  _ n |  i	 } zJyw |  i  i
   | o5 |  i d
 j	 o% |  i i d d | f h   |  _ n* | o | i | |  i  n | |  i UWn e j
 oQ |  i  i p: e i d d d d d |  i  i o   q0|  i   q  nq t o+ |  i  i d IJ|  i   |  i  i   q|  i  i o  e |  i  _ |  i  i d	 IJq|  i   n XWd
 t p+ y |  i  i   Wqe j
 o qXn Xd
 S(   s   Override base class methodR   R  s   Exit?s   Do you want to exit altogether?R   t   yest   masters    IDLE internal error in runcode()R   N(   R   R   R?   R   R9  R   RZ   R   R  R@   t   beginexecutingR   t
   asyncqueueR   t   runR   t
   SystemExitR   t   tkMessageBoxt   askyesnoR*   R:  t   use_subprocessR|   R   t   canceledR   R   (   R&   R  R@   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR    sR    
	 

c         C   s   |  i  i i |  d S(   s   Override base class methodN(   R   R|   R   (   R&   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     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@  (   RE  t	   showerrorR   R*   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     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@  (   RE  RI  R   R*   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     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@  (   RE  RI  R   R*   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR>    s    N('   R   Rg   R)   R   RZ   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+  R:  R9  R   R  R   R   R   R>  (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR   M  sH   				!	,							&													1			Rm   c           B   s  e  Z d  Z e Z e Z d3 d4 d5 d6 d7 d8 g Z e i	   o e d =d9 e d <n d 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: d-  Z. d: d.  Z/ d: d/  Z0 d0   Z1 d1   Z2 d; d2  Z3 RS(<   s   Python ShellR   t   _Filet   editt   _EditRB   t   _Debugt   optionst   _Optionst   windowst   _Windowst   helpt   _Helpit   _Windowii(   t   Historyc         C   sL  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   t |  _ d |  _ t |  _ |  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  t  o* | i d |  i  | i d |  i  n t i |  _ t i |  _  t i! |  _" d 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   She_lli   t   wrapR3  s   <<newline-and-indent>>s   <<plain-newline-and-indent>>s   <<interrupt-execution>>s   <<end-of-file>>s   <<open-stack-viewer>>s   <<toggle-debugger>>s   <<toggle-jit-stack-viewer>>s   <<view-restart>>s   <<restart-shell>>iR{   R|   R}   i2   (   s   shellRW  (*   RG  t
   menu_specsRD   R   R?   RZ   t   TkR   t   withdrawRj   R   R)   R   t   usetabst   indentwidtht   context_use_ps1R*   t	   configureR+   t   enter_callbackt   linefeed_callbackt   cancel_callbackt   eof_callbackR;  t   toggle_debuggert   toggle_jit_stack_viewert   view_restart_markt   restart_shellR   R{   t   save_stdoutR|   t   save_stderrRz   t
   save_stdinR#  t
   PseudoFileR%  R}   RU  t   historyR   (   R&   R.   t   msR  R*   R#  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR)   $  sN    		

				c         C   s   t  i d t  S(   Nt
   shell_only(   R   t   GetExtensionsR   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   get_standard_extension_namesU  s    c         C   s
   | a  d  S(   N(   R   (   R&   t   stream(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   set_warning_stream^  s    c         C   s   t  S(   N(   R   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   get_warning_streamb  s    c         C   sd   |  i  o( t i d d d |  i |  i   d S|  i i   } | o |  i   n |  i   d  S(   Ns   Don't debug nows*   You can only toggle the debugger when idleR@  t   break(	   R   RE  RI  R*   t   set_debugger_indicatorR?   R   t   close_debuggert   open_debugger(   R&   RH   t   db(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRd  e  s    
	

c         C   s%   |  i  i   } |  i d |  d  S(   Ns   <<toggle-debugger>>(   R?   R   t   setvar(   R&   Rx  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRu  s  s    c         C   s   d  S(   N(    (   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRe  w  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   RZ   RU   R   R   t   close_remote_debuggerR   R}   R   R   t   ps1R   Ru  (   R&   Rx  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRv  z  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   t   start_remote_debuggert   DebuggerR   R   R   R{  R   Ru  (   R&   t   dbg_gui(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRw    s    
	
c         C   s   |  i    d |  _ d S(   s   Helper for ModifiedInterpreteri   N(   R   R   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRA    s    
c         C   s    d |  _  d |  _ |  i   d S(   s   Helper for ModifiedInterpreteri    N(   R   RH  R   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s    		c         C   s   |  i  o7 t i d d d d d |  i } | t j o d S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   R7  t   parentt   canceli   N(   R   RE  t   askokcancelR*   R   t   readingRk   t   quitR   RH  R   R   R   t   close2(   R&   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRU     s    
	
		c         C   s   t  i |   S(   N(   R   RU   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR    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(   Rv  RG  R?   R   Rh  R   R{   Ri  R|   Rj  Rz   RZ   R}   R.   R>   Rl  R   Rf   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRf     s    
			c         C   s   t  S(   s8   Override EditorWindow method: never remove the colorizer(   R   (   R&   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   ispythonsource  s    c         C   s   |  i  S(   N(   t   shell_title(   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   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 o/ d } |  i i   } | p |  i   t Sn d } |  i d t i t i	 |  i
 |  i t i | f  |  i   d d  k } d  | _ t S(   Nt    s   ==== No Subprocess ====s&   Python %s on %s
%s
%s
IDLE %s      %s
i(   R   RG  R?   R   RU   R   R   R   t   versionR   t	   COPYRIGHTt   firewallmessaget   idlevert   IDLE_VERSIONR   t   TkinterRZ   t   _default_rootR   (   R&   t   nosubt   clientR  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRn     s    

		
	c      	   C   s  |  i  } z d |  _  |  i i   Wd  | |  _  X|  i i d d  } t |  d j o
 d } n t | t  o< d 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   Rr   s   end-1ci    s   
iR  (   R  Rk   t   mainloopR*   R-  R]   R   t   unicodeR#  R$  R%  R&  R   RH  RG  R   t	   endoffile(   R&   R!   R   R#  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   readline  s.    		

	

	
	
c         C   s   t  S(   N(   R   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   isatty  s    c         C   s   y" |  i  i d d d  o d  SWn n X|  i p |  i p) |  i   |  i i d  |  i   d S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
Rt  i    i   (   R*   R   R   R  R   R?   R   R   R  RH  R   R   R   R   Rk   R  (   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRb    s&    	

		
c         C   s   |  i  o |  i o d  S|  i i d d d  o |  i i d d d  p d  S|  i  p |  i   |  i   n  d |  _ d |  _ |  i i	   d S(   NRr   s   ==RD   s   end-1ci    i   Rt  (
   R   R  R*   R   R   RU   RH  R  Rk   R  (   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRc    s    

		c         C   sB   |  i  o' |  i i d d  |  i i d  n |  i |  d S(   NRD   s   
Rt  (   R  R*   RD   R,  t   newline_and_indent_event(   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRa  )  s
    
c         C   s  |  i  o |  i o d  SyR |  i i d d  } | o2 |  i i d d d  o |  i | |  d Sn Wn n X|  i i d d d  oN|  i i d	 d  } | oI |  i i d d | d
  o, |  i |  i i | d | d
  |  d S|  i i d	 d  } | oI |  i i d d | d  o, |  i |  i i | d | d
  |  d S|  i i d d  } | oD |  i i | d d d  o' |  i |  i i | d
 d  |  n  |  i |  i i d d  |  d S|  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 S|  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   <=Rr   Rt  RD   R   s   iomark linestartRz   i   i    s   insert lineends   >=R}   s   insert linestarts   end-1cs   end-1c linestarts   
(   R   R  R*   R-  R   t   recallt   tag_prevranget   tag_nextrangeR   R   R   R  RD   R,  R:   t   update_idletasksRk   R  t   runit(   R&   RH   t   selt   prevt   nextt   indicesR   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR`  2  sX    $'$''


c      
   C   s  t  i d d |  } t  i d d |  } | i d  } |  i i   zF|  i i d d d  |  i i d d	  |  i i d
 d  } | i   i	 d  o& |  i
 |  |  i i d
 d  } n |  i i d | d i    t |  d j o t  i d | d  i d  } t  i d |  i d  } x[ | d D]K } | i |  o | | t |  } n |  i i d d | i    q8Wn Wd  |  i i d  |  i i   Xd  S(   Ns   ^\s*\nR  s   \n\s*$s   
R  s   1.0Re   RD   s   end-1cs   insert linestartt   :i    i   s	   ^([ \t]*)(   t   ret   subR)  R*   t   undo_block_startRJ   R   R-  t   rstript   endswithR  RD   R   R]   t   searcht   groupRR   R,  t   undo_block_stop(   R&   R   RH   RW   t   prefixt   orig_base_indentt   new_base_indentR   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR  q  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(   NRr   s   end-1ci    i   s    	s   
(   R*   R-  R]   R?   R'  (   R&   R   RA   R  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR    s     "" "
c         C   ss   |  i  i o |  i  i   Sy t i Wn! t i d d d |  i d  SXd d k l	 } | |  i
 |  i  } d  S(   Ns   No stack traces@   There is no stack trace yet.
(sys.last_traceback is not defined)R@  i(   t   StackBrowser(   R?   R   R   R   t   last_tracebackRE  RI  R*   t   StackViewerR  R  R.   (   R&   RH   R  t   sv(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR;    s    	
c         C   s$   |  i  i d  |  i  i d  d  S(   NRr   R   (   R*   R,  (   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRf    s    c         C   s   |  i  i   d  S(   N(   R?   R   (   R&   RH   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRg    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  RD   s   end-1c(   R   RT   R   R{  R}   R   R*   R   t   set_line_and_columnR5   t
   reset_undo(   R&   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     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(   NRr   s   end-1cs   end-2cs   
i    (
   R*   R-  Rl  t   history_storeRD   R   R  R   R{   t	   softspace(   R&   R  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     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(   NRr   t   rightR   i    (   R*   R   R   R   RH  RG  R   (   R&   R   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s    
	(   s   fileRJ  (   RK  RL  (   s   debugRM  (   RN  RO  (   RP  RQ  (   s   helpRS  (   RP  RT  N(    (4   R   Rg   R  Ro   R   R   R   RY  t   macosxSupportt   runningAsOSXAppt   IdleHistoryRU  RZ   R)   Rp  R   R  R   RH  R  R   Rr  Rs  Rd  Ru  Re  Rv  Rw  RA  R   RU   R  Rf   R  R  R  R  Rn   R  R  Rb  Rc  Ra  R`  R  R  R;  Rf  Rg  R   R   R   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRm   
  sf   	1																					?				
Rk  c           B   s8   e  Z d d   Z d   Z d   Z d   Z d   Z RS(   c         C   s(   | |  _  | |  _ d |  _ | |  _ d  S(   Ni    (   RV  R   R  R%  (   R&   RV  R   R%  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR)     s    			c         C   s   |  i  i | |  i  d  S(   N(   RV  R   R   (   R&   R   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR     s    c         C   s   t  |  i |  d  S(   N(   t   mapR   (   R&   t   l(    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt
   writelines  s    c         C   s   d  S(   N(    (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   flush  s    c         C   s   t  S(   N(   R   (   R&   (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyR    s    N(   R   Rg   RZ   R)   R   R  R  R  (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRk    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 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 | <q+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 | }  t d d  a t  t  t i!   t" t  a# t$ i% t t#  | oI | p | p7 x | D] } t# i& |  q
W| p t# i'   q:q>n |  oD t# i(   } | p d  St$ i)   o t# i* o | i+ i,   qn t# i- } | o | i.   n | oW t i/ i0 d  p t i/ i0 d  } | o' t i i |  o | i1 i2 |  qn | o | p | od | i1 i3 d t i f  | o | i1 i4 |  q~| o$ | i1 i5 |  | i1 i2 |  q~n t i6   t i7   d  S(   Ni   s   c:deihnr:st:s
   Error: %s
i   s   -cs   -ds   -es   -hs   -is   -ns   -rs   No script file: s   -ss   -ti    t   -R  Ru   R   s   editor-on-startupR   R   t	   classNamet   Idlet   IDLESTARTUPt   PYTHONSTARTUPsb   if 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
(8   R   RG  R   RZ   t   getoptR   t   argvR   R|   R   RT   t	   usage_msgt   exitR{   R0   R1   R[   Rm   R  Rz   R  Rd   R]   t   abspathR=   t   dirnameRD   t   getcwdR   R~   RZ  R  R   R[  Rj   R.   R  t   setupAppRP   t   newR/   R  t   dictRk   t   lowerR>   Rw  t   environR-  R?   R  R   R  R*  R  t   destroy(   t   enable_shellt   enable_editRB   t   cmdt   scriptt   startupt   optsR8   R0  t   ot   aRA   t   pathxR   t   dirt
   edit_startRV  (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyRu     s    # 




	


	
 $  

 		
R   (=   R0   t   os.pathR   t   stringR  R  R   R   R   t	   tracebackR!  R  R   R  R    R  t   ImportErrorR   R  RE  R   R   R   R   R   R   t   configHandlerR   R  t   rpcR}  R   t   ascii_letterst   digitsR.  R   t   signalR
   R   R   R   t   showwarningR   R   RZ   t
   checkcacheR"   R#   Rj   Ro   R   t	   RPCClientR   R   Rm   t   objectRk  R  Ru   R   R   (    (    (    s,   /mit/python/lib/python2.6/idlelib/PyShell.pyt   <module>   s|   							  H	~