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

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


�`^c@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZmZyddlTWn+ek
r�ejdIJejd�nXddlZddlmZmZddlmZdd	lmZdd
lmZddl m!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/m0Z0Wnek
r
dZ0nXeja1ddl2Z2e3d�Z4e3e3d�Z5e3a6d�Z7e7e8�e3ej9d�Z:e:e_9defd��YZ;defd��YZ<defd ��YZ=d!efd"��YZ>d#e&j?fd$��YZ@d%efd&��YZAd'e!fd(��YZBd)ejCfd*��YZDd+eDfd,��YZEd-eDfd.��YZFd/ZGd0�ZHeId1kr�ejJd1ejJd'<eH�ne7eK�dS(2i�N(tInteractiveInterpreter(tpython_versiontsystem(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(tSIGTERMicCsyd}|d||f7}|dkr;tj||�}n|j�}|r^|d|7}n|d|j|f7}|S(sFormat warnings the IDLE way.s!
Warning (from warnings module):
s  File "%s", line %s
s    %s
s%s: %s
N(tNonet	linecachetgetlinetstript__name__(tmessagetcategorytfilenametlinenotlinets((s%/sys/lib/python2.7/idlelib/PyShell.pytidle_formatwarning8scCsf|dkrt}ny3|jt||||d|��|jd�Wnttfk
ranXdS(sShow Idle-format warning (after replacing warnings.showwarning).

    The differences are the formatter called, the file=None replacement,
    which can be None, the capture of the consequence AttributeError,
    and the output of a hard-coded prompt.
    Rs>>> N(Rtwarning_streamtwriteRtAttributeErrortIOError(RRRRtfileR((s%/sys/lib/python2.7/idlelib/PyShell.pytidle_showwarningEs		cCsL|r*tdkrHtjatt_qHntdk	rHtt_dandS(s>Replace warning.showwarning with idle_showwarning, or reverse.N(t_warnings_showwarningRtwarningstshowwarningR#(tcapture((s%/sys/lib/python2.7/idlelib/PyShell.pytcapture_warningsXs		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_checkcachegs	
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_hook�s
(tbreakpointsRt__init__ttexttbindtset_breakpoint_heretclear_breakpoint_heretflistt
open_shelltostpathtjoinR
t
GetUserCfgDirtbreakpointPathtiotfilename_change_hooktset_filename_change_hookRR2(R4targsR5((s%/sys/lib/python2.7/idlelib/PyShell.pyR7�s		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(
R8RCRttag_addR6tindext
ValueErrortappendR<tpyshelltinterptdebuggerR:(R4RR8Rtitdebug((s%/sys/lib/python2.7/idlelib/PyShell.pytset_breakpoint�s	
cCsU|j}|jj}|s)|j�dStt|jd���}|j|�dS(Ntinsert(R8RCRtbelltinttfloatRORW(R4teventR8RR((s%/sys/lib/python2.7/idlelib/PyShell.pyR:�s	
cCs�|j}|jj}|s)|j�dStt|jd���}y|jj|�WnnX|j	ddd�y&|j
jjj
}|j||�WnnXdS(NRXRMsinsert linestartsinsert lineend +1char(R8RCRRYRZR[ROR6tremovet
tag_removeR<RRRSRTR;(R4R\R8RRRV((s%/sys/lib/python2.7/idlelib/PyShell.pyR;�s"	
cCs�|jr~|j}|jj}|s2|j�dSg|_|jddt�y#|jjj	j
}|j|�Wq~q~XndS(NRMs1.0(R6R8RCRRYR^tENDR<RRRSRTtclear_file_breaks(R4R8RRV((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(R6RCRtopenRBt	readlinesR!t
startswithRtupdate_breakpointststrtgetattrtroottFalsetTrueRdttkMessageBoxt	showerrorR8(R4tbreaksRtold_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(NRaRci(R8R,RCRRR>R?tisfileRBRgRhRitevaltlenRW(R4RRtRtbreakpoint_linenumberstbreakpoint_linenumber((s%/sys/lib/python2.7/idlelib/PyShell.pyR2s


cCs4|j}|jd�}|j|�}||_dS(s3Retrieves all the breakpoints in the current windowRMN(R8t
tag_rangestranges_to_linenumbersR6(R4R8trangestlinenumber_list((s%/sys/lib/python2.7/idlelib/PyShell.pyRjs	cCs�g}x�tdt|�d�D]f}tt||j��}tt||dj��}x'||kr�|j|�|d7}q^WqW|S(Niii(trangeRzRZR[tstringRQ(R4RRtRORtend((s%/sys/lib/python2.7/idlelib/PyShell.pyR~s
cCs|j�tj|�dS(s7Extend base method - clear breaks when module is closedN(R`Rt_close(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�+s
(RGs<<cut>>srmenu_check_cut(RIs<<copy>>RJ(RKs	<<paste>>srmenu_check_pasteN(sSet Breakpoints<<set-breakpoint-here>>N(sClear Breakpoints<<clear-breakpoint-here>>N(Rt
__module__t__doc__R7Rtrmenu_specsRWR:R;R`RwR2RjR~R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR1~s 						/			tPyShellFileListcBs&eZdZeZdZdd�ZRS(s8Extend base class: IDLE supports a shell and breakpointscCsQ|jr|jjj�n.t|�|_|jrJ|jj�sJdSn|jS(N(RRttoptwakeuptPyShelltbeginR(R4R\((s%/sys/lib/python2.7/idlelib/PyShell.pyR=:s		N(RR�R�R1RRRRR=(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�1stModifiedColorDelegatorcBs2eZdZd�Zd�Zd�Zd�ZRS(s8Extend base class: colorizer for the shell window itselfcCstj|�|j�dS(N(RR7tLoadTagDefs(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR7Hs
cCs7|jddd�|jddd�tj|�dS(NtTODOs1.0tiomarktSYNC(R^RNRtrecolorize_main(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�LscCs�tj|�tjddd�}|jjiidd6dd6d6tj|d�d6tj|d�d6tj|d	�d	6�dS(
NtmaintThemetnamet
backgroundt
foregroundtstdintstdouttstderrtconsole(RR�R
t	GetOptionttagdefsR,RtGetHighlight(R4ttheme((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Qs
cCs+x$|jD]}|j|dd�q
WdS(NR�R�(R�R^(R4ttag((s%/sys/lib/python2.7/idlelib/PyShell.pytremovecolors[s(RR�R�R7R�R�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Es
			
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�(tdelegatetcompareRYtTclErrorRRX(R4ROtcharsttags((s%/sys/lib/python2.7/idlelib/PyShell.pyRXcs

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

N(RR�R�RRXR�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�`s	tMyRPCClientcBseZd�ZRS(cCs
t�dS(s0Override the base class - just re-raise EOFErrorN(tEOFError(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyt
handle_EOFxs(RR�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�vstModifiedInterpretercBsFeZd�ZdZdZdZd�Zd�Zd�Z	e
d�Zd�Zd�Z
d�Zd�Ze
d	�ZdZd
�ZdZd�Zd�Zd
�Zd�ZdZd�Zdd�Zd�Zd�Zd�Zdd�Zd�Zd�Z d�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__RR7Rtsave_warnings_filtersRnt
restartingtsubprocess_arglisttPORTtporttcompiletcompilertflagstoriginal_compiler_flags(R4R�R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR7s					cCsL|jdkr!|j�|_n|j}tjtjtj|�|_dS(N(	R�Rtbuild_subprocess_arglistR>tspawnvtP_NOWAITR�t
executabletrpcpid(R4RF((s%/sys/lib/python2.7/idlelib/PyShell.pytspawn_subprocess�s	cCs�gtjD]}d|^q
}dddkr@|jd�ntjdddd	td
d�}tdkr}d
|f}n
d|f}tjd dkr�dtjkr�dtj}n	tj}|g|d|t	|j
�gS(Ns-Wiiis-QnewR�tGeneralsdelete-exitfunctdefaultttypetboolsidlelib.PyShells&__import__('idlelib.run').run.main(%r)s__import__('run').main(%r)itwint s"%s"s-c(R�twarnoptionsRQR
R�RnRtplatformR�RkR�(R4RRbt	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�R<RRStwith_cwd( tHOSTR�R�ttimetsleepR�trpcclttsocketterrortdisplay_port_binding_errorRtlistening_socktgetsocknameR�t
setsockoptt
SOL_SOCKETtSO_REUSEADDRR�t
settimeouttacceptttimeouttdisplay_no_subprocess_errortregisterR�R�R�R�R<Rt
transfer_pathRotpoll_subprocess(R4taddrRURv((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
iiRcs	 RESTART trestarttleft(!R�R�RotgetdebuggerRtclose_subprocess_debuggertclosetunix_terminateR�t	executingRnR�R�R�R�R�RR�t
stop_readlineR8R�Rt
showpromptRZtwidthtmark_settmark_gravitytrestart_subprocess_debuggertload_breakpointsR�R�R�R�(R4R�RVR�t
was_executingRvthalfbartgui((s%/sys/lib/python2.7/idlelib/PyShell.pytrestart_subprocess�sJ		

			






	cCs|jjdddi�dS(Ntexectinterrupt_the_server((R�t
remotecall(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyt__request_interruptscCstjd|j�j�dS(Nttarget(t	threadingtThreadt'_ModifiedInterpreter__request_interrupttstart(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytinterrupt_subprocessscCsp|jdk	r(|jjj|j�ny|jj�Wntk
rLnX|j�t	|j_
d|_dS(N(t_afteridRR�R8tafter_cancelR�R�R R�RnR�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytkill_subprocesss

cCsnttd�rjytj|jt�Wntk
r:dSXytj|jd�Wqjtk
rfdSXndS(s;UNIX: make sure subprocess is terminated and collect statustkillNi(thasattrR>RR�RtOSErrortwaitpid(R4((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(R4R�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�R!tKeyboardInterruptR�tclosingR�tresetoutputR�treprtgetvartremote_stack_viewerR�t
__stderr__tendexecutingR R8taftertpollintervalR�R(R4tclttresponsethowtwhatR�terrmsg((s%/sys/lib/python2.7/idlelib/PyShell.pyR�0s@	
	
cCs
||_dS(N(RT(R4RT((s%/sys/lib/python2.7/idlelib/PyShell.pytsetdebuggerXscCs|jS(N(RT(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�[scCs|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�R8RR(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytopen_remote_stack_viewer^s
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�tstackviewerR<(tScrolledCanvastTreeNodeR�R�R�tnormalR�tbgthighlightthicknessitexpanditfilltboth(sflist(tidlelibR#R�tremotequeueRR�RmRYtStubObjectTreeItemtidlelib.TreeWidgetR%R&tToplevelR
R�R�tframetpacktcanvasR*(R4R#toidtitemR%R&R�R�R�tsctnode((s%/sys/lib/python2.7/idlelib/PyShell.pyRksicCs#|j|�}|j||�dS(s1Like runsource() but assumes complete exec sourceN(tstuffsourcetexecfile(R4tsourceR((s%/sys/lib/python2.7/idlelib/PyShell.pyt
execsource~scCs�|dkr$t|d�j�}nyt||d�}Wnattfk
r�|jj�|jj}|dIJ|dIJt	j
||�|jj�nX|j|�dS(sExecute an existing fileRaR�s *** Error in script or command!
s"Traceback (most recent call last):N(
RRgtreadR�t
OverflowErrortSyntaxErrorR�RR�RtshowsyntaxerrorR�truncode(R4RR;tcodettkerr((s%/sys/lib/python2.7/idlelib/PyShell.pyR:�s


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(R9tmoreR%tfiltersR�tfilterwarningst
SyntaxWarningt
isinstancettypestUnicodeTypeR-REtencodetencodingtUnicodeErrorR�RRRt	runsourceR(R4R;RRE((s%/sys/lib/python2.7/idlelib/PyShell.pyRP�s"	




cCsSd|j}|jd|_|jd�}t|�dd||ftj|<|S(s"Stuff source in the filename caches<pyshell#%d>is
i(tgidtsplitRzRR)(R4R;RRt((s%/sys/lib/python2.7/idlelib/PyShell.pyR9�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(R4R((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 charsRs
 wordstartsSyntaxError: %s
N(
R�R8tunpackerrorRNtseetgett
IDENTCHARSRRRkRR@R�(
R4RR8tstufftmsgRtoffsetRtpostchar((s%/sys/lib/python2.7/idlelib/PyShell.pyR@�s$


c
Cs�tj�\}}}|tk}|rey+|\}\}}}}	|sQd}nWqed}qeXn|r{||||	fSdSdS(Ni(R�texc_infoR?R(
R4R�tvaluettbtokRYtdummy_filenameRRZR((s%/sys/lib/python2.7/idlelib/PyShell.pyRT�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(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyRc�s



cCsFtj}x6|j�D](}|d |ddkr||=qqWdS(Nii�s<>(RR)tkeys(R4tcR/((s%/sys/lib/python2.7/idlelib/PyShell.pyRb�s	cBsQ|jjr|j�dS|jrB|jjdd|fi�n||jUdS(s*Run the code without invoking the debuggeriR�RAi(R�R�tdisplay_executing_dialogR�R.R�(R4RB((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�RAsExit?sDo you want to exit altogether?R�tyestmasters IDLE internal error in runcode()RN(R�R�RSR�RbR�RR%RGRTtbeginexecutingR�t
asyncqueueRtrunR�t
SystemExitRRptaskyesnoR8Rctuse_subprocessR�RtcanceledRnR (R4RBRT((s%/sys/lib/python2.7/idlelib/PyShell.pyRAsR

	





cCs|jjj|�dS(sOverride base class methodN(R�R�R(R4R((s%/sys/lib/python2.7/idlelib/PyShell.pyR4scCs 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.Ri(RpRqR�R8(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�8scCs 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.Ri(RpRqR�R8(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�CscCs tjddd|jj�dS(NsAlready executingsYThe Python Shell window is already executing a command; please wait until it is finished.Ri(RpRqR�R8(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyRgKsN((RR�R7RRR�R�R�R�R�RnR�R�RRR�R�RR�RTR!R�R"RRQR<R:RPR9RSR@RTRcRbRRARR�R�Rg(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�}sH	
			+.				
	&			
										1			R�cBs�eZde�dZeZeZd5d6d7d8d9d:gZe	j
dkrWd;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<d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d<d-�Z/d<d.�Z0d<d/�Z1d0�Z2d1�Z3d=d2�Z4d3�Z5d4�Z6RS(>sPython s ShellR"t_Fileteditt_EditRVt_Debugtoptionst_Optionstwindowst_Windowsthelpt_Helptdarwint_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_llitwrapR\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>>i�(RER�R�R�R�i2(sshellR(,Rot
menu_specsRXR�RSRtTkRtwithdrawR�R	R7Rotusetabstindentwidthtcontext_use_ps1R8t	configureR9tenter_callbacktlinefeed_callbacktcancel_callbackteof_callbackRdttoggle_debuggerttoggle_jit_stack_viewertview_restart_markt
restart_shellR�R�tsave_stdoutR�tsave_stderrR�t
save_stdinR-REtPseudoInputFileRNtPseudoOutputFileR�R}thistoryR(R4R<tmsRmR8RE((s%/sys/lib/python2.7/idlelib/PyShell.pyR7lsP		

				cCstjdt�S(Nt
shell_only(R
t
GetExtensionsRo(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytget_standard_extension_names�scCs
|adS(N(R(R4tstream((s%/sys/lib/python2.7/idlelib/PyShell.pytset_warning_stream�scCstS(N(R(R4((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 idleRitbreak(	R�RpRqR8tset_debugger_indicatorRSR�tclose_debuggert
open_debugger(R4R\tdb((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s		


cCs%|jj�}|jd|�dS(Ns<<toggle-debugger>>(RSR�tsetvar(R4R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCsdS(N((R4R\((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>>> (RSR�R!RR�R�Rtclose_remote_debuggerRR�RR�tps1R�R�(R4R�((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s

	
cCsq|jjr'tj|jj|�}ntj|�}|jj|�|j�dt_|j	�|j
�dS(Ns[DEBUG ON]
>>> (RSR�Rtstart_remote_debuggerR
R!R�R�R�R�R�(R4tdbg_gui((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s
	
cCs|j�d|_dS(sHelper for ModifiedInterpreteriN(RR�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyRj�s
cCs d|_d|_|j�dS(sHelper for ModifiedInterpreteriN(R�RpR�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s		cCsf|jr=tjddddd|j�}|tkr=dSn|j�t|_t|_t	j
|�S(sExtend EditorWindow.close()sKill?s6The program is still running!
 Do you want to kill it?R�R`Rftcancel(R�RptaskokcancelR8RnR�RoRpRRR�(R4R((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s	
		cCs||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�RoRSRR�R�R�R�R�R�R�RR�R<RRR�RR�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s
			cCstS(s8Override EditorWindow method: never remove the colorizer(Ro(R4R((s%/sys/lib/python2.7/idlelib/PyShell.pytispythonsourcescCs|jS(N(tshell_title(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytshort_titless@Type "copyright", "credits" or "license()" for more information.cCs�|j�tr<d}|jj�}|sB|j�tSnd}|jdtjtj	|j
|f�|j�ddl}d|_tS(NR	s==== No Subprocess ====sPython %s on %s
%s
%si�(RRoRSR�R�RnRR�tversionR�t	COPYRIGHTR�tTkinterRt
_default_rootRo(R4tnosubtclientR�((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s

	
	cCs'|js
dSt|_|jj�dS(N(treadingRot_stop_readline_flagR�tquit(R4((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(	NiR	R�send-1cis
i�(RE(R�R�tmainloopR�RnR8RVRzRJtunicodeR-RERMRNRORRpRoRt	endoffile(R4R.RRE((s%/sys/lib/python2.7/idlelib/PyShell.pytreadline(s4		
			

					cCstS(N(Ro(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytisattyEscCs�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(R8R�R�R�RRSRR�R�RpR�R�R�RR�R�(R4R\((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Hs&

			cCs�|jr|jrdS|jjddd�oD|jjddd�sKdS|jsk|j�|j�nd|_d|_|jj	�dS(NR�s==RXsend-1ciiR�(
R�R�R8R�RR�RpR�R�R�(R4R\((s%/sys/lib/python2.7/idlelib/PyShell.pyR�^s	

		
cCs@|jr/|jjdd�|jjd�n
|j|�dS(NRXs
R�(R�R8RXRUtnewline_and_indent_event(R4R\((s%/sys/lib/python2.7/idlelib/PyShell.pyR�ms
	
cCs�|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�RXR�siomark linestartR�iisinsert lineends>=R�sinsert linestartsend-1csend-1c linestarts
(R�R�R8RVR�trecallt
tag_prevranget
tag_nextrangeR�RR�R�RXRURNtupdate_idletasksR�R�trunit(R4R\tseltprevtnexttindicesR((s%/sys/lib/python2.7/idlelib/PyShell.pyR�vsX"'"'&
	

	
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*\nR	s\n\s*$s
R�s1.0R�RXsend-1csinsert linestartt:iis	^([ \t]*)(tretsubRRR8tundo_block_startR^R�RVtrstriptendswithR�RXRRztsearchtgroupRiRUtundo_block_stop(R4RR\Rttprefixtorig_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
(R8RVRzRSRP(R4RRURF((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)Rii�(tStackBrowser(RSR�RR�tlast_tracebackRpRqR8tidlelib.StackViewerR�RmR<(R4R\R�tsv((s%/sys/lib/python2.7/idlelib/PyShell.pyRd�s
	
cCs$|jjd�|jjd�dS(NR�R�(R8RU(R4R\((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCs|jjdt�dS(s&Callback for Run/Restart Shell Cntl-F6R�N(RSR�Ro(R4R\((s%/sys/lib/python2.7/idlelib/PyShell.pyR��scCsk|j�yttj�}Wn
d}nX|jj|�|jjdd�|j�|j	j
�dS(NR	RXsend-1c(RRkR�R�R�RR8R�tset_line_and_columnRCt
reset_undo(R4R((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(
R8RVR�tstoreRXR�R�R�R�t	softspace(R4R;((s%/sys/lib/python2.7/idlelib/PyShell.pyR�s	
cCsry@|jjdd�tj|||d�|jjdd�WnnX|jrnd|_tsnt�qnndS(NR�trightR�i(R8R�R	RRpRoR(R4RR�((s%/sys/lib/python2.7/idlelib/PyShell.pyRs		cCsHy |jjddd�rdSWntk
r4dSXtt|�j�S(Ns	sel.firstR�R�tdisabled(R8R�R�tsuperR�RH(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyRHs
cCs/|jjddd�rdStt|�j�S(NRXR�R�R�(R8R�R�R�RL(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyRLs(sfileRq(RrRs(sdebugRt(RuRv(RwRx(shelpRz(RwR|N((7RR�RR�R�RR�RR�R�R�tidlelib.IdleHistoryR}RR7R�RnR�R�RpR�RR�R�R�R�R�R�R�R�RjRR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RdR�R�R�RRRHRL(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Ssh	
2					
															?				
	t
PseudoFilecBs;eZdd�Zed��Zed��Zd�ZRS(cCs(||_||_d|_||_dS(Ni(R~R�R�t	_encoding(R4R~R�RN((s%/sys/lib/python2.7/idlelib/PyShell.pyR7#s			cCs|jS(N(R�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyRN)scCsd|jS(Ns<%s>(R�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�-scCstS(N(Ro(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�1sN(RR�RR7tpropertyRNR�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�!sR�cBseZd�Zd�ZRS(cCstS(N(Ro(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytwritable7scCs�|jrtd��nt|�tttfkr�t|t�rZtj|dd�}q�t|t�r{tj	|�}q�t|t�r�tj	|�}q�t
dt|�j��n|jj
||j�S(Nswrite to closed filesmust be string, not (tclosedRPR�R�Rkt	bytearrayRJt__getslice__Rt__str__t	TypeErrorRR~RR�(R4R((s%/sys/lib/python2.7/idlelib/PyShell.pyR:s	(RR�R�R(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�5s	R�cBs>eZdd�Zd�Zdd�Zdd�Zd�ZRS(cCs#tj||||�d|_dS(NR	(R�R7t_line_buffer(R4R~R�RN((s%/sys/lib/python2.7/idlelib/PyShell.pyR7LscCstS(N(Ro(R4((s%/sys/lib/python2.7/idlelib/PyShell.pytreadablePsi�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 R	i(
R�RPRRJRZR�R�RR�RoR~R�Rz(R4tsizetresultR((s%/sys/lib/python2.7/idlelib/PyShell.pyR=Ss,					

cCs�|jrtd��n|dkr-d}n+t|t�sXtdt|�j��n|jpm|j	j
�}|dkr�t|�}n|jdd|�}|dkr�|d}n|||_|| S(Nsread from closed filei�smust be int, not is
i(
R�RPRRJRZR�R�RR�R~R�Rztfind(R4R�Rteol((s%/sys/lib/python2.7/idlelib/PyShell.pyR�js		

cCs|jj�dS(N(R~R�(R4((s%/sys/lib/python2.7/idlelib/PyShell.pyR�zsN(RR�RR7R�R=R�R�(((s%/sys/lib/python2.7/idlelib/PyShell.pyR�Js
	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�tt�tat}t}t}d}d}t}y#tjtjdd�\}}WnMtjk
r�}tj	j
dt|��tj	j
t�tj
d�nXx.|D]&\}	}
|	dkr�|
}t}n|	dkr�}t}n|	dkrt}n|	dkr.tjj
t�tj
�n|	d	krCt}n|	d
krXtan|	dkr�|
}tjj|�rndG|GHtj
�t}n|	d
kr�t}t}n|	dkr�|
t_t}q�q�W|r|ddkrtjj�}t}nx=tttj��D]&}tjjtj|�tj|<qW|rs|ddkrsdg|dt_n�r�dg|t_n�|r�|g|t_n�|r,t}g}x'|D]}
|jtjj|
��q�Wxy|D]=}tjj|�}|tjkr�jjd|�q��n1tj�}|tjkr]tjjd|�ntjddddd�}|p�|}|p�|}tdd�a tjj!tjjt"�d�}t#�dkr�jj!|d�}t j$d|�n�t%dkr�t%dkrdnd }gd-D]%}tjj!|d$||f�^q#}g|D]}t&d%|�^qU}t j'j(d&d'tt �d(|�nt)t �t j*�t+t �a,t-j.t t,�|r'|p�|s'x4|D]+}
t,j/|
�dkr�|j0|
�q�q�W|s$t,j1�q$q'n|rkt,j2�}|sCdSt-j3�rtt,j4rt|j5j6�qtn	t,j7}|r�|j8�n|r�tj9j:d)�p�tj9j:d*�}
|
r�tjj|
�r�|j;j<|
�q�n|s�rJ|j;j=d+tjf�|r|j;j>|�q|r|j;j?|�|j;j<|�qn5|rt-j@t �}|r|j;j=d,|�qnxt,jAr�t jB�q�Wt jC�tt�dS(.Nisc:deihnr:st:s
Error: %s
is-cs-ds-es-hs-is-ns-rsNo script file: s-ss-tit-R	R�R�seditor-on-startupR�R�t	classNametIdletIconstWindowssidle.icoR�g!@g333333!@s.pngs.gifii i0s	idle_%d%sR"twmt	iconphotos-defaulttIDLESTARTUPt
PYTHONSTARTUPsbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
sprint('%s')(ii i0(DR(RoRoRnRtgetoptR�targvR�R�RRkt	usage_msgtexitR�R>R?RxR�R�R�R=R�RztabspathRQtdirnameRXtgetcwdR
R�R�RmR@t__file__Rt
wm_iconbitmapt	TkVersiont
PhotoImagettktcallRR�R�R<RtsetupAppRgR]tnewR=tisAquaTktdictR�tlowerRRR�tenvironRVRSR:RR<RSttkVersionWarningtinversedictR�tdestroy(tenable_shelltenable_editRVtcmdtscripttstartuptoptsRFRYtotaRUtpathxRtdirt
edit_startticondirticonfiletextR�t	iconfilesticonsR~ttkversionwarning((s%/sys/lib/python2.7/idlelib/PyShell.pyR��s�
#			
			
			
	$


!/"%

	
	
R�(LR>tos.pathR�R�R�R�R�R�R�t	tracebackRKRCRRBRR�RRR�tImportErrorRR�Rptidlelib.EditorWindowRRtidlelib.FileListRtidlelib.ColorDelegatorRtidlelib.UndoDelegatorRtidlelib.OutputWindowR	tidlelib.configHandlerR
R-RRR
RRt
ascii_letterstdigitsRWR�R�tsignalRRR%RRR#R$R(Rot
checkcacheR0R1R�R�R�t	RPCClientR�R�R�t
TextIOBaseR�R�R�R�R�RR�Rn(((s%/sys/lib/python2.7/idlelib/PyShell.pyt<module>s�



		
	���g	�


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.