summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2007-08-23 05:25:55 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2007-08-23 05:25:55 (GMT)
commite07127793958bc355dd34b79c08397c698c298d7 (patch)
tree72c12623b301055c9b2c0593c19fd326933c11d4 /Lib/idlelib
parent460add45008adff34b3b6a75805b8acf87a6192b (diff)
downloadcpython-e07127793958bc355dd34b79c08397c698c298d7.zip
cpython-e07127793958bc355dd34b79c08397c698c298d7.tar.gz
cpython-e07127793958bc355dd34b79c08397c698c298d7.tar.bz2
Conform to py3k dict.{keys, items, values} with some advice from 2b3
M idlelib/configHandler.py M idlelib/ColorDelegator.py M idlelib/Delegator.py M idlelib/ObjectBrowser.py M idlelib/PyShell.py M idlelib/Debugger.py M idlelib/configDialog.py M idlelib/StackViewer.py M idlelib/keybindingDialog.py M idlelib/tabpage.py M idlelib/EditorWindow.py M idlelib/WindowList.py M idlelib/RemoteDebugger.py M idlelib/dynOptionMenuWidget.py
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/ColorDelegator.py4
-rw-r--r--Lib/idlelib/Debugger.py3
-rw-r--r--Lib/idlelib/Delegator.py4
-rw-r--r--Lib/idlelib/EditorWindow.py8
-rw-r--r--Lib/idlelib/ObjectBrowser.py2
-rw-r--r--Lib/idlelib/PyShell.py2
-rw-r--r--Lib/idlelib/RemoteDebugger.py2
-rw-r--r--Lib/idlelib/StackViewer.py2
-rw-r--r--Lib/idlelib/WindowList.py2
-rw-r--r--Lib/idlelib/configDialog.py46
-rw-r--r--Lib/idlelib/configHandler.py16
-rw-r--r--Lib/idlelib/dynOptionMenuWidget.py2
-rw-r--r--Lib/idlelib/keybindingDialog.py2
-rw-r--r--Lib/idlelib/tabpage.py6
14 files changed, 50 insertions, 51 deletions
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py
index cc20c1e..b93aa5a 100644
--- a/Lib/idlelib/ColorDelegator.py
+++ b/Lib/idlelib/ColorDelegator.py
@@ -190,7 +190,7 @@ class ColorDelegator(Delegator):
##print head, "get", mark, next, "->", repr(line)
if not line:
return
- for tag in self.tagdefs.keys():
+ for tag in self.tagdefs:
self.tag_remove(tag, mark, next)
chars = chars + line
m = self.prog.search(chars)
@@ -244,7 +244,7 @@ class ColorDelegator(Delegator):
return
def removecolors(self):
- for tag in self.tagdefs.keys():
+ for tag in self.tagdefs:
self.tag_remove(tag, "1.0", "end")
def main():
diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py
index 3c16b5a..cd31914 100644
--- a/Lib/idlelib/Debugger.py
+++ b/Lib/idlelib/Debugger.py
@@ -312,8 +312,7 @@ class Debugger:
def load_breakpoints(self):
"Load PyShellEditorWindow breakpoints into subprocess debugger"
- pyshell_edit_windows = self.pyshell.flist.inversedict.keys()
- for editwin in pyshell_edit_windows:
+ for editwin in self.pyshell.flist.inversedict:
filename = editwin.io.filename
try:
for lineno in editwin.breakpoints:
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
index cc62661..93253b9 100644
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -13,7 +13,7 @@ class Delegator:
return attr
def resetcache(self):
- for key in self.__cache.keys():
+ for key in self.__cache:
try:
delattr(self, key)
except AttributeError:
@@ -21,7 +21,7 @@ class Delegator:
self.__cache.clear()
def cachereport(self):
- keys = self.__cache.keys()
+ keys = list(self.__cache.keys())
keys.sort()
print(keys)
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index e051348..7161069 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -654,7 +654,7 @@ class EditorWindow(object):
for item in menu[1]:
if item:
menuEventDict[menu[0]][prepstr(item[0])[1]] = item[1]
- for menubarItem in self.menudict.keys():
+ for menubarItem in self.menudict:
menu = self.menudict[menubarItem]
end = menu.index(END) + 1
for index in range(0, end):
@@ -733,7 +733,7 @@ class EditorWindow(object):
finally:
rf_file.close()
# for each edit window instance, construct the recent files menu
- for instance in self.top.instance_dict.keys():
+ for instance in self.top.instance_dict:
menu = instance.recent_files_menu
menu.delete(1, END) # clear, and rebuild:
for i, file in zip(count(), rf_list):
@@ -863,7 +863,7 @@ class EditorWindow(object):
self.load_standard_extensions()
def unload_extensions(self):
- for ins in self.extensions.values():
+ for ins in list(self.extensions.values()):
if hasattr(ins, "close"):
ins.close()
self.extensions = {}
@@ -893,7 +893,7 @@ class EditorWindow(object):
self.extensions[name] = ins
if keydefs:
self.apply_bindings(keydefs)
- for vevent in keydefs.keys():
+ for vevent in keydefs:
methodname = vevent.replace("-", "_")
while methodname[:1] == '<':
methodname = methodname[1:]
diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/ObjectBrowser.py
index c98a8b6..75bc3a6 100644
--- a/Lib/idlelib/ObjectBrowser.py
+++ b/Lib/idlelib/ObjectBrowser.py
@@ -94,7 +94,7 @@ class SequenceTreeItem(ObjectTreeItem):
class DictTreeItem(SequenceTreeItem):
def keys(self):
- keys = self.object.keys()
+ keys = list(self.object.keys())
try:
keys.sort()
except:
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 7616db4..a9b8f72 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -84,7 +84,7 @@ def extended_linecache_checkcache(filename=None,
"""
cache = linecache.cache
save = {}
- for filename in cache.keys():
+ for filename in cache:
if filename[:1] + filename[-1:] == '<>':
save[filename] = cache[filename]
orig_checkcache()
diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/RemoteDebugger.py
index 11bbc2d..8a0970d 100644
--- a/Lib/idlelib/RemoteDebugger.py
+++ b/Lib/idlelib/RemoteDebugger.py
@@ -163,7 +163,7 @@ class IdbAdapter:
def dict_keys(self, did):
dict = dicttable[did]
- return dict.keys()
+ return list(dict.keys())
def dict_item(self, did, key):
dict = dicttable[did]
diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/StackViewer.py
index 33a73fc..9ca1ff5 100644
--- a/Lib/idlelib/StackViewer.py
+++ b/Lib/idlelib/StackViewer.py
@@ -106,7 +106,7 @@ class VariablesTreeItem(ObjectTreeItem):
return len(self.object) > 0
def keys(self):
- return self.object.keys()
+ return list(self.object.keys())
def GetSubList(self):
sublist = []
diff --git a/Lib/idlelib/WindowList.py b/Lib/idlelib/WindowList.py
index fc463b8..28b55b8 100644
--- a/Lib/idlelib/WindowList.py
+++ b/Lib/idlelib/WindowList.py
@@ -20,7 +20,7 @@ class WindowList:
def add_windows_to_menu(self, menu):
list = []
- for key in self.dict.keys():
+ for key in self.dict:
window = self.dict[key]
try:
title = window.get_title()
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 8fee841..ad3071a 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -182,7 +182,7 @@ class ConfigDialog(Toplevel):
(' ','normal'),('stderr','stderr'),('\n','normal'))
for txTa in textAndTags:
text.insert(END,txTa[0],txTa[1])
- for element in self.themeElements.keys():
+ for element in self.themeElements:
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
lambda event,elem=element: event.widget.winfo_toplevel()
.highlightTarget.set(elem))
@@ -556,7 +556,7 @@ class ConfigDialog(Toplevel):
def GetDefaultItems(self):
dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
- for configType in dItems.keys():
+ for configType in dItems:
sections=idleConf.GetSectionList('default',configType)
for section in sections:
dItems[configType][section]={}
@@ -597,11 +597,11 @@ class ConfigDialog(Toplevel):
else:
currentKeySetName=self.customKeys.get()
currentBindings=idleConf.GetCurrentKeySet()
- if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
+ if currentKeySetName in self.changedItems['keys']: #unsaved changes
keySetChanges=self.changedItems['keys'][currentKeySetName]
- for event in keySetChanges.keys():
+ for event in keySetChanges:
currentBindings[event]=keySetChanges[event].split()
- currentKeySequences=currentBindings.values()
+ currentKeySequences = list(currentBindings.values())
newKeys=GetKeysDialog(self,'Get New Keys',bindName,
currentKeySequences).result
if newKeys: #new keys were specified
@@ -648,14 +648,14 @@ class ConfigDialog(Toplevel):
prevKeySetName=self.customKeys.get()
prevKeys=idleConf.GetCoreKeys(prevKeySetName)
newKeys={}
- for event in prevKeys.keys(): #add key set to changed items
+ for event in prevKeys: #add key set to changed items
eventName=event[2:-2] #trim off the angle brackets
binding=' '.join(prevKeys[event])
newKeys[eventName]=binding
#handle any unsaved changes to prev key set
- if prevKeySetName in self.changedItems['keys'].keys():
+ if prevKeySetName in self.changedItems['keys']:
keySetChanges=self.changedItems['keys'][prevKeySetName]
- for event in keySetChanges.keys():
+ for event in keySetChanges:
newKeys[event]=keySetChanges[event]
#save the new theme
self.SaveNewKeySet(newKeySetName,newKeys)
@@ -673,15 +673,15 @@ class ConfigDialog(Toplevel):
reselect=1
listIndex=self.listBindings.index(ANCHOR)
keySet=idleConf.GetKeySet(keySetName)
- bindNames=keySet.keys()
+ bindNames = list(keySet.keys())
bindNames.sort()
self.listBindings.delete(0,END)
for bindName in bindNames:
key=' '.join(keySet[bindName]) #make key(s) into a string
bindName=bindName[2:-2] #trim off the angle brackets
- if keySetName in self.changedItems['keys'].keys():
+ if keySetName in self.changedItems['keys']:
#handle any unsaved changes to this key set
- if bindName in self.changedItems['keys'][keySetName].keys():
+ if bindName in self.changedItems['keys'][keySetName]:
key=self.changedItems['keys'][keySetName][bindName]
self.listBindings.insert(END, bindName+' - '+key)
if reselect:
@@ -796,9 +796,9 @@ class ConfigDialog(Toplevel):
themeName=self.customTheme.get()
newTheme=idleConf.GetThemeDict(themeType,themeName)
#apply any of the old theme's unsaved changes to the new theme
- if themeName in self.changedItems['highlight'].keys():
+ if themeName in self.changedItems['highlight']:
themeChanges=self.changedItems['highlight'][themeName]
- for element in themeChanges.keys():
+ for element in themeChanges:
newTheme[element]=themeChanges[element]
#save the new theme
self.SaveNewTheme(newThemeName,newTheme)
@@ -850,14 +850,14 @@ class ConfigDialog(Toplevel):
theme=self.builtinTheme.get()
else: #a user theme
theme=self.customTheme.get()
- for elementTitle in self.themeElements.keys():
+ for elementTitle in self.themeElements:
element=self.themeElements[elementTitle][0]
colours=idleConf.GetHighlight(theme,element)
if element=='cursor': #cursor sample needs special painting
colours['background']=idleConf.GetHighlight(theme,
'normal', fgBg='bg')
#handle any unsaved changes to this theme
- if theme in self.changedItems['highlight'].keys():
+ if theme in self.changedItems['highlight']:
themeDict=self.changedItems['highlight'][theme]
if element+'-foreground' in themeDict:
colours['foreground']=themeDict[element+'-foreground']
@@ -976,7 +976,7 @@ class ConfigDialog(Toplevel):
self.optMenuThemeBuiltin.SetMenu(itemList,itemList[0])
self.SetThemeType()
##load theme element option menu
- themeNames=self.themeElements.keys()
+ themeNames = list(self.themeElements.keys())
themeNames.sort(self.__ThemeNameIndexCompare)
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
self.PaintThemeSample()
@@ -1061,7 +1061,7 @@ class ConfigDialog(Toplevel):
"""
if not idleConf.userCfg['keys'].has_section(keySetName):
idleConf.userCfg['keys'].add_section(keySetName)
- for event in keySet.keys():
+ for event in keySet:
value=keySet[event]
idleConf.userCfg['keys'].SetOption(keySetName,event,value)
@@ -1073,7 +1073,7 @@ class ConfigDialog(Toplevel):
"""
if not idleConf.userCfg['highlight'].has_section(themeName):
idleConf.userCfg['highlight'].add_section(themeName)
- for element in theme.keys():
+ for element in theme:
value=theme[element]
idleConf.userCfg['highlight'].SetOption(themeName,element,value)
@@ -1088,14 +1088,14 @@ class ConfigDialog(Toplevel):
def SaveAllChangedConfigs(self):
"Save configuration changes to the user config file."
idleConf.userCfg['main'].Save()
- for configType in self.changedItems.keys():
+ for configType in self.changedItems:
cfgTypeHasChanges = False
- for section in self.changedItems[configType].keys():
+ for section in self.changedItems[configType]:
if section == 'HelpFiles':
#this section gets completely replaced
idleConf.userCfg['main'].remove_section('HelpFiles')
cfgTypeHasChanges = True
- for item in self.changedItems[configType][section].keys():
+ for item in self.changedItems[configType][section]:
value = self.changedItems[configType][section][item]
if self.SetUserValue(configType,section,item,value):
cfgTypeHasChanges = True
@@ -1109,13 +1109,13 @@ class ConfigDialog(Toplevel):
def DeactivateCurrentConfig(self):
#Before a config is saved, some cleanup of current
#config must be done - remove the previous keybindings
- winInstances=self.parent.instance_dict.keys()
+ winInstances = self.parent.instance_dict.keys()
for instance in winInstances:
instance.RemoveKeybindings()
def ActivateConfigChanges(self):
"Dynamically apply configuration changes"
- winInstances=self.parent.instance_dict.keys()
+ winInstances = self.parent.instance_dict.keys()
for instance in winInstances:
instance.ResetColorizer()
instance.ResetFont()
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index 0c88396..b5d9769 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -343,7 +343,7 @@ class IdleConf:
'stderr-background':'#ffffff',
'console-foreground':'#000000',
'console-background':'#ffffff' }
- for element in theme.keys():
+ for element in theme:
if not cfgParser.has_option(themeName,element):
#we are going to return a default, print warning
warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict'
@@ -424,7 +424,7 @@ class IdleConf:
extName=None
vEvent='<<'+virtualEvent+'>>'
for extn in self.GetExtensions(active_only=0):
- for event in self.GetExtensionKeys(extn).keys():
+ for event in self.GetExtensionKeys(extn):
if event == vEvent:
extName=extn
return extName
@@ -519,7 +519,7 @@ class IdleConf:
for extn in activeExtns:
extKeys=self.__GetRawExtensionKeys(extn)
if extKeys: #the extension defines keybindings
- for event in extKeys.keys():
+ for event in extKeys:
if extKeys[event] in keySet.values():
#the binding is already in use
extKeys[event]='' #disable this binding
@@ -532,7 +532,7 @@ class IdleConf:
virtualEvent - string, name of the virtual event to test for, without
the enclosing '<< >>'
"""
- return ('<<'+virtualEvent+'>>') in self.GetCoreKeys().keys()
+ return ('<<'+virtualEvent+'>>') in self.GetCoreKeys()
def GetCoreKeys(self, keySetName=None):
"""
@@ -595,7 +595,7 @@ class IdleConf:
'<<del-word-right>>': ['<Control-Key-Delete>']
}
if keySetName:
- for event in keyBindings.keys():
+ for event in keyBindings:
binding=self.GetKeyBinding(keySetName,event)
if binding:
keyBindings[event]=binding
@@ -662,7 +662,7 @@ class IdleConf:
"""
load all configuration files.
"""
- for key in self.defaultCfg.keys():
+ for key in self.defaultCfg:
self.defaultCfg[key].Load()
self.userCfg[key].Load() #same keys
@@ -670,7 +670,7 @@ class IdleConf:
"""
write all loaded user configuration files back to disk
"""
- for key in self.userCfg.keys():
+ for key in self.userCfg:
self.userCfg[key].Save()
idleConf=IdleConf()
@@ -679,7 +679,7 @@ idleConf=IdleConf()
if __name__ == '__main__':
def dumpCfg(cfg):
print('\n',cfg,'\n')
- for key in cfg.keys():
+ for key in cfg:
sections=cfg[key].sections()
print(key)
print(sections)
diff --git a/Lib/idlelib/dynOptionMenuWidget.py b/Lib/idlelib/dynOptionMenuWidget.py
index e81f7ba..78406d7 100644
--- a/Lib/idlelib/dynOptionMenuWidget.py
+++ b/Lib/idlelib/dynOptionMenuWidget.py
@@ -13,7 +13,7 @@ class DynOptionMenu(OptionMenu):
def __init__(self, master, variable, value, *values, **kwargs):
#get a copy of kwargs before OptionMenu.__init__ munges them
kwargsCopy=copy.copy(kwargs)
- if 'highlightthickness' in kwargs.keys():
+ if 'highlightthickness' in list(kwargs.keys()):
del(kwargs['highlightthickness'])
OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
self.config(highlightthickness=kwargsCopy.get('highlightthickness'))
diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py
index 16db557..7f4cc91 100644
--- a/Lib/idlelib/keybindingDialog.py
+++ b/Lib/idlelib/keybindingDialog.py
@@ -203,7 +203,7 @@ class GetKeysDialog(Toplevel):
'/':'slash','?':'question','Page Up':'Prior','Page Down':'Next',
'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up',
'Down Arrow': 'Down', 'Tab':'Tab'}
- if key in translateDict.keys():
+ if key in translateDict:
key = translateDict[key]
if 'Shift' in modifiers and key in string.ascii_lowercase:
key = key.upper()
diff --git a/Lib/idlelib/tabpage.py b/Lib/idlelib/tabpage.py
index 0f7017b..105ef90 100644
--- a/Lib/idlelib/tabpage.py
+++ b/Lib/idlelib/tabpage.py
@@ -43,12 +43,12 @@ class TabPageSet(Frame):
def ChangePage(self,pageName=None):
if pageName:
- if pageName in self.pages.keys():
+ if pageName in self.pages:
self.activePage.set(pageName)
else:
raise InvalidTabPage('Invalid TabPage Name')
## pop up the active 'tab' only
- for page in self.pages.keys():
+ for page in self.pages:
self.pages[page]['tab'].config(relief=RIDGE)
self.pages[self.GetActivePage()]['tab'].config(relief=RAISED)
## switch page
@@ -73,7 +73,7 @@ class TabPageSet(Frame):
self.ChangePage()
def RemovePage(self,pageName):
- if not pageName in self.pages.keys():
+ if not pageName in self.pages:
raise InvalidTabPage('Invalid TabPage Name')
self.pages[pageName]['tab'].pack_forget()
self.pages[pageName]['page'].grid_forget()