MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / GetOption

Method GetOption

tools/python-3.11.9-amd64/Lib/idlelib/config.py:214–252  ·  view source on GitHub ↗

Return 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 configu

(self, configType, section, option, default=None, type=None,
                  warn_on_default=True, raw=False)

Source from the content-addressed store, hash-verified

212 return userDir
213
214 def GetOption(self, configType, section, option, default=None, type=None,
215 warn_on_default=True, raw=False):
216 """Return a value for configType section option, or default.
217
218 If type is not None, return a value of that type. Also pass raw
219 to the config parser. First try to return a valid value
220 (including type) from a user configuration. If that fails, try
221 the default configuration. If that fails, return default, with a
222 default of None.
223
224 Warn if either user or default configurations have an invalid value.
225 Warn if default is returned and warn_on_default is True.
226 """
227 try:
228 if self.userCfg[configType].has_option(section, option):
229 return self.userCfg[configType].Get(section, option,
230 type=type, raw=raw)
231 except ValueError:
232 warning = ('\n Warning: config.py - IdleConf.GetOption -\n'
233 ' invalid %r value for configuration option %r\n'
234 ' from section %r: %r' %
235 (type, option, section,
236 self.userCfg[configType].Get(section, option, raw=raw)))
237 _warn(warning, configType, section, option)
238 try:
239 if self.defaultCfg[configType].has_option(section,option):
240 return self.defaultCfg[configType].Get(
241 section, option, type=type, raw=raw)
242 except ValueError:
243 pass
244 #returning default, print warning
245 if warn_on_default:
246 warning = ('\n Warning: config.py - IdleConf.GetOption -\n'
247 ' problem retrieving configuration option %r\n'
248 ' from section %r.\n'
249 ' returning default value: %r' %
250 (option, section, default))
251 _warn(warning, configType, section, option)
252 return default
253
254 def SetOption(self, configType, section, option, value):
255 """Set section option to value in user config file."""

Callers 15

GetExtensionsMethod · 0.95
__GetRawExtensionKeysMethod · 0.95
GetExtensionBindingsMethod · 0.95
GetKeyBindingMethod · 0.95
GetFontMethod · 0.95
mainFunction · 0.80
reloadMethod · 0.80
load_theme_cfgMethod · 0.80
load_key_cfgMethod · 0.80

Calls 3

_warnFunction · 0.85
GetMethod · 0.80
has_optionMethod · 0.45

Tested by 4

test_initMethod · 0.64
test_get_optionMethod · 0.64
test_set_optionMethod · 0.64