Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/idlelib/PyShell.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZyddlTWn+ek
r�ejdIJejd�nXddlZddlmZmZddlmZdd	lmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl#m%Z%ddl#m&Z&ddl#m'Z'ddl#m(Z(ej)ej*dZ+dZ,dZ-yddl.m/Z/Wnek
rdZ/nXeja0yddl1Z1Wnek
r4n.Xe2e2d�Z3e3e1_4e2d�Z5e5e1_6e2ej7d�Z8e8e_7defd��YZ9defd��YZ:defd��YZ;d efd!��YZ<d"e%j=fd#��YZ>d$efd%��YZ?d&e fd'��YZ@d(ejAfd)��YZBd*eBfd+��YZCd,eBfd-��YZDd.ZEd/�ZFeGd0kr�ejHd0ejHd&<eF�ndS(1i�N(tInteractiveInterpreter(tpython_version(t*sK** IDLE can't import Tkinter.  Your Python may not be configured for Tk. **i(tEditorWindowt
fixwordbreaks(tFileList(tColorDelegator(t
UndoDelegator(tOutputWindow(tidleConf(tidlever(trpc(tDebugger(tRemoteDebugger(t
macosxSupportt_s	127.0.0.1i(tSIGTERMicCsV|dkrt}ny)|jtj||||d|��Wntk
rQnXdS(Ntline(tNonetwarning_streamtwritetwarningst
formatwarningtIOError(tmessagetcategorytfilenametlinenotfileR((s%/sys/lib/python2.7/idlelib/PyShell.pytidle_showwarning<s	
cCsyd}|d||f7}|dkr;tj||�}n|j�}|r^|d|7}n|d|j|f7}|S(sFormat warnings the IDLE ways!
Warning (from warnings module):
s  File "%s", line %s
s    %s
s%s: %s
>>> N(Rt	linecachetgetlinetstript__name__(RRRRRts((s%/sys/lib/python2.7/idlelib/PyShell.pytidle_formatwarningFscCsotj}i}xBt|�D]4}|d |ddkr|j|�||<qqW||�|j|�dS(soExtend 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()
    (skipping them), and then restore the saved entries.

    orig_checkcache is bound at definition time to the original
    method, allowing it to be patched.
    ii�s<>N(Rtcachetlisttpoptupdate(Rtorig_checkcacheR$tsavetkey((s%/sys/lib/python2.7/idlelib/PyShell.pytextended_linecache_checkcacheSs	
tPyShellEditorWindowcBs�eZdZd�ZdddddgZd�Zdd�Zdd�Zd�Z	d�Z
d�Zd�Zd�Z
d�ZRS(s6Regular text edit window in IDLE, supports breakpointscGs�g|_tj||�|jjd|j�|jjd|j�|jjd|jj�t	j
jtj
�d�|_|jj|d�}|jj|�|jjr�|j�ndS(Ns<<set-breakpoint-here>>s<<clear-breakpoint-here>>s<<open-python-shell>>sbreakpoints.lstcSs|j�|�dS(N(trestore_file_breaks(told_hooktself((s%/sys/lib/python2.7/idlelib/PyShell.pytfilename_changed_hookws
(tbreakpointsRt__init__ttexttbindtset_breakpoint_heretclear_breakpoint_heretflistt
open_shelltostpathtjoinR	t
GetUserCfgDirtbreakpointPathtiotfilename_change_hooktset_filename_change_hookRR-(R/targsR0((s%/sys/lib/python2.7/idlelib/PyShell.pyR2ms		tCuts<<cut>>trmenu_check_cuttCopys<<copy>>trmenu_check_copytPastes	<<paste>>trmenu_check_pastesSet Breakpoints<<set-breakpoint-here>>sClear Breakpoints<<clear-breakpoint-here>>cCs�|j}|jj}|jdd|d|d�y|jj|�}Wn!tk
rm|jj|�nXy&|jj	j
j}|j||�WnnXdS(NtBREAKs%d.0i(
R3R>Rttag_addR1tindext
ValueErrortappendR7tpyshelltinterptdebuggerR5(R/RR3Rtitdebug((s%/sys/lib/python2.7/idlelib/PyShell.pytset_breakpoint�s	
cCsU|j}|jj}|s)|j�dStt|jd���}|j|�dS(Ntinsert(R3R>RtbelltinttfloatRJRR(R/teventR3RR((s%/sys/lib/python2.7/idlelib/PyShell.pyR5�s	
cCs�|j}|jj}|s)|j�dStt|jd���}y|jj|�WnnX|j	ddd�y&|j
jjj
}|j||�WnnXdS(NRSRHsinsert linestartsinsert lineend +1char(R3R>RRTRURVRJR1tremovet
tag_removeR7RMRNROR6(R/RWR3RRRQ((s%/sys/lib/python2.7/idlelib/PyShell.pyR6�s"	
cCs�|jr~|j}|jj}|s2|j�dSg|_|jddt�y#|jjj	j
}|j|�Wq~q~XndS(NRHs1.0(R1R3R>RRTRYtENDR7RMRNROtclear_file_breaks(R/R3RRQ((s%/sys/lib/python2.7/idlelib/PyShell.pyR[�s		
	c	CsO|j}|jj}y+t|jd��}|j�}WdQXWntk
rYg}nXy�t|jd��}x1|D])}|j|d�sy|j|�qyqyW|j	�|j}|r�j|dt
|�d�nWdQXWn`tk
rJ}t|jdt
�sKt|j_tjddd	d
t
|�d|j�qKnXdS(s#Save breakpoints when file is savedtrNtwt=s
tbreakpoint_error_displayedttitles
IDLE ErrorRs$Unable to update breakpoint list:
%stparent(R1R>RtopenR=t	readlinesRt
startswithRtupdate_breakpointststrtgetattrtroottFalsetTrueR_ttkMessageBoxt	showerrorR3(R/tbreaksRtold_filetlinestnew_fileRterr((s%/sys/lib/python2.7/idlelib/PyShell.pytstore_file_breaks�s.	



	,
cCs�|jj�|jdkr dS|jj}|dkr<dStjj|j�r�t	|jd�j
�}x_|D]T}|j|d�rpt|t
|�d�}x|D]}|j|�q�WqpqpWndS(NR\R^i(R3R'R>RRR9R:tisfileR=RbRcRdtevaltlenRR(R/RRoRtbreakpoint_linenumberstbreakpoint_linenumber((s%/sys/lib/python2.7/idlelib/PyShell.pyR-�s


cCs4|j}|jd�}|j|�}||_dS(s3Retrieves all the breakpoints in the current windowRHN(R3t
tag_rangestranges_to_linenumbersR1(R/R3trangestlinenumber_list((s%/sys/lib/python2.7/idlelib/PyShell.pyRe�s	cCs�g}x�tdt|�d�D]f}tt||j��}tt||dj��}x'||kr�|j|�|d7}q^WqW|S(Niii(trangeRuRURVtstringRL(R/RzRoRJRtend((s%/sys/lib/python2.7/idlelib/PyShell.pyRys
cCs|j�tj|�dS(s7Extend base method - clear breaks when module is closedN(R[Rt_close(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyRs
(RBs<<cut>>srmenu_check_cut(RDs<<copy>>RE(RFs	<<paste>>srmenu_check_pasteN(sSet Breakpoints<<set-breakpoint-here>>N(sClear Breakpoints<<clear-breakpoint-here>>N(R!t
__module__t__doc__R2Rtrmenu_specsRRR5R6R[RrR-ReRyR(((s%/sys/lib/python2.7/idlelib/PyShell.pyR,js 						/			tPyShellFileListcBs&eZdZeZdZdd�ZRS(s8Extend base class: IDLE supports a shell and breakpointscCsQ|jr|jjj�n.t|�|_|jrJ|jj�sJdSn|jS(N(RMttoptwakeuptPyShelltbeginR(R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR8&s		N(R!R�R�R,RRRMR8(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�stModifiedColorDelegatorcBs2eZdZd�Zd�Zd�Zd�ZRS(s8Extend base class: colorizer for the shell window itselfcCstj|�|j�dS(N(RR2tLoadTagDefs(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR24s
cCs7|jddd�|jddd�tj|�dS(NtTODOs1.0tiomarktSYNC(RYRIRtrecolorize_main(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�8scCs�tj|�tjddd�}|jjiidd6dd6d6tj|d�d6tj|d�d6tj|d	�d	6�dS(
NtmaintThemetnamet
backgroundt
foregroundtstdintstdouttstderrtconsole(RR�R	t	GetOptionttagdefsR'RtGetHighlight(R/ttheme((s%/sys/lib/python2.7/idlelib/PyShell.pyR�=s
cCs+x$|jD]}|j|dd�q
WdS(NR�R~(R�RY(R/ttag((s%/sys/lib/python2.7/idlelib/PyShell.pytremovecolorsGs(R!R�R�R2R�R�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�1s
			
tModifiedUndoDelegatorcBs&eZdZdd�Zdd�ZRS(s;Extend base class: forbid insert/delete before the I/O markcCs[y-|jj|dd�r,|jj�dSWntk
r@nXtj||||�dS(Nt<R�(tdelegatetcompareRTtTclErrorRRS(R/RJtcharsttags((s%/sys/lib/python2.7/idlelib/PyShell.pyRSOs

cCsXy-|jj|dd�r,|jj�dSWntk
r@nXtj|||�dS(NR�R�(R�R�RTR�Rtdelete(R/tindex1tindex2((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Xs

N(R!R�R�RRSR�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Ls	tMyRPCClientcBseZd�ZRS(cCs
t�dS(s0Override the base class - just re-raise EOFErrorN(tEOFError(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyt
handle_EOFds(R!R�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�bstModifiedInterpretercBs@eZd�ZdZdZd�Zd�Zd�Ze	d�Z
d�Zd�Zd�Z
d�Ze	d	�ZdZd
�ZdZd�Zd�Zd
�Zd�ZdZd�Zdd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&RS( cCsf||_tjdj}tj|d|�d|_t|_	d|_
t|_|j
jj|_dS(Nt__main__tlocals(t	tkconsoletsystmodulest__dict__RR2Rtsave_warnings_filtersRit
restartingtsubprocess_arglisttPORTtporttcompiletcompilertflagstoriginal_compiler_flags(R/R�R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR2ks					cCsL|jdkr!|j�|_n|j}tjtjtj|�|_dS(N(	R�Rtbuild_subprocess_arglistR9tspawnvtP_NOWAITR�t
executabletrpcpid(R/RA((s%/sys/lib/python2.7/idlelib/PyShell.pytspawn_subprocessxs	cCs|jdkstd��gtjD]}d|^q%}dddkr[|jd�ntjddd	d
tdd�}td
kr�d|f}n
d|f}tj	d dkr�dtj
kr�dtj
}n	tj
}|g|d|t|j�gS(Nis/Socket should have been assigned a port number.s-Wiis-QnewR�tGeneralsdelete-exitfunctdefaultttypetboolsidlelib.PyShells&__import__('idlelib.run').run.main(%r)s__import__('run').main(%r)itwint s"%s"s-c(R�tAssertionErrorR�twarnoptionsRLR	R�RiR!tplatformR�Rf(R/R"R]t	del_exitftcommandtdecorated_exec((s%/sys/lib/python2.7/idlelib/PyShell.pyR�~s	 
"	cCs�t|jf}x\td�D]@}tj|�yt|�|_PWqtjk
r[}qXqW|j	�dS|jjj�d|_t
dkr�|jjjtjtjd�n|j�|jjjd�y|jj�Wn!tjk
r}|j�dSX|jjd|j�|jjd|jj�|jjd|jj�|jjd|jj�|jjd	|jj�|jjd
t�|jjd|�|jdt�|j�|jS(
Niiii
R�R�R�R�R7RRNtwith_cwd( tHOSTR�R|ttimetsleepR�trpcclttsocketterrortdisplay_port_binding_errorRtlistening_socktgetsocknameR�t
setsockoptt
SOL_SOCKETtSO_REUSEADDRR�t
settimeouttacceptttimeouttdisplay_no_subprocess_errortregisterR�R�R�R�R7Rt
transfer_pathRjtpoll_subprocess(R/taddrRPRq((s%/sys/lib/python2.7/idlelib/PyShell.pytstart_subprocess�s>




cCs�|jr|jSt|_|j�}|rLytj|j�WqLqLXn|jj�|j�|j}|j	}t
|_	|j�y|jj�Wn!t
jk
r�}|j�dSX|jd|�|j�|jjdd�|r
|jd�|j�nt|j�ddd}|j|d|�|jjd	d�|jjd	d
�|j�|r�tj|j�}|j�n|j|jj_ t
|_|jS(NR�R�send-1cs
iiR^s	 RESTART trestarttleft(!R�R�RjtgetdebuggerR
tclose_subprocess_debuggertclosetunix_terminateR�t	executingRiR�R�R�R�R�RR�t
stop_readlineR3R�Rt
showpromptRUtwidthtmark_settmark_gravitytrestart_subprocess_debuggertload_breakpointsR�R�R�R�(R/R�RQR�t
was_executingRqthalfbartgui((s%/sys/lib/python2.7/idlelib/PyShell.pytrestart_subprocess�sJ		

			






	cCs|jjdddi�dS(Ntexectinterrupt_the_server((R�t
remotecall(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyt__request_interrupt�scCstjd|j�j�dS(Nttarget(t	threadingtThreadt'_ModifiedInterpreter__request_interrupttstart(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytinterrupt_subprocess�scCsHy|jj�Wntk
r$nX|j�t|j_d|_dS(N(R�R�tAttributeErrorR�RiR�R�R(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytkill_subprocess�s

cCsnttd�rjytj|jt�Wntk
r:dSXytj|jd�Wqjtk
rfdSXndS(s;UNIX: make sure subprocess is terminated and collect statustkillNi(thasattrR9RR�RtOSErrortwaitpid(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s

cCsC|r"dg}|jtj�n	tj}|jd|f�dS(NtsRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
(textendR�R:t
runcommand(R/R�R:((s%/sys/lib/python2.7/idlelib/PyShell.pyR�
s		cCs�|j}|dkrdSy|j|jdd�}Wn:tttfk
rq|jjr^dSd}|j	�nX|rb|jj
�d|_|\}}|jj}|dkr�|dk	r:|t|�IJq:nf|dkr|jj
d�r:|j�q:n8|dkr:d}tj|I|IJ||I|IJny|jj�Wqbtk
r^qbXn|jjs�|jjj|jj|j�ndS(Ntwaitg����tOKt	EXCEPTIONs<<toggle-jit-stack-viewer>>tERRORs/PyShell.ModifiedInterpreter: Subprocess ERROR:
(R�Rtpollresponset
active_seqR�RtKeyboardInterruptR�tclosingR�tresetoutputR�treprtgetvartremote_stack_viewerR�t
__stderr__tendexecutingR�R3taftertpollintervalR�(R/tclttresponsethowtwhatR�terrmsg((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s@	
	
cCs
||_dS(N(RO(R/RO((s%/sys/lib/python2.7/idlelib/PyShell.pytsetdebuggerAscCs|jS(N(RO(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�DscCs|jjjd|j�dS(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 exception.  It is queried through
        the RPC mechanism.

        i,N(R�R3RR(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytopen_remote_stack_viewerGs
cCsddlm}|jjdddi�}|dkrK|jjj�dS|j|j|�}ddl	m
}m}t|jj�}t
jddd	�}t
j|d
�d}||d|d
d�}	|	jjdddd�||	jd|�}
|
j�dS(Ni�(tRemoteObjectBrowserR�tstackviewerR7(tScrolledCanvastTreeNodeR�R�R�tnormalR�tbgthighlightthicknessitexpanditfilltboth(sflist(tidlelibRR�tremotequeueRR�RhRTtStubObjectTreeItemtidlelib.TreeWidgetR R!tToplevelR	R�R�tframetpacktcanvasR%(R/RtoidtitemR R!R�R�R�tsctnode((s%/sys/lib/python2.7/idlelib/PyShell.pyRTsicCs#|j|�}|j||�dS(s1Like runsource() but assumes complete exec sourceN(tstuffsourcetexecfile(R/tsourceR((s%/sys/lib/python2.7/idlelib/PyShell.pyt
execsourcegscCs�|dkr$t|d�j�}nyt||d�}Wnattfk
r�|jj�|jj}|dIJ|dIJt	j
||�|jj�nX|j|�dS(sExecute an existing fileR\R�s *** Error in script or command!
s"Traceback (most recent call last):N(
RRbtreadR�t
OverflowErrortSyntaxErrorR�RR�RtshowsyntaxerrorR�truncode(R/RR6tcodettkerr((s%/sys/lib/python2.7/idlelib/PyShell.pyR5ls


cCs�|j|�}d|_tj|_tjdddt�t|tj	�r�ddl
m}y|j|j
�}Wq�tk
r�|jj�|jd�dSXnztj|||�SWd|jdk	r�jtj(d|_nXdS(	sBExtend base class method: Stuff the source in the line cache firstitactionR�Ri�(t	IOBindings Unsupported characters in input
N(R4tmoreRtfiltersR�tfilterwarningst
SyntaxWarningt
isinstancettypestUnicodeTypeR(R@tencodetencodingtUnicodeErrorR�RRRt	runsourceR(R/R6RR@((s%/sys/lib/python2.7/idlelib/PyShell.pyRK|s"	




cCsSd|j}|jd|_|jd�}t|�dd||ftj|<|S(s"Stuff source in the filename caches<pyshell#%d>is
i(tgidtsplitRuRR$(R/R6RRo((s%/sys/lib/python2.7/idlelib/PyShell.pyR4�s

#cCs|jd|f�dS(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%/sys/lib/python2.7/idlelib/PyShell.pytprepend_syspath�sc
Cs|jj}|j�}|r�\}}}}|dkrMd|d}nd|d|df}|jd|�|j|�|j|�}	|	r�|	tkr�|jd|d|�n|jj�|jdt	|��n|jj�t
j||�|jj�dS(s�Extend base class method: Add Colorizing

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

        isiomark + %d charss&iomark linestart + %d lines + %d charsR
s
 wordstartsSyntaxError: %s
N(
R�R3tunpackerrorRItseetgett
IDENTCHARSRRRfRR;R�(
R/RR3tstufftmsgRtoffsetRtpostchar((s%/sys/lib/python2.7/idlelib/PyShell.pyR;�s$


c
Cs�tj�\}}}|tk}|rey+|\}\}}}}	|sQd}nWqed}qeXn|r{||||	fSdSdS(Ni(R�texc_infoR:R(
R/R�tvaluettbtokRTtdummy_filenameRRUR((s%/sys/lib/python2.7/idlelib/PyShell.pyRO�s

cCsJ|jj�|j�tj|�|jjd�rF|jj�ndS(s1Extend base class method to reset output properlys<<toggle-jit-stack-viewer>>N(R�RtchecklinecacheRt
showtracebackRtopen_stack_viewer(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR^�s



cCsFtj}x6|j�D](}|d |ddkr||=qqWdS(Nii�s<>(RR$tkeys(R/tcR*((s%/sys/lib/python2.7/idlelib/PyShell.pyR]�s	cBsQ|jjr|j�dS|jrB|jjdd|fi�n||jUdS(s*Run the code without invoking the debuggeriR�R<i(R�R�tdisplay_executing_dialogR�R)R�(R/R=((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s
	cBs�|jjr|jj�n|j�|jd
k	rN|jej(d
|_n|j	}z;yr|jj
�|r�|jd
k	r�|jjdd|fi�|_
n'|r�|j||j�n||jUWn�ek
r%|jjsejddddd|jj�r�q"|j�q��nlerX|jjdIJ|j�|jj�q�|jjr�e|j_|jjd	IJq�|j�nXWd
es�y|jj�Wq�ek
r�q�XnXd
S(sOverride base class methodR�R<sExit?sDo you want to exit altogether?R�tyestmasters IDLE internal error in runcode()R
N(R�R�RNR�R]R�RRRBROtbeginexecutingR�t
asyncqueueRtrunR�t
SystemExitRRktaskyesnoR3R^tuse_subprocessR�RtcanceledRiR�(R/R=RO((s%/sys/lib/python2.7/idlelib/PyShell.pyR<�sR

	





cCs|jjj|�dS(sOverride base class methodN(R�R�R(R/R"((s%/sys/lib/python2.7/idlelib/PyShell.pyRscCs tjddd|jj�dS(NsPort Binding ErrorsAIDLE can't bind to a TCP/IP port, which is necessary to communicate with its Python execution server.  This might be because no networking is installed on this computer.  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.Rd(RkRlR�R3(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�!scCs tjddd|jj�dS(NsSubprocess Startup Errors�IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.Rd(RkRlR�R3(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�,scCs tjddd|jj�dS(NsAlready executingsYThe Python Shell window is already executing a command; please wait until it is finished.Rd(RkRlR�R3(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyRb4sN('R!R�R2RR�R�R�R�R�RiR�R�R�R�R�R�RR�RORR�RRRLR7R5RKR4RNR;ROR^R]RR<RR�R�Rb(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�isF	
			+.					
	&			
										1			R�cBs�eZde�dZeZeZd6d7d8d9d:d;gZe	j
�r[ed=d<ed<nddlmZd=d�Zd�ZeZeZeZeZeZeZd�Zd�Zd=d�Zd�Zd=d�Zd�Zd�Zd�Zd�Zd�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.�Z0d=d/�Z1d=d0�Z2d1�Z3d2�Z4d>d3�Z5d4�Z6d5�Z7RS(?sPython s ShellRt_Fileteditt_EditRQt_Debugtoptionst_Optionstwindowst_Windowsthelpt_Helpi�t_Windowi�i�(tHistorycCsatr9|j}|dddkr9|jdd�q9nt|�|_|dkr�t�}t|�|j�t	|�}nt
j||dd�t|_
d|_t|_|j}|jdd�|jd|j�|jd	|j�|jd
|j�|jd|j�|jd|j�|jd
|j�|jd|j�tr~|jd|j�|jd|j�ntj|_tj|_ tj!|_"ddl#m$}t%|d|j&�|_!t'|d|j&�|_t'|d|j&�|_t'|d|j&�|_(ts?|jt_|jt_|j!t_!n|j)|j�|_*d|_+dS(NiitshelltShe_llitwrapRWs<<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>>i�(R@R�R�R�R�i2(sshellRy(,Rjt
menu_specsRSR�RNRtTkRtwithdrawR�RR2Rjtusetabstindentwidthtcontext_use_ps1R3t	configureR4tenter_callbacktlinefeed_callbacktcancel_callbackteof_callbackR_ttoggle_debuggerttoggle_jit_stack_viewertview_restart_markt
restart_shellR�R�tsave_stdoutR�tsave_stderrR�t
save_stdinR(R@tPseudoInputFileRItPseudoOutputFileR�RwthistoryR(R/R7tmsRhR3R@((s%/sys/lib/python2.7/idlelib/PyShell.pyR2VsP		

				cCstjdt�S(Nt
shell_only(R	t
GetExtensionsRj(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytget_standard_extension_names�scCs
|adS(N(R(R/tstream((s%/sys/lib/python2.7/idlelib/PyShell.pytset_warning_stream�scCstS(N(R(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytget_warning_stream�scCs`|jr0tjddd|j�|j�dS|jj�}|rR|j�n
|j�dS(NsDon't debug nows*You can only toggle the debugger when idleRdtbreak(	R�RkRlR3tset_debugger_indicatorRNR�tclose_debuggert
open_debugger(R/RWtdb((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s		


cCs%|jj�}|jd|�dS(Ns<<toggle-debugger>>(RNR�tsetvar(R/R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCsdS(N((R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCs�|jj�}|r�|jjd�|j�|jjrQtj|jj�n|j�|j	j
d�dt_|j
�n|j�dS(Ns[DEBUG OFF]
s>>> (RNR�RRR�R�R
tclose_remote_debuggerRR�RR�tps1R�R�(R/R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s

	
cCsq|jjr'tj|jj|�}ntj|�}|jj|�|j�dt_|j	�|j
�dS(Ns[DEBUG ON]
>>> (RNR�R
tstart_remote_debuggerRRR�R�R�R�R�(R/tdbg_gui((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s
	
cCs|j�d|_dS(sHelper for ModifiedInterpreteriN(RR�(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyRe�s
cCs d|_d|_|j�dS(sHelper for ModifiedInterpreteriN(R�RkR�(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s		cCsz|jr=tjddddd|j�}|tkr=dSn|j�t|_t|_|jj	d|j
|j�dS(	sExtend EditorWindow.close()sKill?s6The program is still running!
 Do you want to kill it?R�R[RatcanceliN(R�RktaskokcancelR3RiR�RjRkRRRtclose2(R/R((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s	
		cCs
tj|�S(N(RR�(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCs||j�tr |jj�n|jt_|jt_|j	t_
d|_d|_d|j
_d|_tj|�dS(sEExtend EditorWindow._close(), shut down debugger and execution serverN(R�RjRNR�R�R�R�R�R�R�R�RR�R7RMR�RR(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s
			cCstS(s8Override EditorWindow method: never remove the colorizer(Rj(R/R((s%/sys/lib/python2.7/idlelib/PyShell.pytispythonsource�scCs|jS(N(tshell_title(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytshort_title�ss@Type "copyright", "credits" or "license()" for more information.cCs�|j�tr<d}|jj�}|sB|j�tSnd}|jdtjtj	|j
|f�|j�ddl}d|_tS(NRs==== No Subprocess ====sPython %s on %s
%s
%si�(RRjRNR�R�RiRR�tversionR�t	COPYRIGHTR�tTkinterRt
_default_rootRj(R/tnosubtclientR�((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s

	
	cCs'|js
dSt|_|jj�dS(N(treadingRjt_stop_readline_flagR�tquit(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s		cCs|j}zd|_|jj�Wd||_X|jrFt|_dS|jjdd�}t|�dkrvd}nt|t	�r�ddl
m}y|j|j
�}Wq�tk
r�q�Xn|j�|jr�|_ts��q�|jrd|_d}n|S(	NiRR�send-1cis
i�(R@(R�R�tmainloopR�RiR3RQRuREtunicodeR(R@RHRIRJRRkRjR
t	endoffile(R/R)RR@((s%/sys/lib/python2.7/idlelib/PyShell.pytreadlines4		
			

					cCstS(N(Rj(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytisatty3scCs�y |jjddd�rdSWnnX|jp9|jsd|j�|jjd�|j�dSd|_d|_	|jr�|jj
r�|jj�r�|jj�q�|jj
�n|jr�|jj�ndS(Ns	sel.firsts!=ssel.lastsKeyboardInterrupt
R�ii(R3R�R�R�RRNRR�R�RkR�R�R�R�R�R�(R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR�6s&

			cCs�|jr|jrdS|jjddd�oD|jjddd�sKdS|jsk|j�|j�nd|_d|_|jj	�dS(NR�s==RSsend-1ciiR�(
R�R�R3R�RR�RkR�R�R�(R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Ls	

		
cCs@|jr/|jjdd�|jjd�n
|j|�dS(NRSs
R�(R�R3RSRPtnewline_and_indent_event(R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR�[s
	
c	Cs�|jr|jrdSyN|jjdd�}|rd|jjddd�rd|j||�dSnWnnX|jjddd�r�|jjd	d�}|r�jjdd|d
�r�j|jj|d|d
�|�dS|jjd	d�}|rK|jjdd
|d�rK|j|jj|d|d
�|�dS|jjdd�}|r�|jj|ddd�r�|j|jj|d
d�|�n|j|jjdd�|�dS|jjddd�r�jjdd�n|jjdd�}|r7|j	�r7|jj
dd�n|jjddd�r`|j|�dS|jjdd�|jr�|jjdd�|jj
d�n
|j|�|jjd	dd�|jj�|jr�jj�n
|j�dS(Ns	sel.firstssel.lasts<=R�R�RSR�siomark linestartR�iisinsert lineends>=R�sinsert linestartsend-1csend-1c linestarts
(R�R�R3RQR�trecallt
tag_prevranget
tag_nextrangeR�R R�R�RSRPRItupdate_idletasksR�R�trunit(R/RWtseltprevtnexttindicesR"((s%/sys/lib/python2.7/idlelib/PyShell.pyR�dsX"'"'&
	

	
cCs�tjdd|�}tjdd|�}|jd�}|jj�z@|jjddd�|jjdd	�|jjd
d�}|j�j	d�r�|j
|�|jjd
d�}n|jjd|dj��t
|�d
kr�tjd|d�jd�}tjd|�jd�}xX|d
D]I}|j|�ra||t
|�}n|jjdd|j��q5WnWd|jjd�|jj�XdS(Ns^\s*\nRs\n\s*$s
R�s1.0R~RSsend-1csinsert linestartt:iis	^([ \t]*)(tretsubRMR3tundo_block_startRYR�RQtrstriptendswithR�RSR RutsearchtgroupRdRPtundo_block_stop(R/R"RWRotprefixtorig_base_indenttnew_base_indentR((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s*

(cCs�|jjdd�}t|�}x.|dkrQ||ddkrQ|d}q$W|dkr||ddkr|d}nx.|dkr�||ddkr�|d}q�W|| }|jj|�}dS(NR�send-1ciis 	s
(R3RQRuRNRK(R/RRPRA((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s# 
#
cCsq|jjr|jj�SytjWn!tjddd|j�dSXddlm	}||j
|j�}dS(NsNo stack traces@There is no stack trace yet.
(sys.last_traceback is not defined)Rdi�(tStackBrowser(RNR�RR�tlast_tracebackRkRlR3tidlelib.StackViewerR�RhR7(R/RWR�tsv((s%/sys/lib/python2.7/idlelib/PyShell.pyR_�s
	
cCs$|jjd�|jjd�dS(NR�R�(R3RP(R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCs|jjdt�dS(s&Callback for Run/Restart Shell Cntl-F6R�N(RNR�Rj(R/RW((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCsk|j�yttj�}Wn
d}nX|jj|�|jjdd�|j�|j	j
�dS(NRRSsend-1c(RRfR�R�R�RR3R�tset_line_and_columnR>t
reset_undo(R/R"((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s


cCs�|jjdd�}|jr1|jj|�n|jjd�dkr_|jjdd�n|jjdd�|j�dtj_	dS(NR�send-1csend-2cs
i(
R3RQR�t
history_storeRSR�R�R�R�t	softspace(R/R6((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s	
cCsry@|jjdd�tj|||d�|jjdd�WnnX|jrnd|_tsnt�qnndS(NR�trightR�i(R3R�RRRkRjR
(R/R"R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s		cCsHy |jjddd�rdSWntk
r4dSXtt|�j�S(Ns	sel.firstR�R�tdisabled(R3R�R�tsuperR�RC(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyRCs
cCs/|jjddd�rdStt|�j�S(NRSR�R�R�(R3R�R�R�RG(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyRG
s(sfileRl(RmRn(sdebugRo(RpRq(RrRs(shelpRu(RrRvN((8R!R�RR�R�RR�RR{RtrunningAsOSXApptidlelib.IdleHistoryRwRR2R�RiR�R�RkR�RR�R�R�R�R�R�R�R�ReRR�R�RR�R�R�R�R�R�R�R�R�R�R�R�R�R_R�R�R�RRRCRG(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�<sl	
2					
																?				
	t
PseudoFilecBs;eZdd�Zed��Zed��Zd�ZRS(cCs(||_||_d|_||_dS(Ni(RxR�R�t	_encoding(R/RxR�RI((s%/sys/lib/python2.7/idlelib/PyShell.pyR2s			cCs|jS(N(R�(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyRIscCsd|jS(Ns<%s>(R�(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�scCstS(N(Rj(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�sN(R!R�RR2tpropertyRIR�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�sR�cBseZd�Zd�ZRS(cCstS(N(Rj(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytwritable%scCs_|jrtd��nt|ttf�sItdt|�j��n|jj	||j
�S(Nswrite to closed filesmust be string, not (tclosedRKREt
basestringt	bytearrayt	TypeErrorR�R!RxRR�(R/R"((s%/sys/lib/python2.7/idlelib/PyShell.pyR(s
	(R!R�R�R(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�#s	R�cBs>eZdd�Zd�Zdd�Zdd�Zd�ZRS(cCs#tj||||�d|_dS(NR(R�R2t_line_buffer(R/RxR�RI((s%/sys/lib/python2.7/idlelib/PyShell.pyR22scCstS(N(Rj(R/((s%/sys/lib/python2.7/idlelib/PyShell.pytreadable6si�cCs|jrtd��n|dkr-d}n+t|t�sXtdt|�j��n|j}d|_|dkr�x�t	r�|j
j�}|s�Pn||7}qyWnSx9t|�|kr�j
j�}|s�Pn||7}q�W|||_|| }|S(Nsread from closed filei�smust be int, not Ri(
R�RKRRERUR�R�R!R�RjRxR�Ru(R/tsizetresultR((s%/sys/lib/python2.7/idlelib/PyShell.pyR89s,					

cCs�|jrtd��n|dkr-d}n+t|t�sXtdt|�j��n|jpm|j	j
�}|dkr�t|�}n|||_|| S(Nsread from closed filei�smust be int, not i(R�RKRRERUR�R�R!R�RxR�Ru(R/R�R((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Ps		
cCs|jj�dS(N(RxR�(R/((s%/sys/lib/python2.7/idlelib/PyShell.pyR�]sN(R!R�RR2R�R8R�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�0s
	
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].
cCs�tat}t}t}d}d}t}y#tjtjdd�\}}WnMtjk
r�}tjj	dt
|��tjj	t�tjd�nXx.|D]&\}	}
|	dkr�|
}t}n|	dkr�}t}n|	dkr�}n|	dkr$tj
j	t�tj�n|	d	kr9t}n|	d
krNtan|	dkr�|
}tjj|�rundG|GHtj�t}n|	d
kr�t}t}n|	dkr�|
t_t}q�q�W|r�ddkr�jj�}t}nx=tttj��D]&}tjjtj|�tj|<qW|ri|ddkridg|dt_n�r�dg|t_n�|r�|g|t_n�|r"t}g}x'|D]}
|jtjj|
��q�Wxy|D]=}tjj|�}|tjkr�tjjd|�q�q�Wn1tj�}|tjkrStjjd|�ntjddddd�}|pw|}|p�|}tdd�at t�tj!�t"t�a#t$j%tt#�|r(|p�|s(x4|D]+}
t#j&|
�dkr�j'|
�q��|s%t#j(�q%q(n|rlt#j)�}|sDdSt$j*�rlt#j+rl|j,j-�qlnt#j.}|r�|j/�n|r�j0j1d�p�tj0j1d�}
|
r�jj|
�r�j2j3|
�q�|r�s�rQ|j2j4dtjf�|r%|j2j5|�qQ|rQ|j2j6|�|j2j3|�qQnt$j7t�}|r�|j2j4dj8d|df��nxt#j9r�tj:�q�Wtj;�dS(Nisc:deihnr:st:s
Error: %s
is-cs-ds-es-hs-is-ns-rsNo script file: s-ss-tit-RR�R�seditor-on-startupR�R�t	classNametIdletIDLESTARTUPt
PYTHONSTARTUPsbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
sprint('s')(<RjRjRiRtgetoptR�targvR�R�RRft	usage_msgtexitR�R9R:RsR�R�R�R8R|RutabspathRLtdirnameRStgetcwdR	R�R|RhRR}R�R7RtsetupAppRbRXtnewR8R�tdictR�tlowerRMR�tenvironRQRNR5RR7RNttkVersionWarningR;tinversedictR�tdestroy(tenable_shelltenable_editRQtcmdtscripttstartuptoptsRARTtotaRPtpathxRtdirt
edit_startRxttkversionwarning((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s�#			
			
			
	$




	
	%R�(IR9tos.pathR�R}R�R�R�R�R�t	tracebackRFR>RR=RR�RR�tImportErrorRR�Rktidlelib.EditorWindowRRtidlelib.FileListRtidlelib.ColorDelegatorRtidlelib.UndoDelegatorRtidlelib.OutputWindowRtidlelib.configHandlerR	R(R
RRR
Rt
ascii_letterstdigitsRRR�R�tsignalRRRRRtshowwarningR#Rt
checkcacheR+R,R�R�R�t	RPCClientR�R�R�t
TextIOBaseR�R�R�R�R�R!R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyt<module>s�



	
			���
d	�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].