MCPcopy Index your code
hub / github.com/python/cpython / IdleConfParser

Class IdleConfParser

Lib/idlelib/config.py:39–77  ·  view source on GitHub ↗

A ConfigParser specialised for idle configuration file handling

Source from the content-addressed store, hash-verified

37class InvalidTheme(Exception): pass
38
39class IdleConfParser(ConfigParser):
40 """
41 A ConfigParser specialised for idle configuration file handling
42 """
43 def __init__(self, cfgFile, cfgDefaults=None):
44 """
45 cfgFile - string, fully specified configuration file name
46 """
47 self.file = cfgFile # This is currently '' when testing.
48 ConfigParser.__init__(self, defaults=cfgDefaults, strict=False)
49
50 def Get(self, section, option, type=None, default=None, raw=False):
51 """
52 Get an option value for given section/option or return default.
53 If type is specified, return as type.
54 """
55 # TODO Use default as fallback, at least if not None
56 # Should also print Warning(file, section, option).
57 # Currently may raise ValueError
58 if not self.has_option(section, option):
59 return default
60 if type == 'bool':
61 return self.getboolean(section, option)
62 elif type == 'int':
63 return self.getint(section, option)
64 else:
65 return self.get(section, option, raw=raw)
66
67 def GetOptionList(self, section):
68 "Return a list of options for given section, else []."
69 if self.has_section(section):
70 return self.options(section)
71 else: #return a default value
72 return []
73
74 def Load(self):
75 "Load the configuration file from disk."
76 if self.file:
77 self.read(self.file)
78
79class IdleUserConfParser(IdleConfParser):
80 """

Callers 1

CreateConfigHandlersMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…