Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/idlelib/configHandler.py

    r2 r391  
    2121import sys
    2222import string
    23 import macosxSupport
     23from idlelib import macosxSupport
    2424from ConfigParser import ConfigParser, NoOptionError, NoSectionError
    2525
     
    238238
    239239        """
    240         if self.userCfg[configType].has_option(section,option):
    241             return self.userCfg[configType].Get(section, option,
    242                                                 type=type, raw=raw)
    243         elif self.defaultCfg[configType].has_option(section,option):
    244             return self.defaultCfg[configType].Get(section, option,
    245                                                    type=type, raw=raw)
    246         else: #returning default, print warning
    247             if warn_on_default:
    248                 warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
    249                            ' problem retrieving configration option %r\n'
    250                            ' from section %r.\n'
    251                            ' returning default value: %r\n' %
    252                            (option, section, default))
    253                 try:
    254                     sys.stderr.write(warning)
    255                 except IOError:
    256                     pass
    257             return default
     240        try:
     241            if self.userCfg[configType].has_option(section,option):
     242                return self.userCfg[configType].Get(section, option,
     243                                                    type=type, raw=raw)
     244        except ValueError:
     245            warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
     246                       ' invalid %r value for configuration option %r\n'
     247                       ' from section %r: %r\n' %
     248                       (type, option, section,
     249                        self.userCfg[configType].Get(section, option,
     250                                                     raw=raw)))
     251            try:
     252                sys.stderr.write(warning)
     253            except IOError:
     254                pass
     255        try:
     256            if self.defaultCfg[configType].has_option(section,option):
     257                return self.defaultCfg[configType].Get(section, option,
     258                                                       type=type, raw=raw)
     259        except ValueError:
     260            pass
     261        #returning default, print warning
     262        if warn_on_default:
     263            warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
     264                       ' problem retrieving configuration option %r\n'
     265                       ' from section %r.\n'
     266                       ' returning default value: %r\n' %
     267                       (option, section, default))
     268            try:
     269                sys.stderr.write(warning)
     270            except IOError:
     271                pass
     272        return default
    258273
    259274    def SetOption(self, configType, section, option, value):
     
    596611            '<<goto-line>>': ['<Alt-g>'],
    597612            '<<smart-backspace>>': ['<Key-BackSpace>'],
    598             '<<newline-and-indent>>': ['<Key-Return> <Key-KP_Enter>'],
     613            '<<newline-and-indent>>': ['<Key-Return>', '<Key-KP_Enter>'],
    599614            '<<smart-indent>>': ['<Key-Tab>'],
    600615            '<<indent-region>>': ['<Control-Key-bracketright>'],
     
    655670            if menuItem and helpPath: #neither are empty strings
    656671                helpSources.append( (menuItem,helpPath,option) )
    657         helpSources.sort(self.__helpsort)
     672        helpSources.sort(key=lambda x: int(x[2]))
    658673        return helpSources
    659 
    660     def __helpsort(self, h1, h2):
    661         if int(h1[2]) < int(h2[2]):
    662             return -1
    663         elif int(h1[2]) > int(h2[2]):
    664             return 1
    665         else:
    666             return 0
    667674
    668675    def GetAllExtraHelpSourcesList(self):
Note: See TracChangeset for help on using the changeset viewer.