diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2019-03-22 22:23:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-22 22:23:41 (GMT) |
commit | c1419578a18d787393c7ccee149e7c1fff17a99e (patch) | |
tree | 397ee6aabc58afb07ef4893676ba569f05cf7d3c /Lib/idlelib/config.py | |
parent | 5086589305ff5538709856b27314b68f06ae93db (diff) | |
download | cpython-c1419578a18d787393c7ccee149e7c1fff17a99e.zip cpython-c1419578a18d787393c7ccee149e7c1fff17a99e.tar.gz cpython-c1419578a18d787393c7ccee149e7c1fff17a99e.tar.bz2 |
bpo-36396: Remove fgBg param of idlelib.config.GetHighlight() (GH-12491)
This param was only used once and changed the return type.
Diffstat (limited to 'Lib/idlelib/config.py')
-rw-r--r-- | Lib/idlelib/config.py | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py index 79d988f..aa94d65 100644 --- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -34,7 +34,6 @@ import idlelib class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass -class InvalidFgBg(Exception): pass class InvalidTheme(Exception): pass class IdleConfParser(ConfigParser): @@ -283,34 +282,20 @@ class IdleConf: raise InvalidConfigSet('Invalid configSet specified') return cfgParser.sections() - def GetHighlight(self, theme, element, fgBg=None): - """Return individual theme element highlight color(s). + def GetHighlight(self, theme, element): + """Return dict of theme element highlight colors. - fgBg - string ('fg' or 'bg') or None. - If None, return a dictionary containing fg and bg colors with - keys 'foreground' and 'background'. Otherwise, only return - fg or bg color, as specified. Colors are intended to be - appropriate for passing to Tkinter in, e.g., a tag_config call). + The keys are 'foreground' and 'background'. The values are + tkinter color strings for configuring backgrounds and tags. """ - if self.defaultCfg['highlight'].has_section(theme): - themeDict = self.GetThemeDict('default', theme) - else: - themeDict = self.GetThemeDict('user', theme) - fore = themeDict[element + '-foreground'] - if element == 'cursor': # There is no config value for cursor bg - back = themeDict['normal-background'] - else: - back = themeDict[element + '-background'] - highlight = {"foreground": fore, "background": back} - if not fgBg: # Return dict of both colors - return highlight - else: # Return specified color only - if fgBg == 'fg': - return highlight["foreground"] - if fgBg == 'bg': - return highlight["background"] - else: - raise InvalidFgBg('Invalid fgBg specified') + cfg = ('default' if self.defaultCfg['highlight'].has_section(theme) + else 'user') + theme_dict = self.GetThemeDict(cfg, theme) + fore = theme_dict[element + '-foreground'] + if element == 'cursor': + element = 'normal' + back = theme_dict[element + '-background'] + return {"foreground": fore, "background": back} def GetThemeDict(self, type, themeName): """Return {option:value} dict for elements in themeName. |