ó
§xxTc           @   s�  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Td  d l
 m
 Z
 d  d l m Z y d  d l m Z Wn e k
 rÃ d Z n Xy# d  d l Z e j e j d ƒ Wn e e j f k
 rn Xe j ƒ  Z d Z e j d	 k r]y! e j ƒ  d
 Z e j e ƒ Wn e k
 rYn Xn½ yD e j e j ƒ Z e e k p‡e d k r“d Z n  e j e ƒ Wnv e e e f k
 ryB e j ƒ  d
 Z e e k pâe d k rîd Z n  e j e ƒ Wn e e f k
 rn Xn Xe j  ƒ  Z e j! d ƒ Z" d e
 f d „  ƒ  YZ# d „  Z$ d f  d „  ƒ  YZ% d „  Z& e' d k r™d  d l( m) Z) e) e& ƒ n  d S(   iÿÿÿÿN(   t   *(   t   SimpleDialog(   t   idleConf(   t   BOM_UTF8s   ï»¿t    t   asciit   win32i   s%   ^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)t   EncodingMessagec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s3   Inform user that an encoding declaration is needed.c   
      C   sÅ  t  |  _ t | ƒ |  _ } | j d |  j ƒ | j d |  j ƒ | j d |  j ƒ | j	 d ƒ | j
 d ƒ | |  _ t | d d ƒ} | j d t d t ƒ t | d	 d
 ƒ} | j d d | ƒ | j d t d t d t ƒ t | d d | ƒ} | j d t d t ƒ t | ƒ } | j d t d t ƒ d |  _ |  _ t | d d d d d |  j ƒ} | j d t d t d d ƒ t | d d d |  j ƒ}	 |	 j d t d t d d ƒ |  j | ƒ d  S(   Ns   <Return>s   <Escape>t   WM_DELETE_WINDOWs   I/O Warningt   texts:   Non-ASCII found, yet no encoding declared. Add a line liket   sidet   anchort   fontt   courieri    s   # -*- coding: %s -*-t   fills`   to your file
Choose OK to save this file as %s
Edit your general options to silence this warningt   Okt   defaultt   activet   commandt   expandi   s   Edit my file(   t   Falset   should_editt   Toplevelt   roott   bindt   return_eventt   do_okt   protocolt   wm_delete_windowt   wm_titlet   wm_iconnamet   topt   Labelt   packt   TOPt   Wt   Entryt   insertt   Xt   FrameR   t   cancelt   Buttont   LEFTt   BOTHt   do_editt   _set_transient(
   t   selft   mastert   encR   t   l1t   l2t   l3t   buttonst   b1t   b2(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   __init__N   s6    				
c         C   s   |  j  d ƒ d  S(   Ni    (   t   done(   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR   t   s    c         C   s   |  j  d ƒ d  S(   Ni   (   R8   (   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR,   w   s    (   t   __name__t
   __module__t   __doc__R7   R   R,   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR   L   s   	&	c         C   s›   |  j  d d ƒ d  } x1 | D]% } t j | ƒ } | d k	 r Pq q Wd S| j d ƒ } d d l } y | j | ƒ Wn t k
 r– t d | ‚ n X| S(   sz   Return the encoding declaration according to PEP 263.

    Raise LookupError if the encoding is declared but unknown.
    s   
i   i   iÿÿÿÿNs   Unknown encoding (   t   splitt	   coding_ret   matcht   Nonet   groupt   codecst   lookupt   LookupError(   t   strt   lstt   lineR>   t   nameRA   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   coding_specz   s    t	   IOBindingc           B   s"  e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d Z d „  Z	 d Z
 d Z d „  Z d d d „ Z d Z e j e ƒ Z e j Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z d Z  d  d! d" g Z! d „  Z" d d „ Z# d „  Z$ d „  Z% RS(#   c         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(   Ns   <<open-window-from-file>>s   <<save-window>>s   <<save-window-as-file>>s   <<save-copy-of-window-as-file>>s   <<print-window>>(   t   editwinR	   R   t   opent   _IOBinding__id_opent   savet   _IOBinding__id_savet   save_ast   _IOBinding__id_saveast   save_a_copyt   _IOBinding__id_savecopyR?   t   fileencodingt   print_windowt   _IOBinding__id_print(   R.   RJ   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR7   ”   s    		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(   Ns   <<open-window-from-file>>s   <<save-window>>s   <<save-window-as-file>>s   <<save-copy-of-window-as-file>>s   <<print-window>>(
   R	   t   unbindRL   RN   RP   RR   RU   R?   RJ   t   filename_change_hook(   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   close    s    		c         C   s   |  j  j ƒ  S(   N(   RJ   t	   get_saved(   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRY   ¬   s    c         C   s   |  j  j | ƒ d  S(   N(   RJ   t	   set_saved(   R.   t   flag(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRZ   ¯   s    c         C   s   |  j  j ƒ  d  S(   N(   RJ   t
   reset_undo(   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR\   ²   s    c         C   s   | |  _  d  S(   N(   RW   (   R.   t   hook(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   set_filename_change_hook·   s    c         C   sf   | r- t  j j | ƒ r- d  |  _ | |  _ n5 | |  _ d  |  _ |  j d ƒ |  j rb |  j ƒ  n  d  S(   Ni   (   t   ost   patht   isdirR?   t   filenamet   dirnameRZ   RW   (   R.   Rb   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   set_filename½   s    				c         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(   Nt   interpt   breakR(   (   RJ   t   flistt   askopenfilet   getattrR?   Rb   RY   RK   t   loadfileR	   t	   focus_sett	   maybesave(   R.   t   eventt   editFileRg   Rb   t   reply(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRK   È   s6    	
	s   (\r\n)|\n|\rc         C   sW  y( t  | d ƒ � } | j ƒ  } Wd  QXWn3 t k
 r] } t j d t | ƒ d |  j ƒt SX|  j | ƒ } |  j	 j
 | ƒ } | rÙ | j d ƒ |  _ t |  j t ƒ rÁ |  j j d ƒ |  _ n  |  j	 j d | ƒ } n  |  j j d d ƒ |  j d  ƒ |  j j d | ƒ |  j ƒ  |  j | ƒ |  j j d	 d ƒ |  j j d	 ƒ |  j | ƒ t S(
   Nt   rbs	   I/O ErrorR/   i    R   s   \ns   1.0t   endR%   (   RK   t   readt   IOErrort   tkMessageBoxt	   showerrorRD   R	   R   t   decodet   eol_ret   searchR@   t   eol_conventiont
   isinstancet   unicodet   encodet   subt   deleteRd   R?   R%   R\   t   mark_sett   yviewt   updaterecentfileslistt   True(   R.   Rb   t   ft   charst   msgt   firsteol(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRj   ø   s,    
c         C   s!  | j  t ƒ rK y | d j d ƒ } Wn t k
 r: | SXt |  _ | Sn  y t | ƒ } Wn< t k
 r™ } t j d d d d | d |  j	 ƒ d	 } n X| rÈ y t | | ƒ SWqÈ t k
 rÄ qÈ Xn  y t | d ƒ SWn t k
 rì n Xy t | t ƒ } t |  _ Wn t k
 rn X| S(
   sM   Create a Unicode string

        If that fails, let Tcl try its best
        i   s   utf-8t   titles   Error loading the filet   messages^   The encoding '%s' is not known to this Python installation. The file may not display correctlyR/   R   N(   t
   startswithR   Rv   t   UnicodeErrorRS   RH   RC   Rt   Ru   R	   R?   R{   t   encoding(   R.   R„   R0   RG   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRv     s>    		

c      	   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(   Nt   yess&   Do you want to save %s before closing?s   this untitled documentR‡   s   Save On CloseRˆ   R   R/   R(   t   no(	   RY   Rb   Rt   t   askyesnocancelt   YESR	   RM   R?   Rk   (   R.   Rˆ   t   confirmRo   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRl   C  s&    			c         C   sq   |  j  s |  j | ƒ nG |  j |  j  ƒ r` |  j t ƒ y |  j j ƒ  Wq` t k
 r\ q` Xn  |  j j	 ƒ  d S(   NRf   (
   Rb   RO   t	   writefileRZ   R‚   RJ   t   store_file_breakst   AttributeErrorR	   Rk   (   R.   Rm   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRM   Y  s    	c         C   s„   |  j  ƒ  } | rf |  j | ƒ rf |  j | ƒ |  j d ƒ y |  j j ƒ  Wqc t k
 r_ qc Xqf n  |  j j ƒ  |  j	 | ƒ d S(   Ni   Rf   (
   t   asksavefileR‘   Rd   RZ   RJ   R’   R“   R	   Rk   R�   (   R.   Rm   Rb   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRO   f  s    
c         C   s@   |  j  ƒ  } | r" |  j | ƒ n  |  j j ƒ  |  j | ƒ d S(   NRf   (   R”   R‘   R	   Rk   R�   (   R.   Rm   Rb   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRQ   t  s    c         C   s¶   |  j  ƒ  |  j |  j j d d ƒ ƒ } |  j d k rO | j d |  j ƒ } n  y- t | d ƒ � } | j | ƒ Wd  QXt SWn3 t	 k
 r± } t
 j d t | ƒ d |  j ƒt SXd  S(   Ns   1.0s   end-1cs   
t   wbs	   I/O ErrorR/   (   t   fixlastlineR|   R	   t   getRy   t   replaceRK   t   writeR‚   Rs   Rt   Ru   RD   R   (   R.   Rb   R„   Rƒ   R…   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR‘   |  s    

c   
      C   s›  t  | t j ƒ r | Sy | j d ƒ SWn t k
 r: n Xy t | ƒ } d  } Wn t k
 rr } | } d  } n X| r« y | j | ƒ SWq« t k
 r§ d | } q« Xn  | rÑ t j	 d d | d |  j
 ƒn  |  j t k sæ | r÷ t | j d ƒ S|  j rYy | j |  j ƒ SWqYt k
 rUt j	 d d |  j d |  j
 ƒt | j d ƒ SXn  t j d d	 d
 ƒ } | d k r‹t | j d ƒ St } y. | j t ƒ } t } | d k r¾t } n  Wn* t k
 rët | j d ƒ } d } n X| sö| St |  j j | ƒ } | j ƒ  | j d k r—d | } |  j
 j d d ƒ }	 |	 j d ƒ rh|  j
 j d | ƒ n |  j
 j d | ƒ |  j |  j
 j d d ƒ ƒ S| S(   NR   s   Invalid encoding '%s's	   I/O Errors   %s. Saving as UTF-8R/   s   utf-8s1   Cannot save this as '%s' anymore. Saving as UTF-8t   maint   EditorWindowR‹   t   localei   s   # -*- coding: %s -*-
s   1.0s   2.0s   #!s   end-1c(   Rz   t   typest
   StringTypeR|   RŠ   RH   R?   RC   Rt   Ru   R	   RS   R   R   t	   GetOptionR‚   R‹   R   R   RJ   R   t   got   numR—   R‰   R%   (
   R.   R„   R0   t   failedR…   t   config_encodingt   ask_usert   dialogt   enclinet	   firstline(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR|   Š  sv    


	

	


c         C   s8   |  j  j d ƒ } | d k r4 |  j  j d d ƒ n  d  S(   Ns   end-2cs   
s   end-1c(   R	   R—   R%   (   R.   t   c(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR–   Ô  s    c      	   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 } t } | d
 k rt j d d d ƒ }	 |	 d }	 n* | d k r't j d d d ƒ }	 n t } | 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‡   t   PrintRˆ   s   Print to Default PrinterR   R/   Rf   t   prefixt	   IDLE_tmp_t   posixRš   t   Generals   print-command-posixs    2>&1t   nts   print-command-wint   rs#   Printing failed (exit status 0x%x)
s   Printing command: %s
s   Print statuss-   Printing is not enabled for this platform: %s(   Rt   t   askokcancelt   OKR	   Rk   R?   RY   Rb   t   tempfilet   mkstempR_   RX   R‘   t   unlinkRG   R‚   R   RŸ   R   t   pipest   quotet   popenRr   t   stript   reprRu   t   showinfo(   R.   Rm   R�   t   tempfilenamet   savedRb   t   tfdt   platformt   printPlatformR   t   pipet   outputt   statusRˆ   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRT   Ù  sX    				
s   Python filess
   *.py *.pywt   TEXTs
   Text filess   *.txts	   All filesR    c         C   s‚   |  j  d ƒ \ } } |  j sB t j d |  j d |  j ƒ |  _ n  |  j j d | d | ƒ } t | t ƒ r~ | j	 t
 ƒ } n  | S(   NRK   R/   t	   filetypest
   initialdirt   initialfile(   t   defaultfilenamet
   opendialogt   tkFileDialogt   OpenR	   RÄ   t   showRz   R{   R|   t   filesystemencoding(   R.   t   dirt   baseRb   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRh     s    	RK   c         C   sm   |  j  r t j j |  j  ƒ S|  j r2 |  j d f Sy t j ƒ  } Wn t j k
 r^ d } n X| d f Sd  S(   NR   (   Rb   R_   R`   R<   Rc   t   getcwdt   error(   R.   t   modet   pwd(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRÇ     s    		
c         C   s‚   |  j  d ƒ \ } } |  j sB t j d |  j d |  j ƒ |  _ n  |  j j d | d | ƒ } t | t ƒ r~ | j	 t
 ƒ } n  | S(   NRM   R/   RÄ   RÅ   RÆ   (   RÇ   t
   savedialogRÉ   t   SaveAsR	   RÄ   RË   Rz   R{   R|   RÌ   (   R.   RÍ   RÎ   Rb   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR”   *  s    	c         C   s   |  j  j | ƒ d S(   s-   Update recent file list on all editor windowsN(   RJ   t   update_recent_files_list(   R.   Rb   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR�   4  s    N(   s   Python filess
   *.py *.pywRÃ   (   s
   Text filess   *.txtRÃ   (   s	   All filesR    (&   R9   R:   R7   RX   RY   RZ   R\   R?   RW   R^   Rb   Rc   Rd   RK   t   eolt   ret   compileRw   R_   t   linesepRy   Rj   Rv   Rl   RM   RO   RQ   R‘   R|   R–   RT   RÈ   RÓ   RÄ   Rh   RÇ   R”   R�   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRI   ’   sB   							,			-						J		2		
	
c   
      C   s³   t  ƒ  } | j d ƒ t t t t j d |  j ƒ  ƒ ƒ ƒ \ } } } } | j d | | d f ƒ d d d „  ƒ  Y} t | ƒ } | j	 ƒ  | j
 ƒ  | | ƒ } t | ƒ }	 d  S(   Ns   Test IOBindings   [x+]s   +%d+%di–   t	   MyEditWinc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         S   sB   | |  _  d  |  _ |  j  j d |  j ƒ |  j  j d |  j ƒ d  S(   Ns   <Control-o>s   <Control-s>(   R	   R?   Rg   R   RK   RM   (   R.   R	   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR7   >  s    		c         S   s   d S(   Ni    (    (   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRY   C  s    c         S   s   d  S(   N(    (   R.   R[   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRZ   D  s    c         S   s   d  S(   N(    (   R.   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyR\   E  s    c         S   s   |  j  j d ƒ d  S(   Ns   <<open-window-from-file>>(   R	   t   event_generate(   R.   Rm   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRK   F  s    c         S   s   |  j  j d ƒ d  S(   Ns   <<save-window>>(   R	   RÛ   (   R.   Rm   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRM   H  s    (   R9   R:   R7   RY   RZ   R\   RK   RM   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyRÚ   =  s   					(    (   t   TkR‡   t   listt   mapt   intR×   R<   t   geometryt   TextR!   Rk   RI   (
   t   parentR   t   widtht   heightt   xt   yRÚ   R	   RJ   t   io(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   _io_binding8  s    	3

t   __main__(   t   run(*   R_   R�   Rµ   t   sysRA   R²   RÉ   Rt   R×   t   TkinterR   t   idlelib.configHandlerR   R   t   ImportErrorRœ   t	   setlocalet   LC_CTYPEt   Errort   getfilesystemencodingRÌ   R‹   R¾   t   getdefaultlocaleRB   RC   t   nl_langinfot   CODESETR?   t	   NameErrorR“   t
   ValueErrort   lowerRØ   R=   R   RH   RI   Rè   R9   t   idlelib.idle_test.htestRê   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/idlelib/IOBinding.pyt   <module>   sf   

		.	ÿ §	