[master 30/30] Convert Python 2 metaclass magic to Python 3 metaclass magic (#1014220)

M4rtinK installerbot-noreply at redhat.com
Mon Jun 1 14:04:47 UTC 2015


From: Martin Kolman <mkolman at redhat.com>

---
 pyanaconda/ui/common.py      |  8 ++------
 pyanaconda/ui/gui/helpers.py | 12 +++---------
 pyanaconda/ui/helpers.py     | 12 +++---------
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index e4f994e..7134dff 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -159,7 +159,7 @@ def should_run(cls, environment, data):
         else:
             return False
 
-class Spoke(object):
+class Spoke(object, metaclass=ABCMeta):
     """A Spoke is a single configuration screen.  There are several different
        places where a Spoke can be displayed, each of which will have its own
        unique class.  A Spoke is typically used when an element in the Hub is
@@ -187,8 +187,6 @@ class Spoke(object):
                      given, the default from SpokeSelector will be used.
     """
 
-    __metaclass__ = ABCMeta
-
     category = None
     icon = None
     title = None
@@ -440,7 +438,7 @@ def __init__(self, storage, payload, instclass):
     def status(self):
         return None
 
-class Hub(object):
+class Hub(object, metaclass=ABCMeta):
     """A Hub is an overview UI screen.  A Hub consists of one or more grids of
        configuration options that the user may choose from.  Each grid is
        provided by a SpokeCategory, and each option is provided by a Spoke.
@@ -462,8 +460,6 @@ class Hub(object):
        additional standalone screens either before or after them.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, storage, payload, instclass):
         """Create a new Hub instance.
 
diff --git a/pyanaconda/ui/gui/helpers.py b/pyanaconda/ui/gui/helpers.py
index 320f933..2c9de61 100644
--- a/pyanaconda/ui/gui/helpers.py
+++ b/pyanaconda/ui/gui/helpers.py
@@ -29,15 +29,13 @@
 
 # Inherit abstract methods from InputCheckHandler
 # pylint: disable=abstract-method
-class GUIInputCheckHandler(InputCheckHandler):
+class GUIInputCheckHandler(InputCheckHandler, metaclass=ABCMeta):
     """Provide InputCheckHandler functionality for Gtk input screens.
 
        This class assumes that all input objects are of type GtkEditable and
        attaches InputCheck.update_check_status to the changed signal.
     """
 
-    __metaclass__ = ABCMeta
-
     def _update_check_status(self, editable, inputcheck):
         inputcheck.update_check_status()
 
@@ -49,7 +47,7 @@ def add_check(self, input_obj, run_check, data=None):
         input_obj.connect_after("changed", self._update_check_status, checkRef)
         return checkRef
 
-class GUIDialogInputCheckHandler(GUIInputCheckHandler):
+class GUIDialogInputCheckHandler(GUIInputCheckHandler, metaclass=ABCMeta):
     """Provide InputCheckHandler functionality for Gtk dialogs.
 
        This class provides a helper method for setting an error message
@@ -58,8 +56,6 @@ class GUIDialogInputCheckHandler(GUIInputCheckHandler):
        ignore activated signals.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def set_status(self, inputcheck):
         if inputcheck.check_status in (InputCheck.CHECK_OK, InputCheck.CHECK_SILENT):
@@ -71,7 +67,7 @@ def set_status(self, inputcheck):
             inputcheck.input_obj.set_icon_tooltip_text(Gtk.EntryIconPosition.SECONDARY,
                 inputcheck.check_status)
 
-class GUISpokeInputCheckHandler(GUIInputCheckHandler):
+class GUISpokeInputCheckHandler(GUIInputCheckHandler, metaclass=ABCMeta):
     """Provide InputCheckHandler functionality for graphical spokes.
 
        This class implements set_status to set a message in the warning area of
@@ -79,8 +75,6 @@ class GUISpokeInputCheckHandler(GUIInputCheckHandler):
        prevent the user from exiting a spoke with bad input.
     """
 
-    __metaclass__ = ABCMeta
-
     def set_status(self, inputcheck):
         """Update the warning with the input validation error from the first
            error message.
diff --git a/pyanaconda/ui/helpers.py b/pyanaconda/ui/helpers.py
index b7851a1..0730afb 100644
--- a/pyanaconda/ui/helpers.py
+++ b/pyanaconda/ui/helpers.py
@@ -66,9 +66,7 @@
 import logging
 import copy
 
-class StorageChecker(object):
-    __metaclass__ = ABCMeta
-
+class StorageChecker(object, metaclass=ABCMeta):
     log = logging.getLogger("anaconda")
     errors = []
     warnings = []
@@ -102,15 +100,13 @@ def checkStorage(self):
         for w in StorageChecker.warnings:
             self.log.warning(w)
 
-class SourceSwitchHandler(object):
+class SourceSwitchHandler(object, metaclass=ABCMeta):
     """ A class that can be used as a mixin handling
     installation source switching.
     It will correctly switch to the new method
     and cleanup any previous method set.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractproperty
     def data(self):
         pass
@@ -269,7 +265,7 @@ def enabled(self):
     def enabled(self, value):
         self._enabled = value
 
-class InputCheckHandler(object):
+class InputCheckHandler(object, metaclass=ABCMeta):
     """Provide a framework for adding input validation checks to a screen.
 
        This helper class provides a mean of defining and associating input
@@ -284,8 +280,6 @@ class InputCheckHandler(object):
        functionality.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self):
         self._check_list = []
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/233508fa1826e4c96d62977703a7d09ae59d6fee


More information about the anaconda-patches mailing list