From b50aab52e9e45178c317cb6efc258244a1943161 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Fri, 5 Sep 2014 14:19:45 -0400 Subject: [PATCH 28/30] Let finding install classes be more flexible for Fedora (#1155452). Related: rhbz#1155452 (1) Make it so a valid install class does not have to be named "InstallClass" which should make inheritance less cumbersome. (2) Allow putting more than one install class into a single file. (3) Rename the existing install classes to be BaseInstallClass. This makes it more clear for subclasses where they're coming from. Port of commit 8c2550d20d7fd8964cd3ec5797ff34949fe0f8fd from master. --- pyanaconda/installclass.py | 16 ++++++---------- pyanaconda/installclasses/fedora.py | 2 +- pyanaconda/installclasses/rhel.py | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py index 76609de..83af984 100644 --- a/pyanaconda/installclass.py +++ b/pyanaconda/installclass.py @@ -183,7 +183,6 @@ def availableClasses(showHidden=0): if done.has_key(mainName): continue done[mainName] = 1 - try: found = imputil.imp.find_module(mainName) except ImportError as e: @@ -192,16 +191,13 @@ def availableClasses(showHidden=0): try: loaded = imputil.imp.load_module(mainName, found[0], found[1], found[2]) + for (_key, obj) in loaded.__dict__.items(): + # If it's got these two methods, it's an InstallClass. + if hasattr(obj, "setDefaultPartitioning") and hasattr(obj, "setPackageSelection"): + sortOrder = getattr(obj, "sortPriority", 0) + if obj.hidden == 0 or showHidden == 1: + list.append(((obj.name, obj), sortOrder)) - obj = loaded.InstallClass - - if obj.__dict__.has_key('sortPriority'): - sortOrder = obj.sortPriority - else: - sortOrder = 0 - - if obj.hidden == 0 or showHidden == 1: - list.append(((obj.name, obj), sortOrder)) except ImportError as e: log.warning ("module import of %s failed: %s" % (mainName, sys.exc_type)) if flags.debug: raise diff --git a/pyanaconda/installclasses/fedora.py b/pyanaconda/installclasses/fedora.py index 3e0a5f2..058fdba 100644 --- a/pyanaconda/installclasses/fedora.py +++ b/pyanaconda/installclasses/fedora.py @@ -26,7 +26,7 @@ from pyanaconda.i18n import _, N_ import os, types -class InstallClass(BaseInstallClass): +class FedoraBaseInstallClass(BaseInstallClass): # name has underscore used for mnemonics, strip if you dont need it id = "fedora" name = N_("_Fedora") diff --git a/pyanaconda/installclasses/rhel.py b/pyanaconda/installclasses/rhel.py index 8a694e3..a0dae4c 100644 --- a/pyanaconda/installclasses/rhel.py +++ b/pyanaconda/installclasses/rhel.py @@ -25,7 +25,7 @@ from pyanaconda import nm from pyanaconda import iutil import types -class InstallClass(BaseInstallClass): +class RHELBaseInstallClass(BaseInstallClass): # name has underscore used for mnemonics, strip if you dont need it id = "rhel" name = N_("Red Hat Enterprise Linux") -- 1.9.3