e0SrSSKJr SSKrSSKrSSKJr SSKr"SS\5r "SS\5r "S S \5r "S S \5r "S S\ 5r "SS5r\"5r\"5rSr"SS\5rSr\S:XaSSKJr \"SSSS9 \"5 gg)aDidlelib.config -- Manage IDLE configuration information. The comments at the beginning of config-main.def describe the 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 user file becomes empty, it will be deleted. The configuration database maps options to values. Conceptually, the database keys are tuples (config-type, section, item). As implemented, there are separate dicts for default and user values. Each has config-type keys 'main', 'extensions', 'highlight', and 'keys'. The value for each key is a ConfigParser instance that maps section and item to values. For 'main' and 'extensions', user values override default values. For 'highlight' and 'keys', user sections augment the default sections (and must, therefore, have distinct names). Throughout this module there is an emphasis on returning usable 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. ) ConfigParserN)Fontc\rSrSrSrg)InvalidConfigType#N__name__ __module__ __qualname____firstlineno____static_attributes__r4/opt/imh/python3.13/lib/python3.13/idlelib/config.pyrr#sDrrc\rSrSrSrg)InvalidConfigSet$rNr rrrrr$s4rrc\rSrSrSrg) InvalidTheme%rNr rrrrr%strrc8\rSrSrSrS SjrS SjrSrSrSr g) IdleConfParser'zA A ConfigParser specialised for idle configuration file handling Nc:Xl[R"XSS9 g)z; cfgFile - string, fully specified configuration file name F)defaultsstrictN)filer__init__)selfcfgFile cfgDefaultss rrIdleConfParser.__init__+s dGrcURX5(dU$US:XaURX5$US:XaURX5$URXUS9$)zg Get an option value for given section/option or return default. If type is specified, return as type. boolintraw) has_option getbooleangetintget)rsectionoptiontypedefaultr's rGetIdleConfParser.Get2sWw//N 6>??73 3 U];;w/ /88G85 5rcTURU5(aURU5$/$)z4Return a list of options for given section, else [].) has_sectionoptionsrr,s r GetOptionListIdleConfParser.GetOptionListCs'   G $ $<<( (Irc^UR(aURUR5 gg)z&Load the configuration file from disk.N)rreadrs rLoadIdleConfParser.LoadJs 99 IIdii  rrN)NNF) r r r r __doc__rr0r6r;rrrrrr'sH6"!rrc<\rSrSrSrSrSrSrSrSr Sr S r g ) IdleUserConfParserOz? IdleConfigParser specialised for user configuration handling. cURX5(a)URX5U:XagURXU5 gURU5(dUR U5 URXU5 g)zReturn True if option is added or changed to value, else False. Add section if required. False means option already had value. FT)r(r+setr3 add_section)rr,r-values r SetOptionIdleUserConfParser.SetOptionTsh ??7 + +xx(E1%0##G,,  ) HHWe ,rcRURU5(aURX5$g)z{Return True if option is removed from section, else False. False if either section does not exist or did not have option. F)r3 remove_option)rr,r-s r RemoveOptionIdleUserConfParser.RemoveOptiones)   G $ $%%g6 6rcTURU5(dURU5 gg)z!If section doesn't exist, add it.N)r3rEr5s r AddSectionIdleUserConfParser.AddSectionns&((   W %)rcUR5H,nURU5(aMURU5 M. g)z)Remove any sections that have no options.N)sectionsr6remove_sectionr5s rRemoveEmptySections&IdleUserConfParser.RemoveEmptySectionsss1}}G%%g..##G,'rcLUR5 UR5(+$)z9Return True if no sections after removing empty sections.)rSrQr:s rIsEmptyIdleUserConfParser.IsEmptyys   "==?""rcURnU(aUSS:waUR5(d*[US5nU UR U5 SSS5 g[RRUR5(a![R"UR5 gggg![a% [R "U5 [US5nNf=f!,(df  g=f)zUpdate user configuration file. If self not empty after removing empty sections, write the file to disk. Otherwise, remove the file from disk if it exists. r#wN) rrVopenOSErrorosunlinkwritepathexistsremove)rfnamer s rSaveIdleUserConfParser.Save~s   U1X_<<>>/"5#.GJJw'W ** $))$+%5/IIe$"5#.G/Ws B.C .,CC C.rN) r r r r r?rGrKrNrSrVrdrrrrrArAOs%"& - # %rrAc\rSrSrSrS"SjrSrSrS#SjrSr S r S r S r S r S rSr\S5rS$SjrSrSrSrSrSrSrSrSrSr1SkrS%SjrSrSrSr Sr!S r"S!r#g)&IdleConfaPHold 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 cSUl0Ul0Ul0UlU(d!UR 5 UR 5 gg)N)main highlightkeys extensions) config_types defaultCfguserCfgcfgCreateConfigHandlers LoadCfgFiles)r_utests rrIdleConf.__init__sAG    % % '    rc [RR[5n[R (aSOUR 5=UlnURHn[[RRUSUS355URU'[[RRU=(d SSUS355URU'M g)z5Populate default and user config parser dictionaries.zconfig-z.defrYz.cfgN)r]r`dirname__file__idlelibtesting GetUserCfgDiruserdirrnrjoinrorArp)ridledirr}cfg_types rrrIdleConf.CreateConfigHandlerss''//(+'.D?)ADOOH %%7 W^wxj-EF&HDLL "*rcSn[RRS5nUS:wa\[RRU5(d8[R (d!SU-S-n[ U[RS9 SnUS:Xa[R"5n[RRX!5n[RRU5(d[R"U5 U$U$![a Nf=f![aX [R (d<SU-S-n[ U[RS9 [e![a [ef=f[ef=f)zVReturn a filesystem directory for storing user config files. Creates it if required. z.idlerc~z. Warning: os.path.expanduser("~") points to z, but the path does not exist.r=z2 Warning: unable to create user config directory z( Check path and permissions. Exiting! )r]r` expanduserrarzr{printsysstderrr\getcwdr~mkdir SystemExit)rcfgDiruserDirwarns rr|IdleConf.GetUserCfgDirs= ''$$S) c>77>>'**N#$&HIDd4 c>iikG'',,w/ww~~g&& !!w)# !R#$&STDd4! #     !sB*C=#D = D  D  'E/5E E/ E%E/$E%% E/NcURURX#5(aURURX#XWS9$UR URX#5(aUR URX#XWS9$U(aSU<SU<SU<3n[ XX#5 U$![a< SU<SU<SU<SURURX#US9<3n[ XX#5 Nf=f![a Nxf=f) aReturn a value for configType section option, or default. If type is not None, return a value of that type. Also pass raw to the config parser. First try to return a valid value (including type) from a user configuration. If that fails, try the default configuration. If that fails, return default, with a default of None. Warn if either user or default configurations have an invalid value. Warn if default is returned and warn_on_default is True. )r.r'z5 Warning: config.py - IdleConf.GetOption - invalid z value for configuration option z from section z: r&zU Warning: config.py - IdleConf.GetOption - problem retrieving configuration option . returning default value: )rpr(r0 ValueError_warnro) r configTyper,r-r/r.warn_on_defaultr'warnings r GetOptionIdleConf.GetOptions 8||J'227CC||J/33G9=4HHD z*55gEEz266d7==F   2G 'w 7+ 8fg||J/33G3M OG 'w 7  8   s$?B(?C1(AC.-C.1 C>=C>cBURURX#U5 g)z0Set section option to value in user config file.N)rprG)rrr,r-rFs rrGIdleConf.SetOptions Z **7EBrcX R;a [S5eUS:XaURUnUR 5$US:XaURUnUR 5$[ S5e)zReturn sections for configSet configType configuration. configSet must be either 'user' or 'default' configType must be in self.config_types. zInvalid configType specifieduserr/Invalid configSet specified)rnrrprorrQ)r configSetr cfgParsers rGetSectionListIdleConf.GetSectionListsz ///#$BC C   Z0I !!## ) #ooj1I!!####@A ArcURSRU5(aSOSnURX15nXBS-nUS:XaSnXBS-nXVS.$) zReturn dict of theme element highlight colors. The keys are 'foreground' and 'background'. The values are tkinter color strings for configuring backgrounds and tags. rkr/rz -foregroundcursornormalz -background) foreground background)ror3 GetThemeDict)rthemeelementrq theme_dictforebacks r GetHighlightIdleConf.GetHighlightsh !OOK8DDUKKy &&s2 M12 h GM12"77rcUS:XaURSnO!US:XaURSnO [S5e0SS_SS_S S_S S_S S_S S_S S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSSSS.EnUH`nURX%5(d3UR S5(dSU<SU<SXE<3n[ USX%5 UR X%XES9XE'Mb U$)aReturn {option:value} dict for elements in themeName. type - string, 'default' or 'user' theme type themeName - string, theme name Values are loaded over ultimate fallback defaults to guarantee that all theme elements are present in a newly created theme. rrkr/zInvalid theme type specifiedznormal-foregroundz#000000znormal-backgroundz#ffffffzkeyword-foregroundzkeyword-backgroundzbuiltin-foregroundzbuiltin-backgroundzcomment-foregroundzcomment-backgroundzstring-foregroundzstring-backgroundzdefinition-foregroundzdefinition-backgroundzhilite-foregroundzhilite-backgroundgrayzbreak-foregroundzbreak-backgroundzhit-foreground)zhit-backgroundzerror-foregroundzerror-backgroundzcontext-foregroundzcontext-backgroundzlinenumber-foregroundzlinenumber-backgroundzcursor-foregroundzstdout-foregroundzstdout-backgroundzstderr-foregroundzstderr-backgroundzconsole-foregroundzconsole-background)zcontext-z linenumber-zL Warning: config.IdleConf.GetThemeDict - problem retrieving theme element z from theme z. returning default color: r/)rprorr( startswithrr0)rr. themeNamerrrrs rrIdleConf.GetThemeDict"s 6> [1I Y  4I=> > !#I!#I!$Y!%Y!%Y ! %Y ! %Y !%Y!$I!$I!( !( !$I!$F!#9!#9! !!!""+#,#,%.%.(1(1$-$-$-$-$-%.%.A!DG((<<&&'BCC $Y @ g{I?&]]+@EN rc$URS5$)z9Return the name of the currently active text color theme.Themecurrent_colors_and_keysr:s r CurrentThemeIdleConf.CurrentThemefs++G44rc$URS5$)z0Return the name of the currently active key set.Keysrr:s r CurrentKeysIdleConf.CurrentKeysjs++F33rcTUS:XaSOSnURSUSSSS9nS nU(aURSUS S S 9nU(dURSUS S S 9nU(a9U(a URO URnXRRU5(aU$US:XaS $UR 5$)a~Return the currently active name for Theme or Keys section. idlelib.config-main.def ('default') includes these sections [Theme] default= 1 name= IDLE Classic name2= [Keys] default= 1 name= name2= Item 'name2', is used for built-in ('default') themes and keys added after 2015 Oct 1 and 2016 July 1. This kludge is needed because setting 'name' to a builtin not defined in older IDLEs to display multiple error messages or quit. See https://bugs.python.org/issue25313. When default = True, 'name2' takes precedence over 'name', while older IDLEs will just use name. When default = False, 'name2' may still be set, but it is ignored. rrkrlrjr/r$Tr.r/rwname2rnamez IDLE Classic)rrorpr3 default_keys)rr,cfgnamer/rsources rr IdleConf.current_colors_and_keysns0")G!3+..)&,d!< >>&'7B>GD>>&'62>FD (/T__T\\F**400 !(G!3~L9J9J9LLrc^[RSSS:Xag[RS:Xagg)NwinzIDLE Classic WindowsdarwinzIDLE Classic OSXzIDLE Modern Unix)rplatformrrrrIdleConf.default_keyss* << u $) \\X %%%rc  URURSS55nURURSS55nUHnXd;dM URU5 M SHnURU5 M U(a/nUHunUR SUSSSS9(dMU(dU(a9U(aS nOS nUR SXhSSS S 9(aURU5 MbMdURU5 Mw U$U$) zReturn extensions in default and user config-extensions files. If active_only True, only return active (enabled) extensions and optionally only editor or shell extensions. If active_only False, return all extensions. r/rmr) AutoComplete CodeContextFormatParagraph ParenMatchenableTr$r/r. enable_editor enable_shellF)r/r.r)RemoveKeyBindNamesrappendrbr) r active_only editor_only shell_onlyextns userExtnsextn activeExtnsr-s r GetExtensionsIdleConf.GetExtensionss''##I|<>++##FL9; D  T"5D LL 5 K>>,h'-"//#j&%4F%3F>>,26V:?*A(..t4A $**40 Lrc`UVs/sHo"RS5(aMUPM sn$s snf)z:Return extnNameList with keybinding section names removed.) _bindings _cfgBindings)endswith)r extnNameListns rrIdleConf.RemoveKeyBindNamess$'Y>' N<<>>rr)rGetExtensionKeys)r virtualEventextNamevEventrevents rGetExtnNameForEventIdleConf.GetExtnNameForEventsV  $t+&&1&5D..t4?"G56rcUS-nUR5n0nURSRU5(a7URSRU5nUHnSU-S-nX7nXU'M U$)zReturn dict: {configurable extensionName event : active keybinding}. Events come from default config extension_cfgBindings section. Keybindings come from GetCurrentKeySet() active key dict, where previously used bindings are disabled. rrmrr)GetCurrentKeySetror3r6) r extensionNamekeysName activeKeysextKeys eventNames eventNamerbindings rrIdleConf.GetExtensionKeyss!>1**,  ??< ( 4 4X > >6DDXNJ' y(4/$+!((rcUS-n0nURSRU5(aRURSRU5nUH.nURSX%SS9R 5nSU-S-nXcU'M0 U$)zReturn dict {configurable extensionName event : keybinding list}. Events come from default config extension_cfgBindings section. Keybindings list come from the splitting of GetOption, which tries user config before default config. rrmrwrrr)ror3r6rsplit)rrrrrrrrs r__GetRawExtensionKeysIdleConf.__GetRawExtensionKeyss!/ ??< ( 4 4X > >6DDXNJ' ..$h2)GGLuwy(4/!( ( rcUS-nURU5nURSRU5(aRURSRU5nUH.nUR SX%SS9R 5nSU-S-nXcU'M0 U$)zReturn dict {extensionName event : active or defined keybinding}. Augment self.GetExtensionKeys(extensionName) with mapping of non- configurable events (from default config) to GetOption splits, as in self.__GetRawExtensionKeys. rrmrwrrr)rror3r6rr)rr bindsNameextBindsrrrrs rGetExtensionBindingsIdleConf.GetExtensionBindingss"K/ ((7 ??< ( 4 4Y ? ?6DDYOJ' ..$iB)HHMy(4/") ( rcPUSSnURSXSSS9R5nU$)zReturn the keybinding list for keySetName eventStr. keySetName - name of key binding set (config-keys section). eventStr - virtual event, including brackets, as in '<>'. rlrwF)r/r)rr)r keySetNameeventStrrrs r GetKeyBindingIdleConf.GetKeyBindings: QrN ..16!88= rcURUR55n[RS:XaEUR 5H1up#UVs/sHoDR SS5PM nnX5:wdM-XQU'M3 U$s snf)z/Return CurrentKeys with 'darwin' modifications.rz>' rr)r)rrs r IsCoreBindingIdleConf.IsCoreBinding>s" \!$&4+;+;+===r> <><><><><><><><><>c H0SSS/_SSS/_SSS /_S S S /_S S/_SS/_SS/_SS/_SS/_SS/_SS/_SS/_SS/_SS/_SS /_S!S"/_S#S$/_0S%S&/_S'S(/_S)S*/_S+S,/_S-S./_S/S0/_S1S2/_S3S4/_S5S6/_S7S8/_S9S:/_S;S/_S?S@SA/_SBSC/_SDSE/_SFSG/_E0SHSI/_SJSK/_SLSM/_SNSOSP/_SQSR/_SSST/_SUSV/_SWSX/_SYSZ/_S[S\/_S]S^/_S_S`/_SaSb/_ScSd/_SeSf/_SgSh/_SiSj/_ESk/Sl/Sm/Sn/So/Sp/Sq/Sr.EnU(aURSsRU5(d9URSsRU5(dStU<Su3n[USsU5 U$UHOnUR X5nU(aXRU'M!X@R ;dM2SvU<SwU<SxX$<3n[USsX5 MQ U$)yajReturn dict of core virtual-key keybindings for keySetName. The default keySetName None corresponds to the keyBindings base dict. If keySetName is not None, bindings 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. z<>z z z<>z z z <>z z z<>z zz<>z z<>z z<>zz<>z<>z z<>zz<>z z<>zz<>zz<>z<>zz<>z z<>zz<>zz<>z z<>z z<>z z<>z z<>z z<>zz<>z z<>zz<>z z<>zz<>zz<>z z<>z zz<>zz<>z z<>z z <>z z <>zz<>zz<>z zz<>z z<>zz<>zz<>z z<>z z<>z z<>z z<>z z<>z z<>zz<>zr(zr"zzzz zzz z )r'r#r&r!r r%r$rlz7 Warning: config.py - IdleConf.GetCoreKeys - key set z( is not defined, using default bindings.zX Warning: config.py - IdleConf.GetCoreKeys - problem retrieving key binding for event z from key set r)rpr3rorr former_extension_events)rr keyBindingsrrrs rrIdleConf.GetCoreKeysPs<  6<  }5< -7 < $mX%> < - < $m_<  < }o<  < x< & ~<  < #YK< & < !<" .!1#<$ %yk%<&  {'<( "M?)<* (-+<, +]O-<. /<0 1<2 #ZL3<4 ./@5<6 & {7<8  9<: yk;<< '):(;=<> ?<@ }f5A<B *C<D !>"2E<F G<H M?I<J i[K<L "$5#6M<N %~7G&HO<P  Q<R ">!?S<T "=!>U<V !=/W<X #]OY<Z -[<\ "M?]<^  _<` %}oa<b ";!1IdleConf.GetExtraHelpSourceList..sqtr)key) rprorr6r0findrstriprsort) rr helpSourcesrr4r-rFmenuItemhelpPaths rGetExtraHelpSourceListIdleConf.GetExtraHelpSourceLists   V,I ) #/I"#@A A'' 4F-- VS-AEzz#"$kk#&q)q)xHH""Xv$>@ ^,rcLURS5URS5-nU$)zvReturn a list of the details of all additional help sources. Tuples in the list are those of GetExtraHelpSourceList. r/r)r;)rallHelpSourcess rGetAllExtraHelpSourcesList#IdleConf.GetAllExtraHelpSourcesLists- 55i@++F34rc URX#SSS9nURX#SSSS9nURX#SS S S 9nUS :Xa;[S S US9n[R"U5nUSnUSnUS ::aSnUSS:HnXEU(aS4$S4$)aORetrieve 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 fontcourierrz font-sizer%10rz font-boldrr$r TkFixedFontT)rrarootfamilysize weightboldr)rractual) rrFrr,rGrHrKf actualFonts rGetFontIdleConf.GetFonts VYO~~j;U&*,~~j;#)+ m #-4@AQJ)Ff%Dqyh'61Df;;(;;rcURH=nURUR5 URUR5 M? g)zLoad all configuration files.N)ror;rprr4s rrsIdleConf.LoadCfgFiless:??C OOC % % ' LL  " " $#rcdURH nURUR5 M" g)z2Write all loaded user configuration files to disk.N)rprdrRs rSaveUserCfgFilesIdleConf.SaveUserCfgFiless%<)$r r r r r?rrrr|rrGrrrrrr staticmethodrrrrrrrr rr rr*rr;r?rOrsrUrrrrrgrgs   H"HIM,1&PC$ 8BH54$ML&&)-49'RZ $$( "$> `D@<4% %rrgcU4U-nU[;a/[U[RS9 [R U5 gg![a N#f=f)Nr=)_warnedrrrr\add)msgr4s rrrsO &3,C '  #CJJ '  C    sA A AcF\rSrSrSrSrSr\S5rSr Sr Sr S r g ) ConfigChangesiaManage a user's proposed configuration option changes. Names used across multiple methods: page -- one of the 4 top-level dicts representing a .idlerc/config-x.cfg file. config_type -- name of a page. section -- a section within a page/file. option -- name of an option within a section. value -- value for the option. Methods add_option: Add option and value to changes. save_option: Save option and value to config parser. save_all: Save all the changes to the config parser and file. delete_section: If section exists, delete from changes, userCfg, and file. clear: Clear all changes by clearing each page. c/Ul[RH$n0X'URRX5 M& g)z)Create a page for each configuration fileN)pagesidleConfrnr)r config_types rrConfigChanges.__init__!s6 #00K "D  JJ  d/ 01rcBXn[U5nX%;a0XR'XEUU'g)z0Add item/value pair for config_type and section.N)str)rrar,itemrFpages r add_optionConfigChanges.add_option(s, E   DM#W drc&[RURX5(aH[RURX5U:Xa"[RUR X5$[RUR XU5$)zSReturn True if the configuration value was added or changed. Helper for save_all. )r`ror(r0rprKrG)rar,rerFs r save_optionConfigChanges.save_option0sx   { + 6 6w E E"";/33GBeK'' 4AA'PP ,66weLLrc [RSR5 SnUHnSnXnUHcnUS:Xa$[RSRS5 SnXER 5H upgUR X%Xg5(dMSnM" Me U(dM{[RUR5 SnM SH$n[RUR5 M& UR 5 U$)zSave configuration changes to the user config file. Clear self in preparation for additional changes. Return changed for testing. rjFr.T)rlrk)r`rprdrRrrjclear)rchangedracfg_type_changedrfr,rerFs rsave_allConfigChanges.save_all=s  %%'K$ $Dk)$$V,;;KH'+$#'=#6#6#8KD'' dJJ+/($9     -224 1K   [ ) . . 01 rcX U;aXU [RUnURU5 UR5 g)zZDelete a section from self, userCfg, and file. Used to delete custom themes and keysets. N)r`rprRrd)rrar, configpages rdelete_sectionConfigChanges.delete_section[sB ;' '!'*%%k2 !!'*rcJURHnUR5 M g)z~Clear all 4 pages. Called in save_all after saving to idleConf. XXX Mark window *title* when there are changes; unmark here. N)r_rm)rrfs rrmConfigChanges.clearfs JJD JJLr)r_N) r r r r r?rrgrWrjrprtrmrrrrr]r]s6$1$ M M< rr]c^^^^SSKJm SummUUU4SjmU4SjnU"[R5 U"[R5 [ STSTSS 9 g) Nr)crc32)rrch>[U5nTS- mT"URSS9T5m[U5 g)Nrzutf-8)encoding)rdencoder)objtxtcrcrylines rsprint_dump..sprintus3#h  CJJJ0#6 c rc 0>[SUS5 [U5HynXR5nT"U5 T"U5 UHNnXRU5nT"U5 T"U5 UH"nT"US-XR X55-5 M$ MP M{ g)N z = )rsortedrQr4r0)rqr4rQr,r4r-rs rdumpCfg_dump..dumpCfg}s dC#;Cx((*H 3K 8 #(**73ww%F6E>CHLL,IIJ& $ rz lines = z, crc = rw)sep)zlibryr`rorpr)rrryrrs @@@@r_dumprqsHID# K H    H   ,j#26r__main__)rjzidlelib.idle_test.test_configrF) verbosityexit)r? configparserrr]r tkinter.fontrrz ExceptionrrrrrArgr`rDrYrdictr]rr unittestrjrrrrs6& ( ('y'#9#&!\&!P@%@%Dm %m %` : %_D_F7< z (AEB G r