ó {fc@s~dZddlmZddlZddlZddlmZddlmZddlm Z m Z de fd„ƒYZ d e fd „ƒYZ d e fd „ƒYZd e fd„ƒYZdefd„ƒYZdefd„ƒYZdfd„ƒYZeƒZedkrzddlmZddf\aad„Zd„ZeejƒeejƒedtdtddƒndS(sÕ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. iÿÿÿÿ(tprint_functionN(t ConfigParser(t TkVersion(tFontt nametofonttInvalidConfigTypecBseZRS((t__name__t __module__(((s-/usr/lib64/python2.7/idlelib/configHandler.pyRstInvalidConfigSetcBseZRS((RR(((s-/usr/lib64/python2.7/idlelib/configHandler.pyRst InvalidFgBgcBseZRS((RR(((s-/usr/lib64/python2.7/idlelib/configHandler.pyR st InvalidThemecBseZRS((RR(((s-/usr/lib64/python2.7/idlelib/configHandler.pyR stIdleConfParsercBs>eZdZdd„Zdded„Zd„Zd„ZRS(sI A ConfigParser specialised for idle configuration file handling cCs ||_tj|d|ƒdS(sK cfgFile - string, fully specified configuration file name tdefaultsN(tfileRt__init__(tselftcfgFilet cfgDefaults((s-/usr/lib64/python2.7/idlelib/configHandler.pyR&s cCsh|j||ƒs|S|dkr2|j||ƒS|dkrN|j||ƒS|j||d|ƒSdS(s Get an option value for given section/option or return default. If type is specified, return as type. tbooltinttrawN(t has_optiont getbooleantgetinttget(RtsectiontoptionttypetdefaultR((s-/usr/lib64/python2.7/idlelib/configHandler.pytGet-s  cCs$|j|ƒr|j|ƒSgSdS(s4Return a list of options for given section, else [].N(t has_sectiontoptions(RR((s-/usr/lib64/python2.7/idlelib/configHandler.pyt GetOptionList>s cCs|j|jƒdS(s&Load the configuration file from disk.N(treadR (R((s-/usr/lib64/python2.7/idlelib/configHandler.pytLoadEsN( RRt__doc__tNoneRtFalseRR R"(((s-/usr/lib64/python2.7/idlelib/configHandler.pyR "s   tIdleUserConfParsercBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(sG IdleConfigParser specialised for user configuration handling. cCs#|j|ƒs|j|ƒndS(s!If section doesn't exist, add it.N(Rt add_section(RR((s-/usr/lib64/python2.7/idlelib/configHandler.pyt AddSectionNscCs:x3|jƒD]%}|j|ƒs |j|ƒq q WdS(s)Remove any sections that have no options.N(tsectionsR tremove_section(RR((s-/usr/lib64/python2.7/idlelib/configHandler.pytRemoveEmptySectionsSscCs|jƒ|jƒ S(s9Return True if no sections after removing empty sections.(R+R)(R((s-/usr/lib64/python2.7/idlelib/configHandler.pytIsEmptyYs cCs#|j|ƒr|j||ƒStS(s‹Return True if option is removed from section, else False. False if either section does not exist or did not have option. (Rt remove_optionR%(RRR((s-/usr/lib64/python2.7/idlelib/configHandler.pyt RemoveOption^scCs‚|j||ƒrH|j||ƒ|kr.tS|j|||ƒtSn6|j|ƒsg|j|ƒn|j|||ƒtSdS(s‘Return True if option is added or changed to value, else False. Add section if required. False means option already had value. N(RRR%tsettTrueRR'(RRRtvalue((s-/usr/lib64/python2.7/idlelib/configHandler.pyt SetOptiongscCs,tjj|jƒr(tj|jƒndS(s9Remove user config file self.file from disk if it exists.N(tostpathtexistsR tremove(R((s-/usr/lib64/python2.7/idlelib/configHandler.pyt RemoveFilexscCsƒ|jƒsu|j}yt|dƒ}Wn-tk rWtj|ƒt|dƒ}nX|�|j|ƒWdQXn |jƒdS(sÆ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. twN(R,R topentIOErrorR3tunlinktwriteR7(RtfnameR((s-/usr/lib64/python2.7/idlelib/configHandler.pytSave}s    ( RRR#R(R+R,R.R2R7R>(((s-/usr/lib64/python2.7/idlelib/configHandler.pyR&Is     tIdleConfcBseZdZd„Zd„Zd„Zddeed„Z d„Z d„Z dd„Z d„Z d „Zd „Zeeed „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zdd„Zd„Zd„Zd„Zd„Zd„ZRS(slHold config parsers for all idle config files in singleton instance. Default config files, self.defaultCfg -- for config_type in self.config_types: (idle install dir)/config-{config-type}.def User config files, self.userCfg -- for config_type in self.config_types: (user home dir)/.idlerc/config-{config-type}.cfg cCs<d|_i|_i|_i|_|jƒ|jƒdS(Ntmaint extensionst highlighttkeys(R@RARBRC(t config_typest defaultCfgtuserCfgtcfgtCreateConfigHandlerst LoadCfgFiles(R((s-/usr/lib64/python2.7/idlelib/configHandler.pyR›s      cCsîtdkr!tjjtƒ}ntjjtjdƒ}|jƒ}i}i}xS|jD]H}tjj |d|dƒ||>' s<>R…iN(R$RŒtGetExtensionKeys(Rt virtualEventtextNametvEventRŠtevent((s-/usr/lib64/python2.7/idlelib/configHandler.pytGetExtnNameForEventÇs c Cs‚|d}|jƒ}i}|jdj|ƒr~|jdj|ƒ}x3|D](}d|d}||}|||>(tGetCurrentKeySetRERR ( Rt extensionNametkeysNamet activeKeystextKeyst eventNamest eventNameRštbinding((s-/usr/lib64/python2.7/idlelib/configHandler.pyR–Õs    cCs�|d}i}|jdj|ƒr‰|jdj|ƒ}xJ|D]?}|jd||ddƒjƒ}d|d}|||>(RERR Rdtsplit(RR�RžR R¡R¢R£Rš((s-/usr/lib64/python2.7/idlelib/configHandler.pyt__GetRawExtensionKeysçs  cCs–|d}|j|ƒ}|jdj|ƒr’|jdj|ƒ}xJ|D]?}|jd||ddƒjƒ}d|d}|||>(R–RERR RdR¤(RR�t bindsNametextBindsR¡R¢R£Rš((s-/usr/lib64/python2.7/idlelib/configHandler.pytGetExtensionBindingsùs  cCs2|dd!}|jd||ddƒjƒ}|S(sÊReturn the keybinding list for keySetName eventStr. keySetName - name of key binding set (config-keys section). eventStr - virtual event, including brackets, as in '<>'. iiþÿÿÿRCRRz(RdR¤(Rt keySetNameteventStrR¢R£((s-/usr/lib64/python2.7/idlelib/configHandler.pyt GetKeyBinding s !cCs†|j|jƒƒ}tjdkr‚x[|jƒD]J\}}g|D]}|jddƒ^qD}||kr1|||>' s<>(R¶(RR—((s-/usr/lib64/python2.7/idlelib/configHandler.pyt IsCoreBinding;scCs‡i1ddgd6ddgd6ddgd 6d d gd 6d gd6dgd6dgd6dgd6dgd6dgd6dgd6dgd6dgd6dgd6dgd 6d!gd"6d#gd$6d%gd&6d'gd(6d)gd*6d+gd,6d-gd.6d/gd06d1gd26d3gd46d5gd66d7gd86d9gd:6d;gd<6d=gd>6d?d@gdA6dBgdC6dDgdE6dFgdG6dHgdI6dJgdK6dLgdM6dNdOgdP6dQgdR6dSgdT6dUgdV6dWgdX6dYgdZ6d[gd\6d]gd^6d_gd`6dagdb6dcgdd6degdf6}|rƒxx|D]m}|j||ƒ}|r:|||s s<>s s s<>s s s <>s ss<>s s<>s s<>ss<>s<>s s<>ss<>s s<>ss<>ss<>s<>ss<>s s<>ss<>ss<>s s<>s s<>s s<>s s<>s s<>ss<>s s<>ss<>s s<>ss<>ss<>s s<>s ss<>ss<>s s<>s s<>s s <>ss <>ss<>s ss<>s s<>ss<>ss<>s s<>s s<>s s<>s s<>s s<>s s<>ss<>ss<>s� Warning: configHandler.py - IdleConf.GetCoreKeys - problem retrieving key binding for event %r from key set %r. returning default value: %rR (R«RXRNRYR:(RR©t keyBindingsRšR£Rc((s-/usr/lib64/python2.7/idlelib/configHandler.pyR¶Fs|                                                      c Csg}|dkr"|jd}n(|dkr>|jd}n tdƒ‚|jdƒ}xž|D]–}|jd|ddƒ}|jdƒdkr¢d}d}n/|jdƒ}|d jƒ}|d jƒ}|r`|r`|j|||fƒq`q`W|j d d „ƒ|S( sºReturn 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'. ReR@RsInvalid configSet specifiedt HelpFilest;iÿÿÿÿRziitkeycSst|dƒS(Ni(R(R´((s-/usr/lib64/python2.7/idlelib/configHandler.pyt°Rz( RFRERR RtfindR¤tstripR„R’( RRft helpSourcesRgRRR1tmenuItemthelpPath((s-/usr/lib64/python2.7/idlelib/configHandler.pytGetExtraHelpSourceList“s&       cCs |jdƒ|jdƒ}|S(s†Return a list of the details of all additional help sources. Tuples in the list are those of GetExtraHelpSourceList. RRe(RÅ(RtallHelpSources((s-/usr/lib64/python2.7/idlelib/configHandler.pytGetAllExtraHelpSourcesList³s c Csý|j||dddƒ}|j||dddddƒ}|j||ddd dd ƒ}|d krätd kr~d }qätdd dtd|ƒ}tj|ƒ}|d}|d}|d krÑd}n|ddk}n|||rödndfS(s‡Retrieve a font from configuration (font, font-size, font-bold) Intercept the special value 'TkFixedFont' and substitute the actual font, factoring in some tweaks if needed for appearance sakes. The 'root' parameter can normally be any valid Tkinter widget. Return a tuple (family, size, weight) suitable for passing to tkinter.Font tfontRtcouriers font-sizeRRt10s font-boldiRt TkFixedFontg!@tCourierR{R5troottfamilytsizei tweighttboldtnormal(RdRRR0tactual( RRÍRaRRÎRÏRÑtft actualFont((s-/usr/lib64/python2.7/idlelib/configHandler.pytGetFont¼s          cCs:x3|jD](}|j|jƒ|j|jƒq WdS(sLoad all configuration files.N(RER"RF(RR¾((s-/usr/lib64/python2.7/idlelib/configHandler.pyRIÙscCs)x"|jD]}|j|jƒq WdS(s2Write all loaded user configuration files to disk.N(RFR>(RR¾((s-/usr/lib64/python2.7/idlelib/configHandler.pytSaveUserCfgFilesßsN( RRR#RRHROR$R0R%RdR2RhRuRnR}RRŒRƒR›R–R·R¨R«RœR­RºR¶RÅRÇRÖRIR×(((s-/usr/lib64/python2.7/idlelib/configHandler.pyR?�s8   -    @  #       M  RJ(tcrc32icCs?t|ƒ}td7at|jddƒtƒat|ƒdS(Nitencodingsutf-8(tstrtlineRØtencodetcrcRX(tobjttxt((s-/usr/lib64/python2.7/idlelib/configHandler.pytsprintís  cCsÀtd|dƒx©t|jƒƒD]•}||jƒ}t|ƒt|ƒxh|D]`}||j|ƒ}t|ƒt|ƒx0|D](}t|d||j||ƒƒqˆWqTWq#WdS(Ns s = (RXtsortedRCR)RàRR(RGR¾R)RRR((s-/usr/lib64/python2.7/idlelib/configHandler.pytdumpCfgõs      s lines = s, crc = tsepRz(R#t __future__RR3RNRtTkinterRttkFontRRt ExceptionRRR R R R&R?tidleConfRtzlibRØRÛRÝRàRâRERFRX(((s-/usr/lib64/python2.7/idlelib/configHandler.pyts0  'GÿÿW