Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions Lib/idlelib/config.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@
import sys

from tkinter.font import Font
import idlelib

class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
Expand DownExpand Up@@ -159,14 +160,15 @@ class IdleConf:
for config_type in self.config_types:
(user home dir)/.idlerc/config-{config-type}.cfg
"""
def __init__(self):
def __init__(self, _utest=False):
self.config_types = ('main', 'highlight', 'keys', 'extensions')
self.defaultCfg ={}
self.userCfg ={}
self.cfg ={} # TODO use to select userCfg vs defaultCfg
self.CreateConfigHandlers()
self.LoadCfgFiles()

if not _utest:
self.CreateConfigHandlers()
self.LoadCfgFiles()

def CreateConfigHandlers(self):
"Populate default and user config parser dictionaries."
Expand DownExpand Up@@ -215,7 +217,8 @@ def GetUserCfgDir(self):
except OSError:
warn = ('\n Warning: unable to create user config directory\n' +
userDir + '\n Check path and permissions.\n Exiting!\n')
print(warn, file=sys.stderr)
if not idlelib.testing:
print(warn, file=sys.stderr)
raise SystemExit
# TODO continue without userDIr instead of exit
return userDir
Expand DownExpand Up@@ -463,16 +466,7 @@ def GetExtensions(self, active_only=True,

def RemoveKeyBindNames(self, extnNameList):
"Return extnNameList with keybinding section names removed."
# TODO Easier to return filtered copy with list comp
names = extnNameList
kbNameIndicies = []
for name in names:
if name.endswith(('_bindings', '_cfgBindings')):
kbNameIndicies.append(names.index(name))
kbNameIndicies.sort(reverse=True)
for index in kbNameIndicies: #delete each keybinding section name
del(names[index])
return names
return [n for n in extnNameList if not n.endswith(('_bindings', '_cfgBindings'))]

def GetExtnNameForEvent(self, virtualEvent):
"""Return the name of the extension binding virtualEvent, or None.
Expand Down
Loading