Draft: change super() so it is compatible with Python 2

In Python 3 `super()` can be used without an argument
in order to get the parent class, `super()`.
In Python 2 the present class must be used as an argument,
`super(ThisClass, self)`.

This commit is done to support Python 2,
as without it all Gui Command tools will be broken
and will fail to launch, even if the unit tests pass.

Also, set the `__metaclass__` variable to `type`.
This is done to turn all classes into "new style" classes
in Python 2. This is required so `super()` works correctly
in this version of Pyton.

This commit can be reverted once Python 2 support
is completely dropped, and only Python 3 compatible code
is used.
This commit is contained in:
vocx-fc
2020-04-11 14:01:38 -05:00
committed by Yorik van Havre
parent b25f7f42fb
commit cc75bf91d7
47 changed files with 117 additions and 113 deletions

View File

@@ -56,7 +56,7 @@ class Array(gui_base_original.Modifier):
"""
def __init__(self, use_link=False):
super().__init__()
super(Array, self).__init__()
self.use_link = use_link
def GetResources(self):
@@ -72,7 +72,7 @@ class Array(gui_base_original.Modifier):
def Activated(self, name=_tr("Array")):
"""Execute when the command is called."""
super().Activated(name=name)
super(Array, self).Activated(name=name)
if not Gui.Selection.getSelection():
if self.ui:
self.ui.selectUi()
@@ -114,7 +114,7 @@ class LinkArray(Array):
"""Gui Command for the LinkArray tool based on the simple Array tool."""
def __init__(self):
super().__init__(use_link=True)
super(LinkArray, self).__init__(use_link=True)
def GetResources(self):
"""Set icon, menu and tooltip."""
@@ -128,7 +128,7 @@ class LinkArray(Array):
def Activated(self):
"""Execute when the command is called."""
super().Activated(name=_tr("Link array"))
super(LinkArray, self).Activated(name=_tr("Link array"))
Gui.addCommand('Draft_LinkArray', LinkArray())