<!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>

e f=M                 @   st  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 y# d  d l Z e j e j d  Wn e e j f k
 r Yn Xe j   Z d Z e j d k r!y! e j   d Z e  j e  Wn e k
 rYn Xn yD e j e j  Z e d k pKe d k rWd Z n  e  j e  Wnx e e e f k
 ryB e j   d Z e d k pe d k rd Z n  e  j e  Wn e e f k
 rYn XYn Xe j    Z e Z! e j" d e j#  Z$ e j" d	 e j#  Z% d
 d   Z& Gd d   d  Z' d d   Z( e) d k rpd  d l* m+ Z+ e+ e(  n  d S)    N)BOM_UTF8)	askstring asciiwin32   z%^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)c             C   s  t  |  t  r! |  j d  } n |  } d | k rR | j d d  d d  } n4 d | k r} | j d d  d d  } n	 | g } xD | D]8 } t j |  } | d k	 r Pn  t j |  s d Sq Wd S| j d  } y t j	 |  Wn" t
 k
 rt
 d |   Yn 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   6/opt/alt/python34/lib64/python3.4/idlelib/IOBinding.pycoding_specC   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 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: d; d< g Z! e" j# d. k rJd/ n d0 Z$ d1 d2   Z% d3 d4 d5  Z& d6 d7   Z' d8 d9   Z( d S)=	IOBindingc             C   s   | |  _  | 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__n   s    		zIOBinding.__init__c             C   s   |  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   closez   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  |  _ | |  _ n5 | |  _ d  |  _ |  j d  |  j rb |  j   n  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 } | r | s' |  j   } n | } | r |  j  r~ t |  j  d d   r~ |  j r~ |  j   r~ | j | |  j  q | j |  n |  j r |  j j	   n  d S|  j   r |  j
   } | d k r |  j j	   d Sn  | 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  yK t  | d  6 } | j   | j   } | j d  | j   } Wd  QXWnH t k
 r } z( t j d t |  d |  j d SWYd  d  } ~ Xn X|  j	 | |  \ } } | d  k r t j d d | d |  j d S|  j
 j |  } | r| j d  |  _ |  j
 j d |  } n  |  j j d	 d
  |  j d   |  j j d	 |  |  j   |  j |  | r}|  j d  n  |  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subZ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  ra y | d d  j d  } Wn t k
 rJ d SYqa Xd |  _ | d f Sn  y t |  } Wnc t k
 r } z. t j d d d d	 | d
 |  j	  d } WYd d } ~ Xn t k
 r d SYn X| ry& t
 | |  } | |  _ | d f SWqt k
 rYqXn  y& t
 | d  } d |  _ | d f SWn t k
 rUYn Xy& t
 | d  } d |  _ | d f SWn t k
 rYn Xy` |  j j	 j   t d d d t d
 |  j j	 } | rt
 | |  } d |  _ n  | d f SWn t t f k
 rYn Xd S)zCreate a Unicode string.N   zutf-8FBOMtitlezError loading the filemessagez^The encoding '%s' is not known to this Python installation. The file may not display correctlyrG   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initialvalueT)NF)NF)NF)
startswithr   r   UnicodeDecodeErrorr)   r   r   rN   rO   r   rP   r   updater   locale_encoding)r,   rX   r   rZ   encr   r   r   r   rQ      sh    			
				zIOBinding._decodec          	   C   s   |  j    r d Sd |  j p d } t j d d d | d t j d |  j  } | r~ d } |  j d   |  j    s d	 } q n | d  k r d	 } n d
 } |  j j   | S)Nyesz&Do you want to save %s before closing?zthis untitled documentr]   zSave On Closer^   defaultrG   r=   no)r0   r9   rN   ZaskyesnocancelZYESr   r#   rB   )r,   r^   confirmrE   r   r   r   rC   :  s&    			zIOBinding.maybesavec             C   sr   |  j  s |  j |  nH |  j |  j   ra |  j d  y |  j j   Wqa t k
 r] Yqa Xn  |  j j   d S)NTr<   )	r9   r%   	writefiler1   r   store_file_breaksAttributeErrorr   rB   )r,   rD   r   r   r   r#   P  s    	zIOBinding.savec             C   s   |  j    } | rg |  j |  rg |  j |  |  j d  y |  j j   Wqd t k
 r` Yqd Xqg n  |  j j   |  j	 |  d S)Nr   r<   )
asksavefilerh   r;   r1   r   ri   rj   r   rB   rV   )r,   rD   r9   r   r   r   r%   ]  s    zIOBinding.save_asc             C   s@   |  j    } | r" |  j |  n  |  j j   |  j |  d S)Nr<   )rk   rh   r   rB   rV   )r,   rD   r9   r   r   r   r'   k  s    zIOBinding.save_a_copyc             C   s   |  j    |  j j d d  } |  j d k rF | j d |  j  } n  |  j |  } y- t | d   } | j |  Wd  QXd SWnH t k
 r } z( t	 j
 d t |  d |  j d SWYd  d  } ~ Xn Xd  S)	Nz1.0zend-1cr   wbTz	I/O ErrorrG   F)fixlastliner   getrT   replaceencoder!   writerM   rN   rO   rP   )r,   r9   r   rZ   rW   rY   r   r   r   rh   s  s    

zIOBinding.writefilec          #   C   s  t  | t  r | S|  j d k r3 t | j d  Sy | j d  SWn t k
 rX Yn Xy t |  } d  } Wn1 t k
 r } z | } d  } WYd  d  } ~ Xn X| s d } n  | r y | j |  SWq t k
 r d | } Yq Xn  t j	 d d | d |  j
 t | j d  S)Nr\   zutf-8r   zInvalid encoding '%s'z	I/O Errorz%s.
Saving as UTF-8rG   )r   r   r)   r   rp   UnicodeErrorr   r   rN   rO   r   )r,   rZ   rc   ZfailedrY   r   r   r   rp     s4    
	

zIOBinding.encodec             C   s8   |  j  j d  } | d k r4 |  j  j d d  n  d  S)Nzend-2cr   zend-1c)r   rn   rI   )r,   cr   r   r   rm     s    zIOBinding.fixlastlinec          	   C   s  t  j d d d d d t  j d |  j  } | sA |  j j   d Sd  } |  j   } | re |  j } n  | sx | d  k r t j d d	  \ } } | } t	 j
 |  |  j |  s t	 j |  d Sn  t	 j } d
 } | d k rt j d d d  }	 |	 d }	 n* | d k r't j d d d  }	 n d } | r|	 t j |  }	 t	 j |	 d  }
 |
 j   j   } |
 j
   } | rd | | } n  | rd t |	  | } t  j d | d |  j qn# d | } t  j d | d |  j | rt	 j |  n  d S)Nr]   ZPrintr^   zPrint to Default Printerre   rG   r<   prefixZ	IDLE_tmp_T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 statusz-Printing is not enabled for this platform: %s)rN   ZaskokcancelZOKr   rB   r0   r9   tempfileZmkstempr6   r/   rh   unlinkr   idleConfZ	GetOptionshlexZquotepopenrL   stripreprrO   Zshowinfo)r,   rD   rg   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   sa   |  j  d  \ } } |  j sB t j d |  j d |  j  |  _ n  |  j j d | 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   sk   |  j  r t j j |  j   S|  j r2 |  j d f Sy t j   } Wn t k
 r\ d } Yn X| d f Sd  S)Nr   )r9   r6   r7   r   r:   getcwdrM   )r,   modepwdr   r   r   r     s    		zIOBinding.defaultfilenamec             C   sj   |  j  d  \ } } |  j sK t j d |  j d |  j d |  j  |  _ n  |  j j d | d |  } | S)Nr#   rG   r   defaultextensionr   r   )r   
savedialogr   ZSaveAsr   r   r   r   )r,   r   r   r9   r   r   r   rk     s    				zIOBinding.asksavefilec             C   s#   |  j  j r |  j  j |  n  d S)z-Update recent file list on all editor windowsN)r   r>   Zupdate_recent_files_list)r,   r9   r   r   r   rV   	  s    zIOBinding.updaterecentfileslist)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'   rh   rp   rm   r*   r   r   r   sysr   r   r?   r   rk   rV   r   r   r   r   r   l   sD   ,	$D'2	
r   c             C   s   d d l  m } m } d d l m } | |   } | j d  t t t t	 j
 d |  j      \ } } } } | j d | | d f  Gd d	   d	  }	 | |  }
 |
 j   |
 j   |	 |
  } t |  d  S)
Nr   )ToplevelText)r{   zTest IOBindingz[x+]z+%d+%d   c               @   sX   e  Z 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   sB   | |  _  d  |  _ |  j  j d |  j  |  j  j d |  j  d  S)Nz<Control-o>z<Control-s>)r   r>   r    r!   r#   )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<<save-window>>)r   r   )r,   rD   r   r   r   r#   !  s    z#_io_binding.<locals>.MyEditWin.saveN)	r   r   r   r-   r0   r1   r3   r!   r#   r   r   r   r   	MyEditWin  s   r   )Ztkinterr   r   Zidlelib.configHandlerr{   r]   listmapintr   r   ZgeometryZpackrB   r   )rG   r   r   r{   rootwidthZheightxyr   r   r   r   r   r   _io_binding  s    3

r   __main__)run),r   r   r6   r   r|   r   ry   Ztkinter.filedialogZ
filedialogr   Ztkinter.messageboxZ
messageboxrN   Ztkinter.simpledialogr   Zlocale	setlocaleLC_CTYPEImportErrorErrorgetfilesystemencodingZfilesystemencodingrb   r   Zgetdefaultlocaler   r   nl_langinfoCODESET	NameErrorrj   
ValueErrorlowerencodingr   ASCIIr   r   r   r   r   r   Zidlelib.idle_test.htestr   r   r   r   r   <module>   s\   		
) 