KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21585/root/usr/lib64/python2.4/idlelib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21585/root/usr/lib64/python2.4/idlelib/configHandler.pyc
m
=5Dc@s*dZdkZdkZdkZdklZlZlZdefdYZdefdYZ	defdYZ
d	efd
YZdefdYZd
efdYZ
dfdYZeZedjo?dZeeieeieididdGHndS(sProvides 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.

N(sConfigParsers
NoOptionErrorsNoSectionErrortInvalidConfigTypecBstZRS(N(t__name__t
__module__(((t-/usr/lib64/python2.4/idlelib/configHandler.pyRstInvalidConfigSetcBstZRS(N(RR(((RRstInvalidFgBgcBstZRS(N(RR(((RRstInvalidThemecBstZRS(N(RR(((RRstIdleConfParsercBs;tZdZedZeedZdZdZRS(sI
    A ConfigParser specialised for idle configuration file handling
    cCs ||_ti|d|dS(sK
        cfgFile - string, fully specified configuration file name
        tdefaultsN(tcfgFiletselftfiletConfigParsert__init__tcfgDefaults(R
R	R((RR
"s	cCsi|djo
|i}n$|djo
|i}n
|i}|i||o|||Sn|SdS(s
        Get an option value for given section/option or return default.
        If type is specified, return as type.
        tbooltintN(
ttypeR
t
getbooleantgetValtgetinttgett
has_optiontsectiontoptiontdefault(R
RRRRR((RtGet)s



	cCs)|i|o|i|SngSdS(s6
        Get an option list for given section
        N(R
thas_sectionRtoptions(R
R((Rt
GetOptionList:scCs|i|idS(s7
        Load the configuration file from disk
        N(R
treadR(R
((RtLoadCs(RRt__doc__tNoneR
RRR(((RRs
		tIdleUserConfParsercBsMtZdZdZdZdZdZdZdZdZ	RS(sG
    IdleConfigParser specialised for user configuration handling.
    cCs%|i|p|i|ndS(s2
        if section doesn't exist, add it
        N(R
RRtadd_section(R
R((Rt
AddSectionNscCs<x5|iD]'}|i|p|i|q
q
WdS(s:
        remove any sections that have no options
        N(R
tsectionsRRtremove_section(R
R((RtRemoveEmptySectionsUs

cCs'|i|iodSndSdS(sp
        Remove empty sections and then return 1 if parser has no sections
        left, else return 0.
        iiN(R
R'R%(R
((RtIsEmpty]s


cCs(|i|o|i||SndS(sl
        If section/option exists, remove it.
        Returns 1 if option was removed, 0 otherwise.
        N(R
RRt
remove_optionR(R
RR((RtRemoveOptionhscCs|i||o<|i|||jodSq|i|||dSn9|i|p|i|n|i|||dSdS(s
        Sets option to value, adding section if required.
        Returns 1 if option was added or changed, otherwise 0.
        iiN(	R
RRRRtvaluetsetRR#(R
RRR+((Rt	SetOptionpscCs.tii|ioti|indS(sF
        Removes the user config file from disk if it exists.
        N(tostpathtexistsR
Rtremove(R
((Rt
RemoveFilescCs>|ip#t|id}|i|n|idS(sUpdate 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(topenRR	twriteR2(R
R	((RtSaves

(
RRR R$R'R(R*R-R2R6(((RR"Is						tIdleConfcBstZdZdZdZdZeeedZdZ	dZ
edZdZd	Z
d
ZeeedZdZd
ZdZdZdZdZdZdZdZedZdZdZdZdZdZRS(s
    holds config parsers for all idle config files:
    default config files
        (idle install dir)/config-main.def
        (idle install dir)/config-extensions.def
        (idle install dir)/config-highlight.def
        (idle install dir)/config-keys.def
    user config  files
        (user home dir)/.idlerc/config-main.cfg
        (user home dir)/.idlerc/config-extensions.cfg
        (user home dir)/.idlerc/config-highlight.cfg
        (user home dir)/.idlerc/config-keys.cfg
    cCs3h|_h|_h|_|i|idS(N(R
t
defaultCfgtuserCfgtcfgtCreateConfigHandlerstLoadCfgFiles(R
((RR
s
			
cCstdjotiit}ntiitid}|i	}d}h}h}xP|D]H}tii|d|d||<tii|d|d	||<qaWx<|D]4}t|||i|<t|||i|<qWd
S(sp
        set up a dictionary of config parsers for default and user
        configurations respectively
        t__main__itmaint
extensionst	highlighttkeyssconfig-s.defs.cfgN(smainR?s	highlightskeys(RR.R/tdirnamet__file__tidleDirtabspathtsysR
t
GetUserCfgDirtuserDirtconfigTypestdefCfgFilestusrCfgFilestcfgTypetjoinRR8R"R9(R
RDRKRJRLRHRI((RR;s 
!%cCsd}tiid}|djo?tii|p(d|d}tii	|d}qdn|djoti
}ntii||}tii|pUyti|Wqt
tfj
o+d|d}tii	|tqXn|S(sr
        Creates (if required) and returns a filesystem directory for storing
        user config files.

        s.idlerct~s.
 Warning: os.path.expanduser("~") points to
 s ,
 but the path does not exist.
s2
 Warning: unable to create user config directory
s)
 Check path and permissions.
 Exiting!

N(tcfgDirR.R/t
expanduserRHR0twarnRFtstderrR5tgetcwdRMtmkdirtOSErrortIOErrort
SystemExit(R
RORQRH((RRGs&

cCs|i|i||o!|i|i||d|Snn|i|i||o!|i|i||d|Sn3|o'd|||f}ti
i|n|SdS(sf
        Get an option value for given config type and given general
        configuration section/option or return a default. If type is specified,
        return as type. Firstly the user configuration is checked, with a
        fallback to the default configuration, and a final 'catch all'
        fallback to a useable passed-in default if the option isn't present in
        either the user or the default configuration.
        configType must be one of ('main','extensions','highlight','keys')
        If a default is returned, and warn_on_default is True, a warning is
        printed to stderr.

        Rs
 Warning: configHandler.py - IdleConf.GetOption -
 problem retrieving configration option %r
 from section %r.
 returning default value: %r
N(R
R9t
configTypeRRRRRR8twarn_on_defaultRtwarningRFRRR5(R
RXRRRRRYRZ((Rt	GetOptions
!!cCs|i|i|||dS(s?In user's config file, set section's option to value.

        N(R
R9RXR-RRR+(R
RXRRR+((RR-scCsi|d
jo
tdn|djo|i|}n(|djo|i|}n
td|iS(s
        Get a list of sections from either the user or default config for
        the given config type.
        configSet must be either 'user' or 'default'
        configType must be one of ('main','extensions','highlight','keys')
        R>R?R@RAsInvalid configType specifiedtuserRsInvalid configSet specifiedN(smains
extensionss	highlightskeys(	RXRt	configSetR
R9t	cfgParserR8RR%(R
R]RXR^((RtGetSectionLists



	cCs|idi|o|id|}n|id|}||d}|djo|d}n||d}hd|<d	|<}|p|Sn<|d
jo|dSn|djo|d	Sn
tdd
S(s$
        return individual highlighting theme elements.
        fgBg - string ('fg'or'bg') or None, if None return a dictionary
        containing fg and bg colours (appropriate for passing to Tkinter in,
        e.g., a tag_config call), otherwise fg or bg colour only as specified.
        R@RR\s-foregroundtcursorsnormal-backgrounds-backgroundt
foregroundt
backgroundtfgtbgsInvalid fgBg specifiedN(R
R8RtthemetGetThemeDictt	themeDicttelementtforetbackR@tfgBgR(R
ReRhRkRgRjRiR@((RtGetHighlights 


cCs|djo|id}n(|djo|id}n
tdhdd<dd<d	d<d
d<dd<dd<d
d<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<d d<d!d<d"d<}xx|iD]j}|i	||p+d#||||f}ti
i|n|i||d||}|||<qKW|S(%sj
        type - string, 'default' or 'user' theme type
        themeName - string, theme name
        Returns a dictionary which holds {option:value} for each element
        in the specified theme. Values are loaded over a set of ultimate last
        fallback defaults to guarantee that all theme elements are present in
        a newly created theme.
        R\R@RsInvalid theme type specifiedsnormal-foregrounds#000000snormal-backgrounds#ffffffskeyword-foregroundskeyword-backgroundsbuiltin-foregroundsbuiltin-backgroundscomment-foregroundscomment-backgroundsstring-foregroundsstring-backgroundsdefinition-foregroundsdefinition-backgroundshilite-foregroundshilite-backgroundtgraysbreak-foregroundsbreak-backgroundshit-foregroundshit-backgroundserror-foregroundserror-backgroundscursor-foregroundsstdout-foregroundsstdout-backgroundsstderr-foregroundsstderr-backgroundsconsole-foregroundsconsole-backgrounds
 Warning: configHandler.py - IdleConf.GetThemeDict -
 problem retrieving theme element %r
 from theme %r.
 returning default value: %r
N(RR
R9R^R8RReRARhRt	themeNameRZRFRRR5Rtcolour(R
RRnRoRhReRZR^((RRf*s

	
cCs|idddddS(s@
        Returns the name of the currently active theme
        R>tThemetnameRtN(R
R[(R
((RtCurrentThemegscCs|idddddS(sB
        Returns the name of the currently active key set
        R>tKeysRqRRrN(R
R[(R
((RtCurrentKeysmsc	Cs(|i|idd}|i|idd}x,|D]$}||jo|i|q=q=W|og}x|D]}|i	d|ddt
ddos|p|oT|o
d}nd}|i	d||dt
ddd	to|i|qq|i|qyqyW|Sn|Sd
S(s
        Gets a list of all idle extensions declared in the config files.
        active_only - boolean, if true only return active (enabled) extensions
        RR?R\tenableRRt
enable_editortenable_shellRYN(R
tRemoveKeyBindNamesR_textnst	userExtnstextntappendtactive_onlytactiveExtnsR[tTrueteditor_onlyt
shell_onlyRtFalse(	R
R~RRRzRR|R{R((Rt
GetExtensionsss0



cCs|}g}xH|D]@}|idp|ido|i|i|qqW|i|ix|D]
}||=qrW|S(Nt	_bindingst_cfgBindings(	textnNameListtnamestkbNameIndiciesRqtendswithR}tindextsorttreverse(R
RRRqRR((RRys 

cCsld}d|d}xQ|iddD]=}x4|i|iD]}||jo
|}qCqCWq'W|S(s
        Returns the name of the extension that virtualEvent is bound in, or
        None if not bound in any extension.
        virtualEvent - string, name of the virtual event to test for, without
                       the enclosing '<< >>'
        s<<s>>R~iN(
R!textNametvirtualEventtvEventR
RR|tGetExtensionKeysRAtevent(R
RRRR|R((RtGetExtnNameForEvents
c	Cs|d}|i}h}|idi|oM|idi|}x4|D](}d|d}||}|||<qPWn|S(s
        returns a dictionary of the configurable keybindings for a particular
        extension,as they exist in the dictionary returned by GetCurrentKeySet;
        that is, where previously used bindings are disabled.
        RR?s<<s>>N(
t
extensionNametkeysNameR
tGetCurrentKeySett
activeKeystextKeysR8RRt
eventNamest	eventNameRtbinding(	R
RRRRRRRR((RRs

cCs|d}h}|idi|od|idi|}xK|D]?}|i	d||ddi
}d|d}|||<qDWn|S(s
        returns a dictionary of the configurable keybindings for a particular
        extension, as defined in the configuration files, or an empty dictionary
        if no bindings are found
        RR?RRrs<<s>>N(
RRRR
R8RRRRR[tsplitRR(R
RRRRRRR((Rt__GetRawExtensionKeyss
cCs|d}|i|}|idi|od|idi|}xK|D]?}|i
d||ddi}d|d}|||<qMWn|S(s

        Returns a dictionary of all the event bindings for a particular
        extension. The configurable keybindings are returned as they exist in
        the dictionary returned by GetCurrentKeySet; that is, where re-used
        keybindings are disabled.
        RR?RRrs<<s>>N(Rt	bindsNameR
RtextBindsR8RRRRR[RRR(R
RRRRRRR((RtGetExtensionBindingss
cCs2|dd!}|id||ddi}|S(s
        returns the keybinding for a specific event.
        keySetName - string, name of key binding set
        eventStr - string, the virtual event we want the binding for,
                   represented as a string, eg. '<<event>>'
        iiRARRrN(teventStrRR
R[t
keySetNameRR(R
RRRR((Rt
GetKeyBindings
!cCs|i|iS(N(R
t	GetKeySetRu(R
((RRscCs|i|}|idd}xr|D]j}|i|}|oNxK|i	D]9}|||ijod||<n||||<qQWq(q(W|S(s
        Returns a dictionary of: all requested core keybindings, plus the
        keybindings for all currently active extensions. If a binding defined
        in an extension is already in use, that binding is disabled.
        R~iRrN(R
tGetCoreKeysRtkeySetRRR|t_IdleConf__GetRawExtensionKeysRRARtvalues(R
RRRRR|R((RRs
cCsd|d|iijS(s
        returns true if the virtual event is bound in the core idle keybindings.
        virtualEvent - string, name of the virtual event to test for, without
                       the enclosing '<< >>'
        s<<s>>N(RR
RRA(R
R((Rt
IsCoreBindingscCshdddg<dddg<ddd	g<d
ddg<d
dg<ddg<ddg<ddg<ddg<ddg<ddg<ddg<ddg<ddg<dd g<d!d"g<d#d$g<d%d&g<d'd(g<d)d*g<d+d,g<d-d.g<d/d0g<d1d2g<d3d4g<d5d6g<d7d8g<d9d:g<d;d<g<d=d>g<d?d@dAg<dBdCg<dDdEg<dFdGg<dHdIg<dJdKg<dLdMg<dNdOg<dPdQg<dRdSg<dTdUg<dVdWg<dXdYg<dZd[g<d\d]g<d^d_g<d`dag<}|oixb|iD]T}|i||}|o|||<n(db||||f}ti	i
|q]Wn|SdcS(dsZ
        returns the requested set of core keybindings, with fallbacks if
        required.
        Keybindings loaded from the config file(s) are loaded _over_ these
        defaults, so if there is a problem getting any core binding there will
        be an 'ultimate last resort fallback' to the CUA-ish bindings
        defined here.
        s<<copy>>s<Control-c>s<Control-C>s<<cut>>s<Control-x>s<Control-X>s	<<paste>>s<Control-v>s<Control-V>s<<beginning-of-line>>s<Control-a>s<Home>s<<center-insert>>s<Control-l>s<<close-all-windows>>s<Control-q>s<<close-window>>s<Alt-F4>s<<do-nothing>>s<<end-of-file>>s<Control-d>s<<python-docs>>s<F1>s<<python-context-help>>s
<Shift-F1>s<<history-next>>s<Alt-n>s<<history-previous>>s<Alt-p>s<<interrupt-execution>>s<<view-restart>>s<F6>s<<restart-shell>>s<Control-F6>s<<open-class-browser>>s<Alt-c>s<<open-module>>s<Alt-m>s<<open-new-window>>s<Control-n>s<<open-window-from-file>>s<Control-o>s<<plain-newline-and-indent>>s<Control-j>s<<print-window>>s<Control-p>s<<redo>>s<Control-y>s<<remove-selection>>s<Escape>s<<save-copy-of-window-as-file>>s
<Alt-Shift-S>s<<save-window-as-file>>s<Alt-s>s<<save-window>>s<Control-s>s<<select-all>>s<Alt-a>s<<toggle-auto-coloring>>s<Control-slash>s<<undo>>s<Control-z>s<<find-again>>s<Control-g>s<F3>s<<find-in-files>>s<Alt-F3>s<<find-selection>>s<Control-F3>s<<find>>s<Control-f>s<<replace>>s<Control-h>s
<<goto-line>>s<Alt-g>s<<smart-backspace>>s<Key-BackSpace>s<<newline-and-indent>>s<Key-Return> <Key-KP_Enter>s<<smart-indent>>s	<Key-Tab>s<<indent-region>>s<Control-Key-bracketright>s<<dedent-region>>s<Control-Key-bracketleft>s<<comment-region>>s<Alt-Key-3>s<<uncomment-region>>s<Alt-Key-4>s<<tabify-region>>s<Alt-Key-5>s<<untabify-region>>s<Alt-Key-6>s<<toggle-tabs>>s<Alt-Key-t>s<<change-indentwidth>>s<Alt-Key-u>s
 Warning: configHandler.py - IdleConf.GetCoreKeys -
 problem retrieving key binding for event %r
 from key set %r.
 returning default value: %r
N(tkeyBindingsRRARR
RRRZRFRRR5(R
RRRZRR((RRsK1
c	Csg}|djo|id}n(|djo|id}n
td|id}x|D]}|i
d|dd}|iddjod}d}n3ti|d}|d	i}|d
i}|o!|o|i|||fqaqaW|i|i|S(sFetch 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'.

        R\R>RsInvalid configSet specifiedt	HelpFilest;iRriiN(thelpSourcesR]R
R9R^R8RRRRRR+tfindtmenuItemthelpPathtstringRtstripR}Rt_IdleConf__helpsort(	R
R]R^RRR+RRR((RtGetExtraHelpSourceListVs*	

	
cCsZt|dt|djodSn.t|dt|djodSndSdS(Niiii(Rth1th2(R
RR((Rt
__helpsortvs
!!cCs |id|id}|S(s
        Returns a list of tuples containing the details of all additional help
        sources configured, or an empty list if there are none. Tuples are of
        the format returned by GetExtraHelpSourceList.
        RR\N(R
RtallHelpSources(R
R((RtGetAllExtraHelpSourcesList~scCs@x9|iiD](}|i|i|i|iqWdS(s/
        load all configuration files.
        N(R
R8RAtkeyRR9(R
R((RR<s
cCs/x(|iiD]}|i|iqWdS(sH
        write all loaded user configuration files back to disk
        N(R
R9RARR6(R
R((RtSaveUserCfgFiless( RRR R
R;RGR!RR[R-R_RlRfRsRuRRRyRRRRRRRRRRRRR<R(((RR7s6
						=		!	
								H	 		
	R=cCsdG|GdGHx|iD]|}||i}|GH|GHxY|D]Q}||i|}|GH|GHx+|D]#}|GdG||i||GHqkWqAWqWdS(Ns
t=(R:RARR%RRRR(R:RRRR%R((RtdumpCfgs

R>RpRq(R R.RFRRt
NoOptionErrortNoSectionErrort	ExceptionRRRRRR"R7tidleConfRRR8R9R(RRRRR"RR7RFRRRRR.RR((Rt?s&			+L	
	



Anon7 - 2021