Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python36/lib64/python3.6/idlelib/__pycache__/iomenu.cpython-36.pyc

3

� f�P�@sddlZddlmZddlZddlZddlZddlZddlZddljZ	ddl
jZddl
mZddlZddlmZejr~dZ�n yddlZejejd�Wneejfk
r�YnXdZejdkr�yej�d	Zeje�Wnek
r�YnXn�y2ejej �Zedk�sedk�rdZeje�Wnje!e"efk
�r�y2ej�d	Zedk�s`edk�rddZeje�Wne#efk
�r�YnXYnXej$�ZeZej%d
ej&�Z'ej%dej&�Z(dd
�Z)Gdd�d�Z*dd�Z+e,dk�rddl-m.Z.e.dddd�ddl/m0Z0e0e+�dS)�N)�BOM_UTF8)�	askstring)�idleConfzutf-8��asciiZwin32�z&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)cCs�t|t�r|jd�}n|}d|kr8|jdd�dd�}n$d|krV|jdd�dd�}n|g}x2|D]&}tj|�}|dk	rzPtj|�sbdSqbWdS|jd�}ytj	|�Wn t
k
r�t
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: )�
isinstance�bytes�decode�split�	coding_re�match�blank_re�group�codecs�lookup�LookupError)�data�linesZlst�liner�name�r�3/opt/alt/python36/lib64/python3.6/idlelib/iomenu.py�coding_specGs*	




rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdZdd
�Z	dZ
dZdd�Zd:dd�Z
dZeje�ZejZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdZdZ d>Z!e"j#d.kr�d/nd0Z$d1d2�Z%d?d4d5�Z&d6d7�Z'd8d9�Z(dS)@�	IOBindingcCsr||_|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>>)�editwin�text�bind�open�_IOBinding__id_open�save�_IOBinding__id_save�save_as�_IOBinding__id_saveas�save_a_copy�_IOBinding__id_savecopy�fileencoding�print_window�_IOBinding__id_print)�selfrrrr�__init__us

zIOBinding.__init__cCsf|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�d|_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>>)	rZunbindr"r$r&r(r+r�filename_change_hook)r,rrr�close�szIOBinding.closecCs
|jj�S)N)r�	get_saved)r,rrrr0�szIOBinding.get_savedcCs|jj|�dS)N)r�	set_saved)r,�flagrrrr1�szIOBinding.set_savedcCs|jj�dS)N)r�
reset_undo)r,rrrr3�szIOBinding.reset_undoNcCs
||_dS)N)r.)r,�hookrrr�set_filename_change_hook�sz"IOBinding.set_filename_change_hookcCsF|rtjj|�rd|_||_n$||_d|_|jd�|jrB|j�dS)Nr)�os�path�isdir�filename�dirnamer1r.)r,r9rrr�set_filename�s
zIOBinding.set_filenamecCs�|jj}|rx|s|j�}n|}|rd|jrXt|jdd�rX|jrX|j�rX|j||j�qt|j|�n|jrt|jj	�dS|j�r�|j
�}|dkr�|jj	�dS|s�|j�}n|}|r�|j|�n
|jj	�dS)NZinterp�break�cancel)r�flist�askopenfile�getattrr9r0r!�loadfiler�	focus_set�	maybesave)r,�eventZeditFiler>r9�replyrrrr!�s6




zIOBinding.openz(\r\n)|\n|\rc	Cs@y<t|d��(}|j�|j�}|jd�|j�}WdQRXWn6tk
rr}ztjdt|�|jd�dSd}~XnX|j	||�\}}|dkr�tjdd||jd�dS|j
j|�}|r�|jd�|_
|j
jd|�}|jjd	d
�|jd�|jjd	|�|j�|j|�|�r|jd�|jjdd	�|jjd�|j|�dS)
N�rbrz	I/O Error)�parentFzDecoding ErrorzFile %s
Failed to Decodez\nz1.0�end�insertT)r!�readline�seek�read�OSError�tkMessageBox�	showerror�strr�_decode�eol_re�searchr�eol_convention�sub�deleter;rIr3r1Zmark_setZyview�updaterecentfileslist)	r,r9�f�	two_linesr�msg�charsZ	convertedZfirsteolrrrrA�s:





zIOBinding.loadfilec:Cs�d}|jt�rHy|dd�jd�}Wntk
r8dSXd|_|dfSyt|�}WnNtk
r�}z tjdd||j	d�d}WYdd}~Xntk
r�dSX|r�yt
||�}||_|dfStk
r�YnXyt
|d	�}d|_|dfStk
�rYnXyt
|d�}d|_|dfStk
�r4YnXy>|jj	j�t
d
dt|jj	d�}|�rnt
||�}d|_|d
fSttfk
�r�YnXdS)zCreate a Unicode string.N�zutf-8F�BOMzError loading the filez^The encoding '%s' is not known to this Python installation. The file may not display correctly)�title�messagerGrzSpecify 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initialvaluerGT)NF)NF)NF)�
startswithrr
�UnicodeDecodeErrorr)rrrNrOrrPr�updater�encoding)r,rYrr[�encrrrrrQ�sh





zIOBinding._decodecCsp|j�rdSd|jpd}tjd|tj|jd�}|rPd}|jd�|j�sbd}n|dkr^d}nd}|jj�|S)N�yesz&Do you want to save %s before closing?zthis untitled documentz
Save On Close)r^r_�defaultrGr=�no)r0r9rNZaskyesnocancelZYESrr#rB)r,r_�confirmrErrrrCAs&


zIOBinding.maybesavecCsZ|js|j|�n:|j|j�rL|jd�y|jj�Wntk
rJYnX|jj�dS)NTr<)	r9r%�	writefiler1r�store_file_breaks�AttributeErrorrrB)r,rDrrrr#Ws

zIOBinding.savecCsf|j�}|rN|j|�rN|j|�|jd�y|jj�Wntk
rLYnX|jj�|j	|�dS)Nrr<)
�asksavefilerir;r1rrjrkrrBrW)r,rDr9rrrr%ds




zIOBinding.save_ascCs.|j�}|r|j|�|jj�|j|�dS)Nr<)rlrirrBrW)r,rDr9rrrr'rs


zIOBinding.save_a_copycCs�|j�|jjdd�}|jdkr.|jd|j�}|j|�}y$t|d��}|j|�WdQRXdStk
r�}zt	j
dt|�|jd�dSd}~XnXdS)	Nz1.0zend-1cr�wbTz	I/O Error)rGF)�fixlastliner�getrT�replace�encoder!�writerMrNrOrP)r,r9rr[rXrZrrrrizs


zIOBinding.writefilec#Cs�t|t�r|S|jdkr&t|jd�Sy
|jd�Stk
rDYnXyt|�}d}Wn*tk
r�}z|}d}WYdd}~Xn
X|s�d}|r�y
|j|�Stk
r�d|}YnXtj	dd||j
d�t|jd�S)Nr]zutf-8rzInvalid encoding '%s'z	I/O Errorz%s.
Saving as UTF-8)rG)rrr)rrq�UnicodeErrorrrrNrOr)r,r[rdZfailedrZrrrrq�s4




zIOBinding.encodecCs&|jjd�}|dkr"|jjdd�dS)Nzend-2crzend-1c)rrorI)r,�crrrrn�szIOBinding.fixlastlinecCsftjddtj|jd�}|s(|jj�dSd}|j�}|r>|j}|sL|dkr�tjdd�\}}|}t	j
|�|j|�s�t	j|�dSt	j
}d}|dkr�tjd	d
d�}	|	d}	n|d
kr�tjd	d
d�}	nd}|�r8|	tj|�}	t	j|	d�}
|
j�j�}|
j
�}|�rd||}|�rRdt|	�|}tjd||jd�nd|}
tjd|
|jd�|�rbt	j|�dS)NZPrintzPrint to Default Printer)r^r_rfrGr<Z	IDLE_tmp_)�prefixT�posix�mainZGeneralzprint-command-posixz 2>&1�ntzprint-command-winF�rz#Printing failed (exit status 0x%x)
zPrinting command: %s
zPrint status)rGz-Printing is not enabled for this platform: %s)rNZaskokcancelZOKrrBr0r9�tempfileZmkstempr6r/ri�unlinkrrZ	GetOption�shlexZquote�popenrL�strip�reprrOZshowinfo)r,rDrhZtempfilenameZsavedr9Ztfd�platformZ
printPlatformZcommand�pipe�outputZstatusr_rrrr*�sX







zIOBinding.print_window�Python files�
*.py *.pyw�TEXT�
Text files�*.txt�	All files�*�darwinz.pyrcCs<|jd�\}}|js(tj|j|jd�|_|jj||d�}|S)Nr!)rG�	filetypes)�
initialdir�initialfile)�defaultfilename�
opendialog�tkFileDialogZOpenrr��show)r,�dir�baser9rrrr?�szIOBinding.askopenfiler!cCsV|jrtjj|j�S|jr$|jdfSytj�}Wntk
rHd}YnX|dfSdS)Nr)r9r6r7rr:�getcwdrM)r,�mode�pwdrrrr��s

zIOBinding.defaultfilenamecCs@|jd�\}}|js,tj|j|j|jd�|_|jj||d�}|S)Nr#)rGr��defaultextension)r�r�)r��
savedialogr�ZSaveAsrr�r�r�)r,r�r�r9rrrrlszIOBinding.asksavefilecCs|jjr|jj|�dS)z-Update recent file list on all editor windowsN)rr>Zupdate_recent_files_list)r,r9rrrrWszIOBinding.updaterecentfileslist)NN�r�r�r��r�r�r��r�r�)r�r�r�)r!))�__name__�
__module__�__qualname__r-r/r0r1r3r.r5r9r:r;r!Zeol�re�compilerRr6�lineseprTrArQrCr#r%r'rirqrnr*r�r�r��sysr�r�r?r�rlrWrrrrrpsD
,
$D
'2

rc	Cs�ddlm}m}||�}|jd�tt|j�jd�dd��\}}|jd||df�Gdd	�d	�}||�}|j�|j	�||�}t
|�dS)
Nr)�Toplevel�TextzTest IOBinding�+rz+%d+%d�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z_io_binding.<locals>.MyEditWincSs`||_d|_|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�dS)Nz<Control-o>z<Control-p>z<Control-s>z<Alt-s>z<Control-c>)rr>r r!�printr#�saveas�savecopy)r,rrrrr-sz'_io_binding.<locals>.MyEditWin.__init__cSsdS)Nrr)r,rrrr0%sz(_io_binding.<locals>.MyEditWin.get_savedcSsdS)Nr)r,r2rrrr1&sz(_io_binding.<locals>.MyEditWin.set_savedcSsdS)Nr)r,rrrr3'sz)_io_binding.<locals>.MyEditWin.reset_undocSs|jjd�dS)Nz<<open-window-from-file>>)r�event_generate)r,rDrrrr!(sz#_io_binding.<locals>.MyEditWin.opencSs|jjd�dS)Nz<<print-window>>)rr�)r,rDrrrr�*sz$_io_binding.<locals>.MyEditWin.printcSs|jjd�dS)Nz<<save-window>>)rr�)r,rDrrrr#,sz#_io_binding.<locals>.MyEditWin.savecSs|jjd�dS)Nz<<save-window-as-file>>)rr�)r,rDrrrr�.sz%_io_binding.<locals>.MyEditWin.saveascSs|jjd�dS)Nz<<save-copy-of-window-as-file>>)rr�)r,rDrrrr�0sz'_io_binding.<locals>.MyEditWin.savecopyN)r�r�r�r-r0r1r3r!r�r#r�r�rrrr�	MyEditWinsr�)Ztkinterr�r�r^�map�intZgeometryrZpackrBr)	rGr�r��root�x�yr�rrrrr�_io_bindings
 r��__main__)rwzidlelib.idle_test.test_iomenur	F)�	verbosity�exit)�run)1rrr6r�r|r�rzZtkinter.filedialogZ
filedialogr�Ztkinter.messageboxZ
messageboxrNZtkinter.simpledialogrZidlelibZidlelib.configrZtestingrcZlocale�	setlocale�LC_CTYPE�ImportError�ErrorZ
locale_decoder�ZgetdefaultlocaleZlocale_encodingrr�nl_langinfo�CODESET�	NameErrorrk�
ValueError�lowerr��ASCIIrrrrr�r�ZunittestrwZidlelib.idle_test.htestr�rrrr�<module>sj


)($


Hacked By AnonymousFox1.0, Coded By AnonymousFox