summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/configHandler.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-01-14 22:03:31 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-01-14 22:03:31 (GMT)
commit8e92bf7699ac3617d3a0a9a55a38f642f5a6ecc6 (patch)
tree8e4486a10f7b3e00124724d0f1fe717fbb6c1f2e /Lib/idlelib/configHandler.py
parent50e92235e7fc7151f591f76b73fb539e34593405 (diff)
downloadcpython-8e92bf7699ac3617d3a0a9a55a38f642f5a6ecc6.zip
cpython-8e92bf7699ac3617d3a0a9a55a38f642f5a6ecc6.tar.gz
cpython-8e92bf7699ac3617d3a0a9a55a38f642f5a6ecc6.tar.bz2
M Bindings.py
M EditorWindow.py M NEWS.txt M config-main.def M configDialog.py M configHandler.py M configHelpSourceEdit.py M configSectionNameDialog.py - Change default: IDLE now starts with Python Shell. - Removed the File Path from the Additional Help Sources scrolled list. - Add capability to access Additional Help Sources on the web if the Help File Path begins with //http or www. (Otherwise local path is validated, as before.) - Additional Help Sources were not being posted on the Help menu in the order entered. Implement sorting the list by [HelpFiles] 'option' number. - Add Browse button to New Help Source dialog. Arrange to start in Python/Doc if platform is Windows, otherwise start in current directory. - Put the Additional Help Sources directly on the Help menu instead of in an Extra Help cascade menu. Rearrange the Help menu so the Additional Help Sources come last. Update help.txt appropriately. - Fix Tk root pop-ups in configSectionNameDialog.py and configDialog.py
Diffstat (limited to 'Lib/idlelib/configHandler.py')
-rw-r--r--Lib/idlelib/configHandler.py61
1 files changed, 43 insertions, 18 deletions
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index cf2b6db..22e83a6 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -1,14 +1,25 @@
+"""Provides access to stored IDLE configuration information.
+
+Refer to the comments at the beginning of config-main.def for a description of
+the available configuration files and the design implemented to update user
+configuration information. In particular, user configuration choices which
+duplicate the defaults will be removed from the user's configuration files,
+and if a file becomes empty, it will be deleted.
+
+The contents of the user files may be altered using the Options/Configure IDLE
+menu to access the configuration GUI (configDialog.py), or manually.
+
+Throughout this module there is an emphasis on returning useable defaults
+when a problem occurs in returning a requested configuration value back to
+idle. This is to allow IDLE to continue to function in spite of errors in
+the retrieval of config information. When a default is returned instead of
+a requested config value, a message is printed to stderr to aid in
+configuration problem notification and resolution.
+
"""
-Provides access to stored idle configuration information.
-"""
-# Throughout this module there is an emphasis on returning useable defaults
-# when a problem occurs in returning a requested configuration value back to
-# idle. This is to allow idle to continue to function in spite of errors in
-# the retrieval of config information. When a default is returned instead of
-# a requested config value, a message is printed to stderr to aid in
-# configuration problem notification and resolution.
-
-import os, sys, string
+import os
+import sys
+import string
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
class InvalidConfigType(Exception): pass
@@ -123,9 +134,11 @@ class IdleUserConfParser(IdleConfParser):
os.remove(self.file)
def Save(self):
- """
- If config isn't empty, write file to disk. If config is empty,
- remove the file from disk if it exists.
+ """Update user configuration file.
+
+ Remove empty sections. If resulting config isn't empty, write the file
+ to disk. If config is empty, remove the file from disk if it exists.
+
"""
if not self.IsEmpty():
cfgFile=open(self.file,'w')
@@ -555,11 +568,14 @@ class IdleConf:
return keyBindings
def GetExtraHelpSourceList(self,configSet):
- """
- Returns a list of tuples containing the details of any additional
- help sources configured in the requested configSet ('user' or 'default')
- , or an empty list if there are none. Returned tuples are of the form
- form (menu_item , path_to_help_file , option).
+ """Fetch list of extra help sources from a given configSet.
+
+ Valid configSets are 'user' or 'default'. Return a list of tuples of
+ the form (menu_item , path_to_help_file , option), or return the empty
+ list. 'option' is the sequence number of the help resource. 'option'
+ values determine the position of the menu items on the Help menu,
+ therefore the returned list must be sorted by 'option'.
+
"""
helpSources=[]
if configSet=='user':
@@ -580,8 +596,17 @@ class IdleConf:
helpPath=value[1].strip()
if menuItem and helpPath: #neither are empty strings
helpSources.append( (menuItem,helpPath,option) )
+ helpSources.sort(self.__helpsort)
return helpSources
+ def __helpsort(self, h1, h2):
+ if int(h1[2]) < int(h2[2]):
+ return -1
+ elif int(h1[2]) > int(h2[2]):
+ return 1
+ else:
+ return 0
+
def GetAllExtraHelpSourcesList(self):
"""
Returns a list of tuples containing the details of all additional help