<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import string <EOL> import macosxSupport <EOL> from ConfigParser import ConfigParser , NoOptionError , NoSectionError <EOL> class InvalidConfigType ( Exception ) : pass <EOL> class InvalidConfigSet ( Exception ) : pass <EOL> class InvalidFgBg ( Exception ) : pass <EOL> class InvalidTheme ( Exception ) : pass <EOL> class IdleConfParser ( ConfigParser ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cfgFile , cfgDefaults = None ) : <EOL> """<STR_LIT>""" <EOL> self . file = cfgFile <EOL> ConfigParser . __init__ ( self , defaults = cfgDefaults ) <EOL> def Get ( self , section , option , type = None , default = None , raw = False ) : <EOL> """<STR_LIT>""" <EOL> if not self . has_option ( section , option ) : <EOL> return default <EOL> if type == '<STR_LIT:bool>' : <EOL> return self . getboolean ( section , option ) <EOL> elif type == '<STR_LIT:int>' : <EOL> return self . getint ( section , option ) <EOL> else : <EOL> return self . get ( section , option , raw = raw ) <EOL> def GetOptionList ( self , section ) : <EOL> """<STR_LIT>""" <EOL> if self . has_section ( section ) : <EOL> return self . options ( section ) <EOL> else : <EOL> return [ ] <EOL> def Load ( self ) : <EOL> """<STR_LIT>""" <EOL> self . read ( self . file ) <EOL> class IdleUserConfParser ( IdleConfParser ) : <EOL> """<STR_LIT>""" <EOL> def AddSection ( self , section ) : <EOL> """<STR_LIT>""" <EOL> if not self . has_section ( section ) : <EOL> self . add_section ( section ) <EOL> def RemoveEmptySections ( self ) : <EOL> """<STR_LIT>""" <EOL> for section in self . sections ( ) : <EOL> if not self . GetOptionList ( section ) : <EOL> self . remove_section ( section ) <EOL> def IsEmpty ( self ) : <EOL> """<STR_LIT>""" <EOL> self . RemoveEmptySections ( ) <EOL> if self . sections ( ) : <EOL> return <NUM_LIT:0> <EOL> else : <EOL> return <NUM_LIT:1> <EOL> def RemoveOption ( self , section , option ) : <EOL> """<STR_LIT>""" <EOL> if self . has_section ( section ) : <EOL> return self . remove_option ( section , option ) <EOL> def SetOption ( self , section , option , value ) : <EOL> """<STR_LIT>""" <EOL> if self . has_option ( section , option ) : <EOL> if self . get ( section , option ) == value : <EOL> return <NUM_LIT:0> <EOL> else : <EOL> self . set ( section , option , value ) <EOL> return <NUM_LIT:1> <EOL> else : <EOL> if not self . has_section ( section ) : <EOL> self . add_section ( section ) <EOL> self . set ( section , option , value ) <EOL> return <NUM_LIT:1> <EOL> def RemoveFile ( self ) : <EOL> """<STR_LIT>""" <EOL> if os . path . exists ( self . file ) : <EOL> os . remove ( self . file ) <EOL> def Save ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . IsEmpty ( ) : <EOL> fname = self . file <EOL> try : <EOL> cfgFile = open ( fname , '<STR_LIT:w>' ) <EOL> except IOError : <EOL> os . unlink ( fname ) <EOL> cfgFile = open ( fname , '<STR_LIT:w>' ) <EOL> self . write ( cfgFile ) <EOL> else : <EOL> self . RemoveFile ( ) <EOL> class IdleConf : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . defaultCfg = { } <EOL> self . userCfg = { } <EOL> self . cfg = { } <EOL> self . CreateConfigHandlers ( ) <EOL> self . LoadCfgFiles ( ) <EOL> def CreateConfigHandlers ( self ) : <EOL> """<STR_LIT>""" <EOL> if __name__ != '<STR_LIT:__main__>' : <EOL> idleDir = os . path . dirname ( __file__ ) <EOL> else : <EOL> idleDir = os . path . abspath ( sys . path [ <NUM_LIT:0> ] ) <EOL> userDir = self . GetUserCfgDir ( ) <EOL> configTypes = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> defCfgFiles = { } <EOL> usrCfgFiles = { } <EOL> for cfgType in configTypes : <EOL> defCfgFiles [ cfgType ] = os . path . join ( idleDir , '<STR_LIT>' + cfgType + '<STR_LIT>' ) <EOL> usrCfgFiles [ cfgType ] = os . path . join ( userDir , '<STR_LIT>' + cfgType + '<STR_LIT>' ) <EOL> for cfgType in configTypes : <EOL> self . defaultCfg [ cfgType ] = IdleConfParser ( defCfgFiles [ cfgType ] ) <EOL> self . userCfg [ cfgType ] = IdleUserConfParser ( usrCfgFiles [ cfgType ] ) <EOL> def GetUserCfgDir ( self ) : <EOL> """<STR_LIT>""" <EOL> cfgDir = '<STR_LIT>' <EOL> userDir = os . path . expanduser ( '<STR_LIT>' ) <EOL> if userDir != '<STR_LIT>' : <EOL> if not os . path . exists ( userDir ) : <EOL> warn = ( '<STR_LIT>' + <EOL> userDir + '<STR_LIT>' ) <EOL> try : <EOL> sys . stderr . write ( warn ) <EOL> except IOError : <EOL> pass <EOL> userDir = '<STR_LIT>' <EOL> if userDir == "<STR_LIT>" : <EOL> userDir = os . getcwd ( ) <EOL> userDir = os . path . join ( userDir , cfgDir ) <EOL> if not os . path . exists ( userDir ) : <EOL> try : <EOL> os . mkdir ( userDir ) <EOL> except ( OSError , IOError ) : <EOL> warn = ( '<STR_LIT>' + <EOL> userDir + '<STR_LIT>' ) <EOL> sys . stderr . write ( warn ) <EOL> raise SystemExit <EOL> return userDir <EOL> def GetOption ( self , configType , section , option , default = None , type = None , <EOL> warn_on_default = True , raw = False ) : <EOL> """<STR_LIT>""" <EOL> if self . userCfg [ configType ] . has_option ( section , option ) : <EOL> return self . userCfg [ configType ] . Get ( section , option , <EOL> type = type , raw = raw ) <EOL> elif self . defaultCfg [ configType ] . has_option ( section , option ) : <EOL> return self . defaultCfg [ configType ] . Get ( section , option , <EOL> type = type , raw = raw ) <EOL> else : <EOL> if warn_on_default : <EOL> warning = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( option , section , default ) ) <EOL> try : <EOL> sys . stderr . write ( warning ) <EOL> except IOError : <EOL> pass <EOL> return default <EOL> def SetOption ( self , configType , section , option , value ) : <EOL> """<STR_LIT>""" <EOL> self . userCfg [ configType ] . SetOption ( section , option , value ) <EOL> def GetSectionList ( self , configSet , configType ) : <EOL> """<STR_LIT>""" <EOL> if not ( configType in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> raise InvalidConfigType , '<STR_LIT>' <EOL> if configSet == '<STR_LIT:user>' : <EOL> cfgParser = self . userCfg [ configType ] <EOL> elif configSet == '<STR_LIT:default>' : <EOL> cfgParser = self . defaultCfg [ configType ] <EOL> else : <EOL> raise InvalidConfigSet , '<STR_LIT>' <EOL> return cfgParser . sections ( ) <EOL> def GetHighlight ( self , theme , element , fgBg = None ) : <EOL> """<STR_LIT>""" <EOL> if self . defaultCfg [ '<STR_LIT>' ] . has_section ( theme ) : <EOL> themeDict = self . GetThemeDict ( '<STR_LIT:default>' , theme ) <EOL> else : <EOL> themeDict = self . GetThemeDict ( '<STR_LIT:user>' , theme ) <EOL> fore = themeDict [ element + '<STR_LIT>' ] <EOL> if element == '<STR_LIT>' : <EOL> back = themeDict [ '<STR_LIT>' ] <EOL> else : <EOL> back = themeDict [ element + '<STR_LIT>' ] <EOL> highlight = { "<STR_LIT>" : fore , "<STR_LIT>" : back } <EOL> if not fgBg : <EOL> return highlight <EOL> else : <EOL> if fgBg == '<STR_LIT>' : <EOL> return highlight [ "<STR_LIT>" ] <EOL> if fgBg == '<STR_LIT>' : <EOL> return highlight [ "<STR_LIT>" ] <EOL> else : <EOL> raise InvalidFgBg , '<STR_LIT>' <EOL> def GetThemeDict ( self , type , themeName ) : <EOL> """<STR_LIT>""" <EOL> if type == '<STR_LIT:user>' : <EOL> cfgParser = self . userCfg [ '<STR_LIT>' ] <EOL> elif type == '<STR_LIT:default>' : <EOL> cfgParser = self . defaultCfg [ '<STR_LIT>' ] <EOL> else : <EOL> raise InvalidTheme , '<STR_LIT>' <EOL> theme = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> for element in theme . keys ( ) : <EOL> if not cfgParser . has_option ( themeName , element ) : <EOL> warning = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( element , themeName , theme [ element ] ) ) <EOL> try : <EOL> sys . stderr . write ( warning ) <EOL> except IOError : <EOL> pass <EOL> colour = cfgParser . Get ( themeName , element , default = theme [ element ] ) <EOL> theme [ element ] = colour <EOL> return theme <EOL> def CurrentTheme ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetOption ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , default = '<STR_LIT>' ) <EOL> def CurrentKeys ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetOption ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , default = '<STR_LIT>' ) <EOL> def GetExtensions ( self , active_only = True , editor_only = False , shell_only = False ) : <EOL> """<STR_LIT>""" <EOL> extns = self . RemoveKeyBindNames ( <EOL> self . GetSectionList ( '<STR_LIT:default>' , '<STR_LIT>' ) ) <EOL> userExtns = self . RemoveKeyBindNames ( <EOL> self . GetSectionList ( '<STR_LIT:user>' , '<STR_LIT>' ) ) <EOL> for extn in userExtns : <EOL> if extn not in extns : <EOL> extns . append ( extn ) <EOL> if active_only : <EOL> activeExtns = [ ] <EOL> for extn in extns : <EOL> if self . GetOption ( '<STR_LIT>' , extn , '<STR_LIT>' , default = True , <EOL> type = '<STR_LIT:bool>' ) : <EOL> if editor_only or shell_only : <EOL> if editor_only : <EOL> option = "<STR_LIT>" <EOL> else : <EOL> option = "<STR_LIT>" <EOL> if self . GetOption ( '<STR_LIT>' , extn , option , <EOL> default = True , type = '<STR_LIT:bool>' , <EOL> warn_on_default = False ) : <EOL> activeExtns . append ( extn ) <EOL> else : <EOL> activeExtns . append ( extn ) <EOL> return activeExtns <EOL> else : <EOL> return extns <EOL> def RemoveKeyBindNames ( self , extnNameList ) : <EOL> names = extnNameList <EOL> kbNameIndicies = [ ] <EOL> for name in names : <EOL> if name . endswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> kbNameIndicies . append ( names . index ( name ) ) <EOL> kbNameIndicies . sort ( ) <EOL> kbNameIndicies . reverse ( ) <EOL> for index in kbNameIndicies : <EOL> del ( names [ index ] ) <EOL> return names <EOL> def GetExtnNameForEvent ( self , virtualEvent ) : <EOL> """<STR_LIT>""" <EOL> extName = None <EOL> vEvent = '<STR_LIT>' + virtualEvent + '<STR_LIT>' <EOL> for extn in self . GetExtensions ( active_only = <NUM_LIT:0> ) : <EOL> for event in self . GetExtensionKeys ( extn ) . keys ( ) : <EOL> if event == vEvent : <EOL> extName = extn <EOL> return extName <EOL> def GetExtensionKeys ( self , extensionName ) : <EOL> """<STR_LIT>""" <EOL> keysName = extensionName + '<STR_LIT>' <EOL> activeKeys = self . GetCurrentKeySet ( ) <EOL> extKeys = { } <EOL> if self . defaultCfg [ '<STR_LIT>' ] . has_section ( keysName ) : <EOL> eventNames = self . defaultCfg [ '<STR_LIT>' ] . GetOptionList ( keysName ) <EOL> for eventName in eventNames : <EOL> event = '<STR_LIT>' + eventName + '<STR_LIT>' <EOL> binding = activeKeys [ event ] <EOL> extKeys [ event ] = binding <EOL> return extKeys <EOL> def __GetRawExtensionKeys ( self , extensionName ) : <EOL> """<STR_LIT>""" <EOL> keysName = extensionName + '<STR_LIT>' <EOL> extKeys = { } <EOL> if self . defaultCfg [ '<STR_LIT>' ] . has_section ( keysName ) : <EOL> eventNames = self . defaultCfg [ '<STR_LIT>' ] . GetOptionList ( keysName ) <EOL> for eventName in eventNames : <EOL> binding = self . GetOption ( '<STR_LIT>' , keysName , <EOL> eventName , default = '<STR_LIT>' ) . split ( ) <EOL> event = '<STR_LIT>' + eventName + '<STR_LIT>' <EOL> extKeys [ event ] = binding <EOL> return extKeys <EOL> def GetExtensionBindings ( self , extensionName ) : <EOL> """<STR_LIT>""" <EOL> bindsName = extensionName + '<STR_LIT>' <EOL> extBinds = self . GetExtensionKeys ( extensionName ) <EOL> if self . defaultCfg [ '<STR_LIT>' ] . has_section ( bindsName ) : <EOL> eventNames = self . defaultCfg [ '<STR_LIT>' ] . GetOptionList ( bindsName ) <EOL> for eventName in eventNames : <EOL> binding = self . GetOption ( '<STR_LIT>' , bindsName , <EOL> eventName , default = '<STR_LIT>' ) . split ( ) <EOL> event = '<STR_LIT>' + eventName + '<STR_LIT>' <EOL> extBinds [ event ] = binding <EOL> return extBinds <EOL> def GetKeyBinding ( self , keySetName , eventStr ) : <EOL> """<STR_LIT>""" <EOL> eventName = eventStr [ <NUM_LIT:2> : - <NUM_LIT:2> ] <EOL> binding = self . GetOption ( '<STR_LIT>' , keySetName , eventName , default = '<STR_LIT>' ) . split ( ) <EOL> return binding <EOL> def GetCurrentKeySet ( self ) : <EOL> result = self . GetKeySet ( self . CurrentKeys ( ) ) <EOL> if macosxSupport . runningAsOSXApp ( ) : <EOL> for k , v in result . items ( ) : <EOL> v2 = [ x . replace ( '<STR_LIT>' , '<STR_LIT>' ) for x in v ] <EOL> if v != v2 : <EOL> result [ k ] = v2 <EOL> return result <EOL> def GetKeySet ( self , keySetName ) : <EOL> """<STR_LIT>""" <EOL> keySet = self . GetCoreKeys ( keySetName ) <EOL> activeExtns = self . GetExtensions ( active_only = <NUM_LIT:1> ) <EOL> for extn in activeExtns : <EOL> extKeys = self . __GetRawExtensionKeys ( extn ) <EOL> if extKeys : <EOL> for event in extKeys . keys ( ) : <EOL> if extKeys [ event ] in keySet . values ( ) : <EOL> extKeys [ event ] = '<STR_LIT>' <EOL> keySet [ event ] = extKeys [ event ] <EOL> return keySet <EOL> def IsCoreBinding ( self , virtualEvent ) : <EOL> """<STR_LIT>""" <EOL> return ( '<STR_LIT>' + virtualEvent + '<STR_LIT>' ) in self . GetCoreKeys ( ) . keys ( ) <EOL> def GetCoreKeys ( self , keySetName = None ) : <EOL> """<STR_LIT>""" <EOL> keyBindings = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> if keySetName : <EOL> for event in keyBindings . keys ( ) : <EOL> binding = self . GetKeyBinding ( keySetName , event ) <EOL> if binding : <EOL> keyBindings [ event ] = binding <EOL> else : <EOL> warning = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( event , keySetName , keyBindings [ event ] ) ) <EOL> try : <EOL> sys . stderr . write ( warning ) <EOL> except IOError : <EOL> pass <EOL> return keyBindings <EOL> def GetExtraHelpSourceList ( self , configSet ) : <EOL> """<STR_LIT>""" <EOL> helpSources = [ ] <EOL> if configSet == '<STR_LIT:user>' : <EOL> cfgParser = self . userCfg [ '<STR_LIT>' ] <EOL> elif configSet == '<STR_LIT:default>' : <EOL> cfgParser = self . defaultCfg [ '<STR_LIT>' ] <EOL> else : <EOL> raise InvalidConfigSet , '<STR_LIT>' <EOL> options = cfgParser . GetOptionList ( '<STR_LIT>' ) <EOL> for option in options : <EOL> value = cfgParser . Get ( '<STR_LIT>' , option , default = '<STR_LIT:;>' ) <EOL> if value . find ( '<STR_LIT:;>' ) == - <NUM_LIT:1> : <EOL> menuItem = '<STR_LIT>' <EOL> helpPath = '<STR_LIT>' <EOL> else : <EOL> value = string . split ( value , '<STR_LIT:;>' ) <EOL> menuItem = value [ <NUM_LIT:0> ] . strip ( ) <EOL> helpPath = value [ <NUM_LIT:1> ] . strip ( ) <EOL> from platform import platform <EOL> if platform ( ) . lower ( ) . split ( '<STR_LIT:->' ) [ <NUM_LIT:0> ] in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> from visual_common import __file__ as fname <EOL> helpPath = os . path . join ( '<STR_LIT>' + os . path . split ( os . path . split ( fname ) [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if menuItem and helpPath : <EOL> helpSources . append ( ( menuItem , helpPath , option ) ) <EOL> helpSources . sort ( self . __helpsort ) <EOL> return helpSources <EOL> def __helpsort ( self , h1 , h2 ) : <EOL> if int ( h1 [ <NUM_LIT:2> ] ) < int ( h2 [ <NUM_LIT:2> ] ) : <EOL> return - <NUM_LIT:1> <EOL> elif int ( h1 [ <NUM_LIT:2> ] ) > int ( h2 [ <NUM_LIT:2> ] ) : <EOL> return <NUM_LIT:1> <EOL> else : <EOL> return <NUM_LIT:0> <EOL> def GetAllExtraHelpSourcesList ( self ) : <EOL> """<STR_LIT>""" <EOL> allHelpSources = ( self . GetExtraHelpSourceList ( '<STR_LIT:default>' ) + <EOL> self . GetExtraHelpSourceList ( '<STR_LIT:user>' ) ) <EOL> return allHelpSources <EOL> def LoadCfgFiles ( self ) : <EOL> """<STR_LIT>""" <EOL> for key in self . defaultCfg . keys ( ) : <EOL> self . defaultCfg [ key ] . Load ( ) <EOL> self . userCfg [ key ] . Load ( ) <EOL> def SaveUserCfgFiles ( self ) : <EOL> """<STR_LIT>""" <EOL> for key in self . userCfg . keys ( ) : <EOL> self . userCfg [ key ] . Save ( ) <EOL> idleConf = IdleConf ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> def dumpCfg ( cfg ) : <EOL> print '<STR_LIT:\n>' , cfg , '<STR_LIT:\n>' <EOL> for key in cfg . keys ( ) : <EOL> sections = cfg [ key ] . sections ( ) <EOL> print key <EOL> print sections <EOL> for section in sections : <EOL> options = cfg [ key ] . options ( section ) <EOL> print section <EOL> print options <EOL> for option in options : <EOL> print option , '<STR_LIT:=>' , cfg [ key ] . Get ( section , option ) <EOL> dumpCfg ( idleConf . defaultCfg ) <EOL> dumpCfg ( idleConf . userCfg ) <EOL> print idleConf . userCfg [ '<STR_LIT>' ] . Get ( '<STR_LIT>' , '<STR_LIT:name>' ) </s>
