Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
84bac63
Various modules/Python 3: wrap dict.items/keys/values inside a list c…
josephsl Jun 3, 2019
1e017cd
NVDAObjects/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
c7386f5
IAccessible handler/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
9f31224
UIA handler and utilities/Python 3: dict.iteritems -> dict.items, dic…
josephsl Jun 4, 2019
f9ad5ce
Add-on handler/Python 3: dict.itervalues -> dict.values. Re #9067.
josephsl Jun 4, 2019
4e5413e
App module handler/Python 3: dict.iteritems -> dict.items, dict.iterv…
josephsl Jun 4, 2019
37b96a4
Base object/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
739c256
Braille display detection/Python 3: dict.iteritems -> dict.items. Re …
josephsl Jun 4, 2019
71e93a2
Braille display drivers/Python 3: dict.iteritems -> dict.items, dict.…
josephsl Jun 4, 2019
482a49d
Character processing/Python 3: dict.iteritems -> dict.items, dict.ite…
josephsl Jun 4, 2019
9109ab0
Config/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
148e5a2
Global plugin handler/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
6ca14d2
GUI/Python 3: dict.iteritems -> dict.items, dict.itervalues -> dict.v…
josephsl Jun 4, 2019
da0d9e3
Input core/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
e5be6a6
Installer/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
f9a195f
Oleacc/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
b570eba
Speech/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
5568d26
Speech XML/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
ee975bd
Synth drivers/Python 3: dict.iteritems -> dict.items, dict.itervalues…
josephsl Jun 4, 2019
c4c48d4
Table utils/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
0977950
Text infos offsets/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
25319e1
Touch tracker/Python 3: dict.itervalues -> dict.values. Re #9067.
josephsl Jun 4, 2019
bc505b1
VK codes/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
8916b78
Watchdog/Python 3: dict.iteritems -> dict.items. Re #9067.
josephsl Jun 4, 2019
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
8 changes: 5 additions & 3 deletions source/IAccessibleHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ def flushEvents(self):
g=self._genericEventCache
self._genericEventCache={}
threadCounters={}
for k,v in sorted(g.iteritems(),key=lambda item: item[1],reverse=True):
for k,v in sorted(g.items(),key=lambda item: item[1],reverse=True):
threadCount=threadCounters.get(k[-1],0)
if threadCount>MAX_WINEVENTS_PER_THREAD:
continue
heapq.heappush(self._eventHeap,(v,)+k)
threadCounters[k[-1]]=threadCount+1
f=self._focusEventCache
self._focusEventCache={}
for k,v in sorted(f.iteritems(),key=lambda item: item[1])[0-self.maxFocusItems:]:
for k,v in sorted(f.items(),key=lambda item: item[1])[0-self.maxFocusItems:]:
heapq.heappush(self._eventHeap,(v,)+k)
e=self._eventHeap
self._eventHeap=[]
Expand Down Expand Up @@ -832,7 +832,9 @@ def initialize():
accPropServices=comtypes.client.CreateObject(CAccPropServices)
except (WindowsError,COMError) as e:
log.debugWarning("AccPropServices is not available: %s"%e)
for eventType in winEventIDsToNVDAEventNames.keys():
# #9067 (Py3 review required): originally, this calls dict.keys, which in Python 2 returns a list and Python 3 assumes iterators.
# Therefore wrap this around a list call.
for eventType in list(winEventIDsToNVDAEventNames.keys()):
hookID=winUser.setWinEventHook(eventType,eventType,0,cWinEventCallback,0,0,0)
if hookID:
winEventHookIDs.append(hookID)
Expand Down
14 changes: 8 additions & 6 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,9 @@ def _get_positionInfo(self):
del info['indexInGroup']
del info['similarItemsInGroup']
# 0 means not applicable, so remove it.
for key, val in info.items():
# #9067 (Py3 review required): originally this called dict.items, which returns iterators in Python 3.
# Therefore wrap this inside a list call.
for key, val in list(info.items()):
if not val:
del info[key]
return info
Expand All @@ -1376,7 +1378,7 @@ def _get_positionInfo(self):
d=self.decodedAccDescription
if d and not isinstance(d,basestring):
groupdict=d.groupdict()
return {x:int(y) for x,y in groupdict.iteritems() if y is not None}
return {x:int(y) for x,y in groupdict.items() if y is not None}
if self.allowIAccessibleChildIDAndChildCountForPositionInfo and self.IAccessibleChildID>0:
indexInGroup=self.IAccessibleChildID
parent=self.parent
Expand Down Expand Up @@ -1503,7 +1505,7 @@ def _get_devInfo(self):
info.append("IAccessible accName: %s" % ret)
try:
ret = iaObj.accRole(childID)
for name, const in oleacc.__dict__.iteritems():
for name, const in oleacc.__dict__.items():
if not name.startswith("ROLE_"):
continue
if ret == const:
Expand All @@ -1517,7 +1519,7 @@ def _get_devInfo(self):
try:
temp = iaObj.accState(childID)
ret = ", ".join(
name for name, const in oleacc.__dict__.iteritems()
name for name, const in oleacc.__dict__.items()
if name.startswith("STATE_") and temp & const
) + " (%d)" % temp
except Exception as e:
Expand Down Expand Up @@ -1546,7 +1548,7 @@ def _get_devInfo(self):
info.append("IAccessible2 uniqueID: %s" % ret)
try:
ret = iaObj.role()
for name, const in itertools.chain(oleacc.__dict__.iteritems(), IAccessibleHandler.__dict__.iteritems()):
for name, const in itertools.chain(oleacc.__dict__.items(), IAccessibleHandler.__dict__.items()):
if not name.startswith("ROLE_") and not name.startswith("IA2_ROLE_"):
continue
if ret == const:
Expand All @@ -1560,7 +1562,7 @@ def _get_devInfo(self):
try:
temp = iaObj.states
ret = ", ".join(
name for name, const in IAccessibleHandler.__dict__.iteritems()
name for name, const in IAccessibleHandler.__dict__.items()
if name.startswith("IA2_STATE_") and temp & const
) + " (%d)" % temp
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,11 @@ def _get_devInfo(self):
info.append("UIA className: %s"%ret)
patternsAvailable = []
patternAvailableConsts = dict(
(const, name) for name, const in UIAHandler.__dict__.iteritems()
(const, name) for name, const in UIAHandler.__dict__.items()
if name.startswith("UIA_Is") and name.endswith("PatternAvailablePropertyId")
)
self._prefetchUIACacheForPropertyIDs(list(patternAvailableConsts))
for const, name in patternAvailableConsts.iteritems():
for const, name in patternAvailableConsts.items():
try:
res = self._getUIACacheablePropertyValue(const)
except COMError:
Expand Down
4 changes: 2 additions & 2 deletions source/NVDAObjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,15 +1144,15 @@ def _get_devInfo(self):
info.append("name: %s" % ret)
try:
ret = self.role
for name, const in controlTypes.__dict__.iteritems():
for name, const in controlTypes.__dict__.items():
if name.startswith("ROLE_") and ret == const:
ret = name
break
except Exception as e:
ret = "exception: %s" % e
info.append("role: %s" % ret)
try:
stateConsts = dict((const, name) for name, const in controlTypes.__dict__.iteritems() if name.startswith("STATE_"))
stateConsts = dict((const, name) for name, const in controlTypes.__dict__.items() if name.startswith("STATE_"))
ret = ", ".join(
stateConsts.get(state) or str(state)
for state in self.states)
Expand Down
2 changes: 1 addition & 1 deletion source/NVDAObjects/window/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ def _get_states(self):
if not cellInfo:
return states
stateBits=cellInfo.states
for k,v in vars(controlTypes).iteritems():
for k,v in vars(controlTypes).items():
if k.startswith('STATE_') and stateBits&v:
states.add(v)
return states
Expand Down
8 changes: 6 additions & 2 deletions source/NVDAObjects/window/excelCellBorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@

def getCellBorderStyleDescription(bordersObj,reportBorderColor=False):
d=OrderedDict()
for pos in bordersIndexLabels.keys():
# #9067 (Py3 review required): originally called dict.keys.
# Therefore wrap this inside list call.
for pos in list(bordersIndexLabels.keys()):
border=bordersObj[pos]
if border.lineStyle != xlLineStyleNone:
style=border.lineStyle
Expand Down Expand Up @@ -150,7 +152,9 @@ def getCellBorderStyleDescription(bordersObj,reportBorderColor=False):
s.append(_("{desc} up-right and down-right diagonal lines").format(desc=d.get(xlDiagonalUp)))
del d[xlDiagonalUp]
del d[xlDiagonalDown]
for pos,desc in d.items():
# #9067 (Py3 review required): Originally called dict.items.
# Therefore wrap this inside a list call.
for pos,desc in list(d.items()):
# Translators: border styles in Microsoft Excel.
s.append(_("{desc} {position}").format(
desc=desc,
Expand Down
3 changes: 2 additions & 1 deletion source/NVDAObjects/window/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ def getTextWithFields(self,formatConfig=None):
startOffset=self._rangeObj.start
endOffset=self._rangeObj.end
text=BSTR()
formatConfigFlags=sum(y for x,y in formatConfigFlagsMap.iteritems() if formatConfig.get(x,False))
# #9067: format config flags map is a dictionary.
formatConfigFlags=sum(y for x,y in formatConfigFlagsMap.items() if formatConfig.get(x,False))
if self.shouldIncludeLayoutTables:
formatConfigFlags+=formatConfigFlag_includeLayoutTables
if self.obj.ignoreEditorRevisions:
Expand Down
2 changes: 1 addition & 1 deletion source/UIAUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def createUIAMultiPropertyCondition(*dicts):
outerOrList=[]
for dict in dicts:
andList=[]
for key,values in dict.iteritems():
for key,values in dict.items():
innerOrList=[]
if not isinstance(values,(list,set)):
values=[values]
Expand Down
10 changes: 6 additions & 4 deletions source/_UIAHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
ignoreWinEventsMap = {
UIA_AutomationPropertyChangedEventId: list(UIAPropertyIdsToNVDAEventNames.keys()),
}
for id in UIAEventIdsToNVDAEventNames.iterkeys():
for id in UIAEventIdsToNVDAEventNames.keys():
ignoreWinEventsMap[id] = [0]

class UIAHandler(COMObject):
Expand Down Expand Up @@ -198,7 +198,7 @@ def MTAThreadFunc(self):
for index in xrange(pfm.count):
e=pfm.getEntry(index)
entryChanged = False
for eventId, propertyIds in ignoreWinEventsMap.iteritems():
for eventId, propertyIds in ignoreWinEventsMap.items():
for propertyId in propertyIds:
# Check if this proxy has mapped any winEvents to the UIA propertyChange event for this property ID
try:
Expand Down Expand Up @@ -246,8 +246,10 @@ def MTAThreadFunc(self):
self.reservedNotSupportedValue=self.clientObject.ReservedNotSupportedValue
self.ReservedMixedAttributeValue=self.clientObject.ReservedMixedAttributeValue
self.clientObject.AddFocusChangedEventHandler(self.baseCacheRequest,self)
self.clientObject.AddPropertyChangedEventHandler(self.rootElement,TreeScope_Subtree,self.baseCacheRequest,self,UIAPropertyIdsToNVDAEventNames.keys())
for x in UIAEventIdsToNVDAEventNames.iterkeys():
# #9067 (Py3 review required): originally called dict.keys.
# Therefore wrap this inside a list call.
self.clientObject.AddPropertyChangedEventHandler(self.rootElement,TreeScope_Subtree,self.baseCacheRequest,self,list(UIAPropertyIdsToNVDAEventNames.keys()))
for x in UIAEventIdsToNVDAEventNames.keys():
self.clientObject.addAutomationEventHandler(x,self.rootElement,TreeScope_Subtree,self.baseCacheRequest,self)
# #7984: add support for notification event (IUIAutomation5, part of Windows 10 build 16299 and later).
if isinstance(self.clientObject, IUIAutomation5):
Expand Down
6 changes: 4 additions & 2 deletions source/addonHandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def getAvailableAddons(refresh=False, filterFunc=None):
generators = [_getAvailableAddonsFromPath(path) for path in _getDefaultAddonPaths()]
for addon in itertools.chain(*generators):
_availableAddons[addon.path] = addon
return (addon for addon in _availableAddons.itervalues() if not filterFunc or filterFunc(addon))
return (addon for addon in _availableAddons.values() if not filterFunc or filterFunc(addon))

def installAddonBundle(bundle):
"""Extracts an Addon bundle in to a unique subdirectory of the user addons directory, marking the addon as needing install completion on NVDA restart."""
Expand Down Expand Up @@ -513,7 +513,9 @@ def getCodeAddon(obj=None, frameDist=1):
raise AddonError("Code does not belong to an addon package.")
curdir = dir
while curdir not in _getDefaultAddonPaths():
if curdir in _availableAddons.keys():
# #9067 (Py3 review required): originally called dict.keys.
# Therefore wrap this inside a list call.
if curdir in list(_availableAddons.keys()):
return _availableAddons[curdir]
curdir = os.path.abspath(os.path.join(curdir, ".."))
# Not found!
Expand Down
8 changes: 4 additions & 4 deletions source/appModuleHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def update(processID,helperLocalBindingHandle=None,inprocRegistrationHandle=None
def cleanup():
"""Removes any appModules from the cache whose process has died.
"""
for deadMod in [mod for mod in runningTable.itervalues() if not mod.isAlive]:
for deadMod in [mod for mod in runningTable.values() if not mod.isAlive]:
log.debug("application %s closed"%deadMod.appName)
del runningTable[deadMod.processID]
if deadMod in set(o.appModule for o in api.getFocusAncestors()+[api.getFocusObject()] if o and o.appModule):
Expand Down Expand Up @@ -189,7 +189,7 @@ def reloadAppModules():
"""
global appModules
state = []
for mod in runningTable.itervalues():
for mod in runningTable.values():
state.append({key: getattr(mod, key) for key in ("processID",
# #2892: We must save nvdaHelperRemote handles, as we can't reinitialize without a foreground/focus event.
# Also, if there is an active context handle such as a loaded buffer,
Expand All @@ -203,7 +203,7 @@ def reloadAppModules():
mod._helperPreventDisconnect = True
terminate()
del appModules
mods=[k for k,v in sys.modules.iteritems() if k.startswith("appModules") and v is not None]
mods=[k for k,v in sys.modules.items() if k.startswith("appModules") and v is not None]
for mod in mods:
del sys.modules[mod]
import appModules
Expand Down Expand Up @@ -232,7 +232,7 @@ def initialize():
_importers=list(pkgutil.iter_importers("appModules.__init__"))

def terminate():
for processID, app in runningTable.iteritems():
for processID, app in runningTable.items():
try:
app.terminate()
except:
Expand Down
8 changes: 4 additions & 4 deletions source/baseObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ def invalidateCaches(cls):
"""
# We use keys() here instead of iterkeys(), as invalidating the cache on an object may cause instances to disappear,
# which would in turn cause an exception due to the dictionary changing size during iteration.
for instance in cls.__instances.keys():
# #9067 (Py3 review required): because of this, wrap this in a list, as dict.keys() in Python 3 returns iterators.
for instance in list(cls.__instances.keys()):
instance.invalidateCache()

class ScriptableType(AutoPropertyType):
Expand All @@ -173,8 +174,7 @@ def __new__(meta, name, bases, dict):
# This class currently has no gestures dictionary,
# because no custom __gestures dictionary has been defined.
gestures = {}
# Python 3 incompatible.
for name, script in dict.iteritems():
for name, script in dict.items():
if not name.startswith('script_'):
continue
scriptName = name[len("script_"):]
Expand Down Expand Up @@ -261,7 +261,7 @@ def bindGestures(self, gestureMap):
@param gestureMap: A mapping of gesture identifiers to script names.
@type gestureMap: dict of str to str
"""
for gestureIdentifier, scriptName in gestureMap.iteritems():
for gestureIdentifier, scriptName in gestureMap.items():
if scriptName:
try:
self.bindGesture(gestureIdentifier, scriptName)
Expand Down
8 changes: 4 additions & 4 deletions source/bdDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def getDriversForConnectedUsbDevices():
for port in deviceInfoFetcher.comPorts if "usbID" in port)
)
for match in usbDevs:
for driver, devs in _driverDevices.iteritems():
for type, ids in devs.iteritems():
for driver, devs in _driverDevices.items():
for type, ids in devs.items():
if match.type==type and match.id in ids:
yield driver, match

Expand All @@ -136,7 +136,7 @@ def getDriversForPossibleBluetoothDevices():
for port in deviceInfoFetcher.hidDevices if port["provider"]=="bluetooth"),
)
for match in btDevs:
for driver, devs in _driverDevices.iteritems():
for driver, devs in _driverDevices.items():
matchFunc = devs[KEY_BLUETOOTH]
if not callable(matchFunc):
continue
Expand Down Expand Up @@ -334,7 +334,7 @@ def getConnectedUsbDevicesForDriver(driver):
for port in deviceInfoFetcher.comPorts if "usbID" in port)
)
for match in usbDevs:
for type, ids in devs.iteritems():
for type, ids in devs.items():
if match.type==type and match.id in ids:
yield match

Expand Down
2 changes: 1 addition & 1 deletion source/brailleDisplayDrivers/baum.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def __init__(self, model, keysDown):
self.keysDown = dict(keysDown)

self.keyNames = names = []
for group, groupKeysDown in keysDown.iteritems():
for group, groupKeysDown in keysDown.items():
if group == BAUM_BRAILLE_KEYS and len(keysDown) == 1 and not groupKeysDown & 0xfc:
# This is braille input.
# 0xfc covers command keys. The space bars are covered by 0x3.
Expand Down
2 changes: 1 addition & 1 deletion source/brailleDisplayDrivers/brltty.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
try:
import brlapi
BRLAPI_CMD_KEYS = dict((code, name[8:].lower())
for name, code in brlapi.__dict__.iteritems() if name.startswith("KEY_CMD_"))
for name, code in brlapi.__dict__.items() if name.startswith("KEY_CMD_"))
except ImportError:
pass

Expand Down
6 changes: 3 additions & 3 deletions source/brailleDisplayDrivers/eurobraille.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ def __init__(self, display):
self.model = display.deviceType.lower().split(" ")[0]
keysDown = dict(display.keysDown)
self.keyNames = names = []
for group, groupKeysDown in keysDown.iteritems():
for group, groupKeysDown in keysDown.items():
if group == EB_KEY_BRAILLE:
if sum(keysDown.itervalues())==groupKeysDown and not groupKeysDown & 0x100:
if sum(keysDown.values())==groupKeysDown and not groupKeysDown & 0x100:
# This is braille input.
# 0x1000 is backspace, 0x2000 is space
self.dots = groupKeysDown & 0xff
Expand All @@ -565,7 +565,7 @@ def __init__(self, display):
self.routingIndex = (groupKeysDown & 0xff)-1
names.append("doubleRouting" if groupKeysDown>>8 ==ord(EB_KEY_INTERACTIVE_DOUBLE_CLICK) else "routing")
if group == EB_KEY_COMMAND:
for key, keyName in display.keys.iteritems():
for key, keyName in display.keys.items():
if groupKeysDown & key:
# This key is pressed
names.append(keyName)
Expand Down
4 changes: 3 additions & 1 deletion source/brailleTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def listTables():
@return: A list of braille tables.
@rtype: list of L{BrailleTable}
"""
tables = _tables.values()
# #9067 (Py3 review required): originally called dict.values.
# Therefore wrap this inside a list call.
tables = list(_tables.values())
tables.sort(key=lambda table: table.displayName)
return tables

Expand Down
Loading