[Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.56, 1.57 IOBinding.py, 1.22, 1.23 NEWS.txt, 1.32, 1.33 configDialog.py, 1.57, 1.58

kbk at users.sourceforge.net kbk at users.sourceforge.net
Sat Apr 10 23:16:10 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/idlelib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13503

Modified Files:
	EditorWindow.py IOBinding.py NEWS.txt configDialog.py 
Log Message:
M EditorWindow.py
M IOBinding.py
M NEWS.txt
M configDialog.py

- If nulls somehow got into the strings in recent-files.lst
  EditorWindow.update_recent_files_list() was failing.  Python Bug 931336.


Index: EditorWindow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** EditorWindow.py	8 Mar 2004 18:15:30 -0000	1.56
--- EditorWindow.py	11 Apr 2004 03:16:07 -0000	1.57
***************
*** 3,6 ****
--- 3,7 ----
  import re
  import imp
+ from itertools import count
  from Tkinter import *
  import tkSimpleDialog
***************
*** 79,86 ****
          if flist:
              self.vars = flist.vars
!             #self.top.instanceDict makes flist.inversedict avalable to
              #configDialog.py so it can access all EditorWindow instaces
!             self.top.instanceDict=flist.inversedict
!         self.recentFilesPath=os.path.join(idleConf.GetUserCfgDir(),
                  'recent-files.lst')
          self.vbar = vbar = Scrollbar(top, name='vbar')
--- 80,87 ----
          if flist:
              self.vars = flist.vars
!             #self.top.instance_dict makes flist.inversedict avalable to
              #configDialog.py so it can access all EditorWindow instaces
!             self.top.instance_dict=flist.inversedict
!         self.recent_files_path=os.path.join(idleConf.GetUserCfgDir(),
                  'recent-files.lst')
          self.vbar = vbar = Scrollbar(top, name='vbar')
***************
*** 179,187 ****
          io.set_filename_change_hook(self.filename_change_hook)
  
!         #create the Recent Files submenu
!         self.menuRecentFiles=Menu(self.menubar)
!         self.menudict['file'].insert_cascade(3,label='Recent Files',
!                 underline=0,menu=self.menuRecentFiles)
!         self.UpdateRecentFilesList()
  
          if filename:
--- 180,189 ----
          io.set_filename_change_hook(self.filename_change_hook)
  
!         # Create the recent files submenu
!         self.recent_files_menu = Menu(self.menubar)
!         self.menudict['file'].insert_cascade(3, label='Recent Files',
!                                              underline=0,
!                                              menu=self.recent_files_menu)
!         self.update_recent_files_list()
  
          if filename:
***************
*** 580,643 ****
          return display_extra_help
  
!     def UpdateRecentFilesList(self,newFile=None):
!         "Load or update the recent files list, and menu if required"
!         rfList=[]
!         if os.path.exists(self.recentFilesPath):
!             RFfile=open(self.recentFilesPath,'r')
              try:
!                 rfList=RFfile.readlines()
              finally:
!                 RFfile.close()
!         if newFile:
!             newFile=os.path.abspath(newFile)+'\n'
!             if newFile in rfList:
!                 rfList.remove(newFile)
!             rfList.insert(0,newFile)
!         rfList=self.__CleanRecentFiles(rfList)
!         #print self.flist.inversedict
!         #print self.top.instanceDict
!         #print self
!         ullist = "1234567890ABCDEFGHIJ"
!         if rfList:
!             for instance in self.top.instanceDict.keys():
!                 menu = instance.menuRecentFiles
!                 menu.delete(1,END)
!                 i = 0 ; ul = 0; ullen = len(ullist)
!                 for file in rfList:
!                     fileName=file[0:-1]
!                     callback = instance.__RecentFileCallback(fileName)
!                     if i > ullen: # don't underline menuitems
!                         ul=None
!                     menu.add_command(label=ullist[i] + " " + fileName,
!                                      command=callback,
!                                      underline=ul)
!                     i += 1
! 
!     def __CleanRecentFiles(self,rfList):
!         origRfList=rfList[:]
!         count=0
!         nonFiles=[]
!         for path in rfList:
!             if not os.path.exists(path[0:-1]):
!                 nonFiles.append(count)
!             count=count+1
!         if nonFiles:
!             nonFiles.reverse()
!             for index in nonFiles:
!                 del(rfList[index])
!         if len(rfList)>19:
!             rfList=rfList[0:19]
!         #if rfList != origRfList:
!         RFfile=open(self.recentFilesPath,'w')
          try:
!             RFfile.writelines(rfList)
          finally:
!             RFfile.close()
!         return rfList
  
!     def __RecentFileCallback(self,fileName):
!         def OpenRecentFile(fileName=fileName):
!             self.io.open(editFile=fileName)
!         return OpenRecentFile
  
      def saved_change_hook(self):
--- 582,627 ----
          return display_extra_help
  
!     def update_recent_files_list(self, new_file=None):
!         "Load and update the recent files list and menus"
!         rf_list = []
!         if os.path.exists(self.recent_files_path):
!             rf_list_file = open(self.recent_files_path,'r')
              try:
!                 rf_list = rf_list_file.readlines()
              finally:
!                 rf_list_file.close()
!         if new_file:
!             new_file = os.path.abspath(new_file) + '\n'
!             if new_file in rf_list:
!                 rf_list.remove(new_file)  # move to top
!             rf_list.insert(0, new_file)
!         # clean and save the recent files list
!         bad_paths = []
!         for path in rf_list:
!             if '\0' in path or not os.path.exists(path[0:-1]):
!                 bad_paths.append(path)
!         rf_list = [path for path in rf_list if path not in bad_paths]
!         ulchars = "1234567890ABCDEFGHIJK"
!         rf_list = rf_list[0:len(ulchars)]
!         rf_file = open(self.recent_files_path, 'w')
          try:
!             rf_file.writelines(rf_list)
          finally:
!             rf_file.close()
!         # for each edit window instance, construct the recent files menu
!         for instance in self.top.instance_dict.keys():
!             menu = instance.recent_files_menu
!             menu.delete(1, END)  # clear, and rebuild:
!             for i, file in zip(count(), rf_list):
!                 file_name = file[0:-1]  # zap \n
!                 callback = instance.__recent_file_callback(file_name)
!                 menu.add_command(label=ulchars[i] + " " + file_name,
!                                  command=callback,
!                                  underline=0)
  
!     def __recent_file_callback(self, file_name):
!         def open_recent_file(fn_closure=file_name):
!             self.io.open(editFile=fn_closure)
!         return open_recent_file
  
      def saved_change_hook(self):
***************
*** 730,734 ****
          #print self.io.filename
          if self.io.filename:
!             self.UpdateRecentFilesList(newFile=self.io.filename)
          WindowList.unregister_callback(self.postwindowsmenu)
          if self.close_hook:
--- 714,718 ----
          #print self.io.filename
          if self.io.filename:
!             self.update_recent_files_list(new_file=self.io.filename)
          WindowList.unregister_callback(self.postwindowsmenu)
          if self.close_hook:

Index: IOBinding.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/IOBinding.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** IOBinding.py	25 Nov 2003 05:01:00 -0000	1.22
--- IOBinding.py	11 Apr 2004 03:16:07 -0000	1.23
***************
*** 541,545 ****
      def updaterecentfileslist(self,filename):
          "Update recent file list on all editor windows"
!         self.editwin.UpdateRecentFilesList(filename)
  
  def test():
--- 541,545 ----
      def updaterecentfileslist(self,filename):
          "Update recent file list on all editor windows"
!         self.editwin.update_recent_files_list(filename)
  
  def test():

Index: NEWS.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** NEWS.txt	15 Mar 2004 04:26:37 -0000	1.32
--- NEWS.txt	11 Apr 2004 03:16:07 -0000	1.33
***************
*** 4,9 ****
  *Release date: XX-XXX-2004*
  
  - If the normal background is changed via Configure/Highlighting, it will update 
!   immediately, thanks to the previously mentioned patch.
  
  - Add a highlight theme for builtin keywords.  Python Patch 805830 Nigel Rowe
--- 4,12 ----
  *Release date: XX-XXX-2004*
  
+ - If nulls somehow got into the strings in recent-files.lst
+   EditorWindow.update_recent_files_list() was failing.  Python Bug 931336.
+ 
  - If the normal background is changed via Configure/Highlighting, it will update 
!   immediately, thanks to the previously mentioned patch by Nigel Rowe.
  
  - Add a highlight theme for builtin keywords.  Python Patch 805830 Nigel Rowe

Index: configDialog.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configDialog.py,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** configDialog.py	8 Mar 2004 18:15:31 -0000	1.57
--- configDialog.py	11 Apr 2004 03:16:07 -0000	1.58
***************
*** 1158,1162 ****
          #update keybindings and re-bind
          #update user help sources menu
!         winInstances=self.parent.instanceDict.keys()
          for instance in winInstances:
              instance.ResetColorizer()
--- 1158,1162 ----
          #update keybindings and re-bind
          #update user help sources menu
!         winInstances=self.parent.instance_dict.keys()
          for instance in winInstances:
              instance.ResetColorizer()
***************
*** 1184,1187 ****
      Button(root,text='Dialog',
              command=lambda:ConfigDialog(root,'Settings')).pack()
!     root.instanceDict={}
      root.mainloop()
--- 1184,1187 ----
      Button(root,text='Dialog',
              command=lambda:ConfigDialog(root,'Settings')).pack()
!     root.instance_dict={}
      root.mainloop()




More information about the Python-checkins mailing list