From 67ca270cd38b3fc6c775da680616cd2e6653614b Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:07:58 -0700 Subject: [PATCH 1/9] NVDA object: metaclass syntax. Python 2 classes can specify metaclasses via __metaclass__ attribute, whereas a metaclass keyword argument is required in Python 3. Thus use Python 3 native syntax for specifying metaclasses. --- source/NVDAObjects/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/NVDAObjects/__init__.py b/source/NVDAObjects/__init__.py index 4518d60b30a..196932a6d1a 100644 --- a/source/NVDAObjects/__init__.py +++ b/source/NVDAObjects/__init__.py @@ -147,7 +147,7 @@ def clearDynamicClassCache(cls): """ cls._dynamicClassCache.clear() -class NVDAObject(with_metaclass(DynamicNVDAObjectType, documentBase.TextContainerObject,baseObject.ScriptableObject)): +class NVDAObject(documentBase.TextContainerObject, baseObject.ScriptableObject, metaclass=DynamicNVDAObjectType): """NVDA's representation of a single control/widget. Every widget, regardless of how it is exposed by an application or the operating system, is represented by a single NVDAObject instance. This allows NVDA to work with all widgets in a uniform way. From 9de291fdbb860db71341267e0c9c6fe158575d08 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:08:33 -0700 Subject: [PATCH 2/9] Excel window object: metaclass syntax. --- source/NVDAObjects/window/excel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/NVDAObjects/window/excel.py b/source/NVDAObjects/window/excel.py index 87ea5eadb5d..0bedd659251 100755 --- a/source/NVDAObjects/window/excel.py +++ b/source/NVDAObjects/window/excel.py @@ -1085,7 +1085,7 @@ class FormulaExcelCellInfoQuickNavItem(ExcelCellInfoQuickNavItem): def label(self): return "%s: %s"%(self.excelCellInfo.address.split('!')[-1],self.excelCellInfo.formula) -class ExcelCellInfoQuicknavIterator(with_metaclass(abc.ABCMeta,object)): +class ExcelCellInfoQuicknavIterator(object, metaclass=abc.ABCMeta): cellInfoFlags=NVCELLINFOFLAG_ADDRESS|NVCELLINFOFLAG_COORDS @abc.abstractproperty From f04bebfe0bb5ca04d463b646b1b4f76d02c0f44d Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:09:18 -0700 Subject: [PATCH 3/9] Base object: metaclass syntax. --- source/baseObject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/baseObject.py b/source/baseObject.py index f04895a4e5e..5d946a2f651 100755 --- a/source/baseObject.py +++ b/source/baseObject.py @@ -104,7 +104,7 @@ def __init__(self,name,bases,dict): # The __abstractmethods__ set is frozen, therefore we ought to override it. self.__abstractmethods__=(self.__abstractmethods__|newAbstractProps)-oldAbstractProps -class AutoPropertyObject(with_metaclass(AutoPropertyType, object)): +class AutoPropertyObject(object, metaclass=AutoPropertyType): """A class that dynamically supports properties, by looking up _get_*, _set_*, and _del_* methods at runtime. _get_x will make property x with a getter (you can get its value). _set_x will make a property x with a setter (you can set its value). @@ -188,7 +188,7 @@ def __new__(meta, name, bases, dict): setattr(cls, gesturesDictName, gestures) return cls -class ScriptableObject(with_metaclass(ScriptableType, AutoPropertyObject)): +class ScriptableObject(AutoPropertyObject, metaclass=ScriptableType): """A class that implements NVDA's scripting interface. Input gestures are bound to scripts such that the script will be executed when the appropriate input gesture is received. Scripts are methods named with a prefix of C{script_}; e.g. C{script_foo}. From 1ee431f2aad8a33fbac021c660837af1241cf087 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:10:23 -0700 Subject: [PATCH 4/9] Browse mode: metaclass syntax. --- source/browseMode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/browseMode.py b/source/browseMode.py index 255ce94d576..68ba48583f9 100644 --- a/source/browseMode.py +++ b/source/browseMode.py @@ -93,7 +93,7 @@ def mergeQuickNavItemIterators(iterators,direction="next"): continue curValues.append((it,newVal)) -class QuickNavItem(with_metaclass(ABCMeta, object)): +class QuickNavItem(object, metaclass=ABCMeta): """ Emitted by L{BrowseModeTreeInterceptor._iterNodesByType}, this represents one of many positions in a browse mode document, based on the type of item being searched for (e.g. link, heading, table etc).""" itemType=None #: The type of items searched for (e.g. link, heading, table etc) From 11bc04799c405096cb2b2bb382bea65e417e036f Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:11:21 -0700 Subject: [PATCH 5/9] Content recog: metaclass syntax. --- source/contentRecog/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/contentRecog/__init__.py b/source/contentRecog/__init__.py index 2c26da70325..72e05adb2de 100644 --- a/source/contentRecog/__init__.py +++ b/source/contentRecog/__init__.py @@ -19,7 +19,7 @@ from six import with_metaclass from locationHelper import RectLTWH -class ContentRecognizer(with_metaclass(ABCMeta, object)): +class ContentRecognizer(object, metaclass=ABCMeta): """Implementation of a content recognizer. """ @@ -129,7 +129,7 @@ def convertHeightToScreen(self, height): """ return int(height / self.resizeFactor) -class RecognitionResult(with_metaclass(ABCMeta, object)): +class RecognitionResult(object, metaclass=ABCMeta): """Provides access to the result of recognition by a recognizer. The result is textual, but to facilitate navigation by word, line, etc. and to allow for retrieval of screen coordinates within the text, From 54fb9916c105f3e83d0dae13110e2f1bfca9d6ce Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:12:24 -0700 Subject: [PATCH 6/9] Acc prop server: metaclass syntax. --- source/gui/accPropServer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/accPropServer.py b/source/gui/accPropServer.py index 6886b6fbcb8..d54817bb946 100644 --- a/source/gui/accPropServer.py +++ b/source/gui/accPropServer.py @@ -16,7 +16,7 @@ import winUser import wx -class IAccPropServer_Impl(with_metaclass(ABCMeta, COMObject)): +class IAccPropServer_Impl(COMObject, metaclass=ABCMeta): """Base class for implementing a COM interface for a hwnd based AccPropServer\ to annotate a WX control. The AccPropServer registers itself using the window handle of the WX control. From b9bc44149ca79aeed3fef75f8ab92ba9dbde0adf Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:13:12 -0700 Subject: [PATCH 7/9] Settings dialogs: metaclass syntax. --- source/gui/settingsDialogs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index 1e13fbf7342..c3e9f235970 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -50,7 +50,7 @@ import keyLabels from .dpiScalingHelper import DpiScalingHelperMixin -class SettingsDialog(with_metaclass(guiHelper.SIPABCMeta, wx.Dialog, DpiScalingHelperMixin)): +class SettingsDialog(wx.Dialog, DpiScalingHelperMixin, metaclass=guiHelper.SIPABCMeta): """A settings dialog. A settings dialog consists of one or more settings controls and OK and Cancel buttons and an optional Apply button. Action may be taken in response to the OK, Cancel or Apply buttons. @@ -243,7 +243,7 @@ def _onWindowDestroy(self, evt): # redo the layout in whatever way makes sense for their particular content. _RWLayoutNeededEvent, EVT_RW_LAYOUT_NEEDED = wx.lib.newevent.NewCommandEvent() -class SettingsPanel(with_metaclass(guiHelper.SIPABCMeta, wx.Panel, DpiScalingHelperMixin)): +class SettingsPanel(wx.Panel, DpiScalingHelperMixin, metaclass=guiHelper.SIPABCMeta): """A settings panel, to be used in a multi category settings dialog. A settings panel consists of one or more settings controls. Action may be taken in response to the parent dialog's OK or Cancel buttons. From c79a485cb32b956007d055b2765be12ea9b07364 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:13:48 -0700 Subject: [PATCH 8/9] Speech commands: metaclass syntax. --- source/speech/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/speech/commands.py b/source/speech/commands.py index 2aa1e10687a..211f3d80f6e 100644 --- a/source/speech/commands.py +++ b/source/speech/commands.py @@ -229,7 +229,7 @@ def __repr__(self): out += ", text=%r" % self.text return out + ")" -class BaseCallbackCommand(with_metaclass(ABCMeta, SpeechCommand)): +class BaseCallbackCommand(SpeechCommand, metaclass=ABCMeta): """Base class for commands which cause a function to be called when speech reaches them. This class should not be instantiated directly. It is designed to be subclassed to provide specific functionality; From 8b19817f7b8e092d1d3b46366358808a7b1e3f80 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sat, 15 Jun 2019 21:36:00 -0700 Subject: [PATCH 9/9] Metaclass: remove six.with_metaclass import as Python 3 native metaclass syntax is used. --- source/NVDAObjects/__init__.py | 1 - source/NVDAObjects/window/excel.py | 1 - source/baseObject.py | 1 - source/browseMode.py | 1 - source/contentRecog/__init__.py | 1 - source/gui/accPropServer.py | 1 - source/gui/settingsDialogs.py | 1 - source/speech/commands.py | 1 - 8 files changed, 8 deletions(-) diff --git a/source/NVDAObjects/__init__.py b/source/NVDAObjects/__init__.py index 196932a6d1a..05b2877b2be 100644 --- a/source/NVDAObjects/__init__.py +++ b/source/NVDAObjects/__init__.py @@ -7,7 +7,6 @@ """Module that contains the base NVDA object type""" -from six import with_metaclass import time import re import weakref diff --git a/source/NVDAObjects/window/excel.py b/source/NVDAObjects/window/excel.py index 0bedd659251..acc5f303c4f 100755 --- a/source/NVDAObjects/window/excel.py +++ b/source/NVDAObjects/window/excel.py @@ -5,7 +5,6 @@ #See the file COPYING for more details. import abc -from six import with_metaclass import ctypes from comtypes import COMError, BSTR import comtypes.automation diff --git a/source/baseObject.py b/source/baseObject.py index 5d946a2f651..30635416391 100755 --- a/source/baseObject.py +++ b/source/baseObject.py @@ -10,7 +10,6 @@ import weakref from logHandler import log from abc import ABCMeta, abstractproperty -from six import with_metaclass class Getter(object): diff --git a/source/browseMode.py b/source/browseMode.py index 68ba48583f9..62d46770171 100644 --- a/source/browseMode.py +++ b/source/browseMode.py @@ -35,7 +35,6 @@ import gui.guiHelper from NVDAObjects import NVDAObject from abc import ABCMeta, abstractmethod -from six import with_metaclass REASON_QUICKNAV = "quickNav" diff --git a/source/contentRecog/__init__.py b/source/contentRecog/__init__.py index 72e05adb2de..29c9258d389 100644 --- a/source/contentRecog/__init__.py +++ b/source/contentRecog/__init__.py @@ -16,7 +16,6 @@ from collections import namedtuple import textInfos.offsets from abc import ABCMeta, abstractmethod -from six import with_metaclass from locationHelper import RectLTWH class ContentRecognizer(object, metaclass=ABCMeta): diff --git a/source/gui/accPropServer.py b/source/gui/accPropServer.py index d54817bb946..7560c7b07f6 100644 --- a/source/gui/accPropServer.py +++ b/source/gui/accPropServer.py @@ -11,7 +11,6 @@ from comtypes import COMObject, GUID from comInterfaces.Accessibility import IAccPropServer, ANNO_CONTAINER, ANNO_THIS from abc import ABCMeta, abstractmethod, abstractproperty -from six import with_metaclass import weakref import winUser import wx diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index c3e9f235970..48917baa23b 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -7,7 +7,6 @@ import logging from abc import abstractmethod -from six import with_metaclass import os import copy import re diff --git a/source/speech/commands.py b/source/speech/commands.py index 211f3d80f6e..47e83ad7115 100644 --- a/source/speech/commands.py +++ b/source/speech/commands.py @@ -7,7 +7,6 @@ """Commands that can be embedded in a speech sequence for changing synth parameters, playing sounds or running other callbacks.""" from abc import ABCMeta, abstractmethod -from six import with_metaclass import config import languageHandler from synthDriverHandler import getSynth