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 f868d8d5ee
commit 20db141c3a
47 changed files with 117 additions and 113 deletions

View File

@@ -57,7 +57,7 @@ class PathArray(gui_base_original.Modifier):
"""
def __init__(self, use_link=False):
super().__init__()
super(PathArray, self).__init__()
self.use_link = use_link
def GetResources(self):
@@ -73,7 +73,7 @@ class PathArray(gui_base_original.Modifier):
def Activated(self, name=_tr("Path array")):
"""Execute when the command is called."""
super().Activated(name=name)
super(PathArray, self).Activated(name=name)
if not Gui.Selection.getSelectionEx():
if self.ui:
self.ui.selectUi()
@@ -115,7 +115,7 @@ class PathLinkArray(PathArray):
"""Gui Command for the PathLinkArray tool based on the PathArray tool."""
def __init__(self):
super().__init__(use_link=True)
super(PathLinkArray, self).__init__(use_link=True)
def GetResources(self):
"""Set icon, menu and tooltip."""
@@ -131,7 +131,7 @@ class PathLinkArray(PathArray):
def Activated(self):
"""Execute when the command is called."""
super().Activated(name=_tr("Link path array"))
super(PathLinkArray, self).Activated(name=_tr("Link path array"))
Gui.addCommand('Draft_PathLinkArray', PathLinkArray())