summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/configHandler.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/configHandler.py')
-rw-r--r--Lib/idlelib/configHandler.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index fada4eb..b00bdcf 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -20,7 +20,7 @@ configuration problem notification and resolution.
import os
import sys
import string
-import macosxSupport
+from idlelib import macosxSupport
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
class InvalidConfigType(Exception): pass
@@ -39,22 +39,19 @@ class IdleConfParser(ConfigParser):
self.file=cfgFile
ConfigParser.__init__(self,defaults=cfgDefaults)
- def Get(self, section, option, type=None, default=None):
+ def Get(self, section, option, type=None, default=None, raw=False):
"""
Get an option value for given section/option or return default.
If type is specified, return as type.
"""
+ if not self.has_option(section, option):
+ return default
if type=='bool':
- getVal=self.getboolean
+ return self.getboolean(section, option)
elif type=='int':
- getVal=self.getint
- else:
- getVal=self.get
- if self.has_option(section,option):
- #return getVal(section, option, raw, vars, default)
- return getVal(section, option)
+ return self.getint(section, option)
else:
- return default
+ return self.get(section, option, raw=raw)
def GetOptionList(self,section):
"""
@@ -227,7 +224,7 @@ class IdleConf:
return userDir
def GetOption(self, configType, section, option, default=None, type=None,
- warn_on_default=True):
+ warn_on_default=True, raw=False):
"""
Get an option value for given config type and given general
configuration section/option or return a default. If type is specified,
@@ -241,9 +238,11 @@ class IdleConf:
"""
if self.userCfg[configType].has_option(section,option):
- return self.userCfg[configType].Get(section, option, type=type)
+ return self.userCfg[configType].Get(section, option,
+ type=type, raw=raw)
elif self.defaultCfg[configType].has_option(section,option):
- return self.defaultCfg[configType].Get(section, option, type=type)
+ return self.defaultCfg[configType].Get(section, option,
+ type=type, raw=raw)
else: #returning default, print warning
if warn_on_default:
warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
@@ -655,17 +654,9 @@ class IdleConf:
helpPath=value[1].strip()
if menuItem and helpPath: #neither are empty strings
helpSources.append( (menuItem,helpPath,option) )
- helpSources.sort(self.__helpsort)
+ helpSources.sort(key=lambda x: int(x[2]))
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