<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 fP                 @   s  d dl Z d dl mZ d dlZd dlZd dlZd dlZd dlZd dljZ	d dl
jZd dlmZ d dlZd dlmZ ejr~dZn yd dlZejejd W n eejfk
r   Y nX dZejdkryej d	 Ze je W n ek
r   Y nX ny2ejej ZedksedkrdZe je W nj e!e"efk
r   y2ej d	 Zedks`edkrddZe je W n e#efk
r   Y nX Y nX ej$ ZeZej%d
ej&Z'ej%dej&Z(dd Z)G dd dZ*dd Z+e,dkrd dl-m.Z. e.dddd d dl/m0Z0 e0e+ dS )    N)BOM_UTF8)	askstring)idleConfzutf-8 asciiZwin32   z&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)c             C   s   t | tr| jd}n| }d|kr8|jdddd }n$d|krV|jdddd }n|g}x2|D ]&}tj|}|dk	rzP tj|sbdS qbW dS |jd}ytj	| W n  t
k
r   t
d| Y nX |S )aV  Return 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r   zUnknown encoding: )
isinstancebytesdecodesplit	coding_rematchblank_regroupcodecslookupLookupError)datalinesZlstliner   name r   3/opt/alt/python36/lib64/python3.6/idlelib/iomenu.pycoding_specG   s*    	




r   c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdZdd Z	dZ
dZdd Zd:ddZdZejeZejZdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& ZdZdZ d>Z!e"j#d.krd/nd0Z$d1d2 Z%d?d4d5Z&d6d7 Z'd8d9 Z(dS )@	IOBindingc             C   sr   || _ |j| _| jjd| j| _| jjd| j| _| jjd| j| _| jjd| j	| _
d | _| jjd| j| _d S )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)selfr   r   r   r   __init__u   s    

zIOBinding.__init__c             C   sf   | j jd| j | j jd| j | j jd| j | j jd| j | j jd| j d | _d | _ d | _d S )Nz<<open-window-from-file>>z<<save-window>>z<<save-window-as-file>>z<<save-copy-of-window-as-file>>z<<print-window>>)	r   Zunbindr"   r$   r&   r(   r+   r   filename_change_hook)r,   r   r   r   close   s    zIOBinding.closec             C   s
   | j j S )N)r   	get_saved)r,   r   r   r   r0      s    zIOBinding.get_savedc             C   s   | j j| d S )N)r   	set_saved)r,   flagr   r   r   r1      s    zIOBinding.set_savedc             C   s   | j j  d S )N)r   
reset_undo)r,   r   r   r   r3      s    zIOBinding.reset_undoNc             C   s
   || _ d S )N)r.   )r,   hookr   r   r   set_filename_change_hook   s    z"IOBinding.set_filename_change_hookc             C   sF   |rt jj|rd | _|| _n$|| _d | _| jd | jrB| j  d S )Nr   )ospathisdirfilenamedirnamer1   r.   )r,   r9   r   r   r   set_filename   s    
zIOBinding.set_filenamec             C   s   | j j}|rx|s| j }n|}|rd| j rXt| j dd  rX| j rX| j rX|j|| j qt|j| n| jrt| jj	  dS | j r| j
 }|dkr| jj	  dS |s| j }n|}|r| j| n
| jj	  dS )NZinterpbreakcancel)r   flistaskopenfilegetattrr9   r0   r!   loadfiler   	focus_set	maybesave)r,   eventZeditFiler>   r9   replyr   r   r   r!      s6    




zIOBinding.openz(\r\n)|\n|\rc       	      C   s@  y<t |d(}|j |j  }|jd |j }W d Q R X W n6 tk
rr } ztjdt|| jd dS d }~X nX | j	||\}}|d krtjdd| | jd dS | j
j|}|r|jd| _| j
jd|}| jjd	d
 | jd  | jjd	| | j  | j| |r| jd | jjdd	 | jjd | j| dS )Nrbr   z	I/O Error)parentFzDecoding ErrorzFile %s
Failed to Decodez\nz1.0endinsertT)r!   readlineseekreadOSErrortkMessageBox	showerrorstrr   _decodeeol_researchr   eol_conventionsubdeleter;   rI   r3   r1   Zmark_setZyviewupdaterecentfileslist)	r,   r9   f	two_linesr   msgcharsZ	convertedZfirsteolr   r   r   rA      s:    





zIOBinding.loadfilec          :   C   s  d}|j trHy|dd jd}W n tk
r8   dS X d| _|dfS yt|}W nN tk
r } z tjdd| | j	d d}W Y dd}~X n tk
r   dS X |ryt
||}|| _|dfS  tk
r   Y nX yt
|d	}d| _|dfS  tk
r   Y nX yt
|d}d| _|dfS  tk
r4   Y nX y>| jj	j  td
dt| jj	d}|rnt
||}d| _|dfS  ttfk
r   Y nX dS )zCreate a Unicode string.N   zutf-8FBOMzError loading the filez^The encoding '%s' is not known to this Python installation. The file may not display correctly)titlemessagerG   r   zSpecify 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initialvaluerG   T)NF)NF)NF)
startswithr   r   UnicodeDecodeErrorr)   r   r   rN   rO   r   rP   r   updater   encoding)r,   rY   r   r[   encr   r   r   r   rQ      sh    





zIOBinding._decodec             C   sp   | j  rdS d| jpd }tjd|tj| jd}|rPd}| jd  | j  sbd}n|d kr^d}nd}| jj  |S )Nyesz&Do you want to save %s before closing?zthis untitled documentzSave On Close)r^   r_   defaultrG   r=   no)r0   r9   rN   ZaskyesnocancelZYESr   r#   rB   )r,   r_   confirmrE   r   r   r   rC   A  s&    


zIOBinding.maybesavec             C   sZ   | j s| j| n:| j| j rL| jd y| jj  W n tk
rJ   Y nX | jj  dS )NTr<   )	r9   r%   	writefiler1   r   store_file_breaksAttributeErrorr   rB   )r,   rD   r   r   r   r#   W  s    

zIOBinding.savec             C   sf   | j  }|rN| j|rN| j| | jd y| jj  W n tk
rL   Y nX | jj  | j	| dS )Nr   r<   )
asksavefileri   r;   r1   r   rj   rk   r   rB   rW   )r,   rD   r9   r   r   r   r%   d  s    




zIOBinding.save_asc             C   s.   | j  }|r| j| | jj  | j| dS )Nr<   )rl   ri   r   rB   rW   )r,   rD   r9   r   r   r   r'   r  s    


zIOBinding.save_a_copyc             C   s   | j   | jjdd}| jdkr.|jd| j}| j|}y$t|d}|j| W d Q R X dS  tk
r } zt	j
dt|| jd dS d }~X nX d S )	Nz1.0zend-1cr   wbTz	I/O Error)rG   F)fixlastliner   getrT   replaceencoder!   writerM   rN   rO   rP   )r,   r9   r   r[   rX   rZ   r   r   r   ri   z  s    


zIOBinding.writefilec          #   C   s   t |tr|S | jdkr&t|jd S y
|jdS  tk
rD   Y nX yt|}d }W n* tk
r } z|}d }W Y d d }~X n
X |sd}|ry
|j|S  tk
r   d| }Y nX tj	dd| | j
d t|jd S )Nr]   zutf-8r   zInvalid encoding '%s'z	I/O Errorz%s.
Saving as UTF-8)rG   )r   r   r)   r   rq   UnicodeErrorr   r   rN   rO   r   )r,   r[   rd   ZfailedrZ   r   r   r   rq     s4    




zIOBinding.encodec             C   s&   | j jd}|dkr"| j jdd d S )Nzend-2cr   zend-1c)r   ro   rI   )r,   cr   r   r   rn     s    zIOBinding.fixlastlinec             C   sf  t jddt j| jd}|s(| jj  dS d }| j }|r>| j}| sL|d krtjdd\}}|}t	j
| | j|st	j| dS t	j}d}|dkrtjd	d
d}	|	d }	n|dkrtjd	d
d}	nd}|r8|	tj| }	t	j|	d}
|
j j }|
j
 }|rd| | }|rRdt|	 | }t jd|| jd nd| }t jd|| jd |rbt	j| dS )NZPrintzPrint to Default Printer)r^   r_   rf   rG   r<   Z	IDLE_tmp_)prefixTposixmainZGeneralzprint-command-posixz 2>&1ntzprint-command-winFrz#Printing failed (exit status 0x%x)
zPrinting command: %s
zPrint status)rG   z-Printing is not enabled for this platform: %s)rN   ZaskokcancelZOKr   rB   r0   r9   tempfileZmkstempr6   r/   ri   unlinkr   r   Z	GetOptionshlexZquotepopenrL   stripreprrO   Zshowinfo)r,   rD   rh   ZtempfilenameZsavedr9   ZtfdplatformZprintPlatformZcommandpipeoutputZstatusr_   r   r   r   r*     sX    







zIOBinding.print_windowPython files
*.py *.pywTEXT
Text files*.txt	All files*darwinz.pyr   c             C   s<   | j d\}}| js(tj| j| jd| _| jj||d}|S )Nr!   )rG   	filetypes)
initialdirinitialfile)defaultfilename
opendialogtkFileDialogZOpenr   r   show)r,   dirbaser9   r   r   r   r?     s    zIOBinding.askopenfiler!   c             C   sV   | j rtjj| j S | jr$| jdfS ytj }W n tk
rH   d}Y nX |dfS d S )Nr   )r9   r6   r7   r   r:   getcwdrM   )r,   modepwdr   r   r   r     s    

zIOBinding.defaultfilenamec             C   s@   | j d\}}| js,tj| j| j| jd| _| jj||d}|S )Nr#   )rG   r   defaultextension)r   r   )r   
savedialogr   ZSaveAsr   r   r   r   )r,   r   r   r9   r   r   r   rl     s    zIOBinding.asksavefilec             C   s   | j jr| j j| dS )z-Update recent file list on all editor windowsN)r   r>   Zupdate_recent_files_list)r,   r9   r   r   r   rW     s    zIOBinding.updaterecentfileslist)NNr   r   r   r   r   r   r   r   )r   r   r   )r!   ))__name__
__module____qualname__r-   r/   r0   r1   r3   r.   r5   r9   r:   r;   r!   ZeolrecompilerR   r6   lineseprT   rA   rQ   rC   r#   r%   r'   ri   rq   rn   r*   r   r   r   sysr   r   r?   r   rl   rW   r   r   r   r   r   p   sD   
,
$D'2  

r   c       	      C   s   ddl m}m} || }|jd tt| j jddd  \}}|jd||d f  G dd	 d	}||}|j  |j	  ||}t
| d S )
Nr   )ToplevelTextzTest IOBinding+r   z+%d+%d   c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )z_io_binding.<locals>.MyEditWinc             S   s`   || _ d | _| j jd| j | j jd| j | j jd| j | j jd| j | j jd| j d S )Nz<Control-o>z<Control-p>z<Control-s>z<Alt-s>z<Control-c>)r   r>   r    r!   printr#   saveassavecopy)r,   r   r   r   r   r-     s    z'_io_binding.<locals>.MyEditWin.__init__c             S   s   dS )Nr   r   )r,   r   r   r   r0   %  s    z(_io_binding.<locals>.MyEditWin.get_savedc             S   s   d S )Nr   )r,   r2   r   r   r   r1   &  s    z(_io_binding.<locals>.MyEditWin.set_savedc             S   s   d S )Nr   )r,   r   r   r   r3   '  s    z)_io_binding.<locals>.MyEditWin.reset_undoc             S   s   | j jd d S )Nz<<open-window-from-file>>)r   event_generate)r,   rD   r   r   r   r!   (  s    z#_io_binding.<locals>.MyEditWin.openc             S   s   | j jd d S )Nz<<print-window>>)r   r   )r,   rD   r   r   r   r   *  s    z$_io_binding.<locals>.MyEditWin.printc             S   s   | j jd d S )Nz<<save-window>>)r   r   )r,   rD   r   r   r   r#   ,  s    z#_io_binding.<locals>.MyEditWin.savec             S   s   | j jd d S )Nz<<save-window-as-file>>)r   r   )r,   rD   r   r   r   r   .  s    z%_io_binding.<locals>.MyEditWin.saveasc             S   s   | j jd d S )Nz<<save-copy-of-window-as-file>>)r   r   )r,   rD   r   r   r   r   0  s    z'_io_binding.<locals>.MyEditWin.savecopyN)r   r   r   r-   r0   r1   r3   r!   r   r#   r   r   r   r   r   r   	MyEditWin  s   r   )Ztkinterr   r   r^   mapintZgeometryr   ZpackrB   r   )	rG   r   r   rootxyr   r   r   r   r   r   _io_binding  s    
 r   __main__)rw   zidlelib.idle_test.test_iomenur	   F)	verbosityexit)run)1r   r   r6   r   r|   r   rz   Ztkinter.filedialogZ
filedialogr   Ztkinter.messageboxZ
messageboxrN   Ztkinter.simpledialogr   ZidlelibZidlelib.configr   Ztestingrc   Zlocale	setlocaleLC_CTYPEImportErrorErrorZlocale_decoder   ZgetdefaultlocaleZlocale_encodingr   r   nl_langinfoCODESET	NameErrorrk   
ValueErrorlowerr   ASCIIr   r   r   r   r   r   Zunittestrw   Zidlelib.idle_test.htestr   r   r   r   r   <module>   sj   


)   ($
