Viewing File: /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/IOBinding.cpython-35.opt-1.pyc



YfwP@sddlZddlmZddlZddlZddlZddlZddlZddljZ	ddl
jZddl
mZddlZddlmZejrdZnZy#ddlZejejdWneejfk
rYnXdZejdkrCy!ejd	ZejeWnek
r?YnXnyAejej ZedkpmedkrvdZejeWnue!e"efk
ry?ejd	ZedkpedkrdZejeWne#efk
rYnXYnXej$ZeZej%d
ej&Z'ej%dej&Z(dd
Z)GdddZ*ddZ+e,dkrddl-Z-e-j.dddddddl/m0Z0e0e+dS)N)BOM_UTF8)	askstring)idleConfzutf-8asciiwin32z&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)cCst|tr!|jd}n|}d|krR|jdddd}n4d|kr}|jdddd}n	|g}xA|D]5}tj|}|dk	rPtj|sdSqWdS|jd}ytj	|Wn"t
k
rt
d|YnX|S)aVReturn the encoding declaration according to PEP 263.

    When checking encoded data, only the first two lines should be passed
    in to avoid a UnicodeDecodeError if the rest of the data is not unicode.
    The first two lines would contain the encoding specification.

    Raise a LookupError if the encoding is declared but unknown.
    z
iso-8859-1
N
rzUnknown encoding: )
isinstancebytesdecodesplit	coding_rematchblank_regroupcodecslookupLookupError)datalinesZlstlinernamer6/opt/alt/python35/lib64/python3.5/idlelib/IOBinding.pycoding_specGs*		

rc@seZdZddZddZddZddZd	d
ZdZdd
Z	dZ
dZddZddddZ
dZejeZejZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZdZdZ d:d;d<gZ!e"j#d.krJd/nd0Z$d1d2Z%d3d4d5Z&d6d7Z'd8d9Z(dS)=	IOBindingcCs||_|j|_|jjd|j|_|jjd|j|_|jjd|j|_|jjd|j	|_
d|_|jjd|j|_
dS)Nz<<open-window-from-file>>z<<save-window>>z<<save-window-as-file>>z<<save-copy-of-window-as-file>>z<<print-window>>)editwintextbindopen_IOBinding__id_opensave_IOBinding__id_savesave_as_IOBinding__id_saveassave_a_copy_IOBinding__id_savecopyfileencodingprint_window_IOBinding__id_print)selfrrrr__init__rs		zIOBinding.__init__cCs|jjd|j|jjd|j|jjd|j|jjd|j|jjd|jd|_d|_d|_dS)Nz<<open-window-from-file>>z<<save-window>>z<<save-window-as-file>>z<<save-copy-of-window-as-file>>z<<print-window>>)	r Zunbindr#r%r'r)r,rfilename_change_hook)r-rrrclose~s		zIOBinding.closecCs
|jjS)N)r	get_saved)r-rrrr1szIOBinding.get_savedcCs|jj|dS)N)r	set_saved)r-flagrrrr2szIOBinding.set_savedcCs|jjdS)N)r
reset_undo)r-rrrr4szIOBinding.reset_undoNcCs
||_dS)N)r/)r-hookrrrset_filename_change_hooksz"IOBinding.set_filename_change_hookcCsc|r-tjj|r-d|_||_n2||_d|_|jd|jr_|jdS)Nr)ospathisdirfilenamedirnamer2r/)r-r:rrrset_filenames			
	zIOBinding.set_filenamecCs|jj}|r|s'|j}n|}|r|jr~t|jddr~|jr~|jr~|j||jq|j|n|jr|jj	dS|jr|j
}|dkr|jj	dS|s|j}n|}|r|j|n
|jj	dS)NZinterpbreakcancel)rflistaskopenfilegetattrr:r1r"loadfiler 	focus_set	maybesave)r-eventZeditFiler?r:replyrrrr"s6	
	


zIOBinding.openz(\r\n)|\n|\rc	CsyLt|d6}|j|j}|jd|j}WdQRXWnHtk
r}z(tjdt|d|jdSWYdd}~XnX|j	||\}}|dkrtjdd|d|jdS|j
j|}|r|jd|_
|j
jd|}|jjd	d
|jd|jjd	||j|j||rx|jd|jjdd	|jjd|j|dS)
Nrbrz	I/O ErrorparentFzDecoding ErrorzFile %s
Failed to Decodez\nz1.0endinsertT)r"readlineseekreadOSErrortkMessageBox	showerrorstrr _decodeeol_researchreol_conventionsubZdeleter<rJr4r2Zmark_setZyviewupdaterecentfileslist)	r-r:f	two_linesr
msgcharsZ	convertedZfirsteolrrrrBs:
	






zIOBinding.loadfilec;Csd}|jtr^y|ddjd}Wntk
rJdSYnXd|_|dfSyt|}Wnctk
r}z.tjdddd	|d
|j	d}WYdd}~Xntk
rdSYnX|ry&t
||}||_|dfSWntk
rYnXy&t
|d}d|_|dfSWntk
rOYnXy&t
|d}d|_|dfSWntk
rYnXy]|jj	jt
dd
dtd
|jj	}|rt
||}d|_|dfSWnttfk
rYnXdS)zCreate a Unicode string.Nzutf-8FBOMtitlezError loading the filemessagez^The encoding '%s' is not known to this Python installation. The file may not display correctlyrHrzSpecify file encodingzwThe file's encoding is invalid for Python 3.x.
IDLE will convert it to UTF-8.
What is the current encoding of the file?ZinitialvalueT)NF)NF)NF)
startswithrrUnicodeDecodeErrorr*rrrOrPr rQrupdaterencoding)r-rYr
r[encrrrrrRsh
		
	

		
	
	
	zIOBinding._decodec	Cs|jrdSd|jpd}tjddd|dtjd|j}|r{d}|jd|jsd	}n|dkrd	}nd
}|jj|S)Nyesz&Do you want to save %s before closing?zthis untitled documentr^z
Save On Closer_defaultrHr>no)r1r:rOZaskyesnocancelZYESr r$rC)r-r_confirmrFrrrrD>s&		
		
zIOBinding.maybesavecCso|js|j|nE|j|jr^|jdy|jjWntk
r]YnX|jjdS)NTr=)	r:r&	writefiler2rstore_file_breaksAttributeErrorr rC)r-rErrrr$Ts	


zIOBinding.savecCs|j}|ra|j|ra|j||jdy|jjWntk
r`YnX|jj|j	|dS)Nrr=)
asksavefilerir<r2rrjrkr rCrW)r-rEr:rrrr&as




zIOBinding.save_ascCs=|j}|r|j||jj|j|dS)Nr=)rlrir rCrW)r-rEr:rrrr(os


zIOBinding.save_a_copycCs|j|jjdd}|jdkrC|jd|j}|j|}y.t|d}|j|WdQRXdSWnHtk
r}z(t	j
dt|d|jdSWYdd}~XnXdS)	Nz1.0zend-1cr	wbTz	I/O ErrorrHF)fixlastliner getrUreplaceencoder"writerNrOrPrQ)r-r:r r[rXrZrrrriws

zIOBinding.writefilec#Cst|tr|S|jdkr3t|jdSy|jdSWntk
rXYnXyt|}d}Wn1tk
r}z|}d}WYdd}~Xn
X|sd}|ry|j|SWntk
rd|}YnXtj	dd|d|j
t|jdS)Nr]zutf-8rzInvalid encoding '%s'z	I/O Errorz%s.
Saving as UTF-8rH)rr
r*rrqUnicodeErrorrrrOrPr )r-r[rdZfailedrZrrrrqs4




zIOBinding.encodecCs5|jjd}|dkr1|jjdddS)Nzend-2cr	zend-1c)r rorJ)r-crrrrnszIOBinding.fixlastlinec	Cstjdddddtjd|j}|sA|jjdSd}|j}|rb|j}|su|dkrtjdd	\}}|}t	j
||j|st	j|dSt	j
}d
}|dkrtjdd
d}	|	d}	n*|dkr!tjdd
d}	nd}|r|	tj|}	t	j|	d}
|
jj}|
j
}|rd||}|rdt|	|}tjd|d|jn#d|}
tjd|
d|j|rt	j|dS)Nr^ZPrintr_zPrint to Default PrinterrfrHr=prefixZ	IDLE_tmp_TposixmainZGeneralzprint-command-posixz 2>&1ntzprint-command-winFrz#Printing failed (exit status 0x%x)
zPrinting command: %s
zPrint statusz-Printing is not enabled for this platform: %s)rOZaskokcancelZOKr rCr1r:tempfileZmkstempr7r0riunlinkrrZ	GetOptionshlexZquotepopenrMstripreprrPZshowinfo)r-rErhZtempfilenameZsavedr:ZtfdplatformZ
printPlatformZcommandpipeoutputZstatusr_rrrr+sX		
	

		


zIOBinding.print_windowPython files
*.py *.pywTEXT
Text files*.txt	All files*darwinz.pyrcCs^|jd\}}|js?tjd|jd|j|_|jjd|d|}|S)Nr"rH	filetypes
initialdirinitialfile)defaultfilename
opendialogtkFileDialogZOpenr rshow)r-dirbaser:rrrr@s	zIOBinding.askopenfiler"cCsk|jrtjj|jS|jr2|jdfSytj}Wntk
r\d}YnX|dfSdS)Nr)r:r7r8rr;getcwdrN)r-modepwdrrrrs		

zIOBinding.defaultfilenamecCsg|jd\}}|jsHtjd|jd|jd|j|_|jjd|d|}|S)Nr$rHrdefaultextensionrr)r
savedialogrZSaveAsr rrr)r-rrr:rrrrls				zIOBinding.asksavefilecCs |jjr|jj|dS)z-Update recent file list on all editor windowsN)rr?Zupdate_recent_files_list)r-r:rrrrW
szIOBinding.updaterecentfileslist)rrr)rrr)rr))__name__
__module____qualname__r.r0r1r2r4r/r6r:r;r<r"ZeolrecompilerSr7lineseprUrBrRrDr$r&r(rirqrnr+rrrsysrrr@rrlrWrrrrrpsD,	$D
'2	
rcCsddlm}m}||}|jdttttjd|j	\}}}}|j	d||dfGddd}||}	|	j
|	j||	}
t|
dS)	Nr)ToplevelTextzTest IOBindingz[x+]z+%d+%dc@s|eZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZdS)z_io_binding.<locals>.MyEditWincSs||_d|_|jjd|j|jjd|j|jjd|j|jjd|j|jjd|jdS)Nz<Control-o>z<Control-p>z<Control-s>z<Alt-s>z<Control-c>)r r?r!r"printr$saveassavecopy)r-r rrrr.s		z'_io_binding.<locals>.MyEditWin.__init__cSsdS)Nrr)r-rrrr1"sz(_io_binding.<locals>.MyEditWin.get_savedcSsdS)Nr)r-r3rrrr2#sz(_io_binding.<locals>.MyEditWin.set_savedcSsdS)Nr)r-rrrr4$sz)_io_binding.<locals>.MyEditWin.reset_undocSs|jjddS)Nz<<open-window-from-file>>)r event_generate)r-rErrrr"%sz#_io_binding.<locals>.MyEditWin.opencSs|jjddS)Nz<<print-window>>)r r)r-rErrrr'sz$_io_binding.<locals>.MyEditWin.printcSs|jjddS)Nz<<save-window>>)r r)r-rErrrr$)sz#_io_binding.<locals>.MyEditWin.savecSs|jjddS)Nz<<save-window-as-file>>)r r)r-rErrrr+sz%_io_binding.<locals>.MyEditWin.saveascSs|jjddS)Nz<<save-copy-of-window-as-file>>)r r)r-rErrrr-sz'_io_binding.<locals>.MyEditWin.savecopyN)rrrr.r1r2r4r"rr$rrrrrr	MyEditWinsr)
Ztkinterrrr^listmapintrrZgeometryZpackrCr)rHrrrootwidthZheightxyrr rrrr_io_bindings
3

r__main__zidlelib.idle_test.test_iomenu	verbosityr
exitF)run)1rrr7rr|rrzZtkinter.filedialogZ
filedialogrZtkinter.messageboxZ
messageboxrOZtkinter.simpledialogrZidlelibZidlelib.configHandlerrZtestingrcZlocale	setlocaleLC_CTYPEImportErrorErrorZ
locale_decoderZgetdefaultlocaleZlocale_encodingrrnl_langinfoCODESET	NameErrorrk
ValueErrorlowerrASCIIrrrrrrZunittestrwZidlelib.idle_test.htestrrrrr<module>sf		

)$
Back to Directory File Manager