[PATCH] Let finding install classes be more flexible for Fedora (#1138820).

Martin Kolman mkolman at redhat.com
Fri Sep 5 20:42:08 UTC 2014



----- Original Message -----
> From: "Chris Lumens" <clumens at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Friday, September 5, 2014 8:21:30 PM
> Subject: [PATCH] Let finding install classes be more flexible for Fedora	(#1138820).
> 
> (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 <distro>BaseInstallClass.  This
> makes it more clear for subclasses where they're coming from.
> ---
>  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 4fd8865..3a52f65 100644
> --- a/pyanaconda/installclass.py
> +++ b/pyanaconda/installclass.py
> @@ -185,7 +185,6 @@ def availableClasses(showHidden=0):
>              continue
>          done[mainName] = 1
>  
> -
>          try:
>              found = imputil.imp.find_module(mainName)
>          except ImportError:
> @@ -195,15 +194,12 @@ def availableClasses(showHidden=0):
>          try:
>              loaded = imputil.imp.load_module(mainName, found[0], found[1],
>              found[2])
>  
> -            obj = loaded.InstallClass
> -
> -            if 'sortPriority' in obj.__dict__:
> -                sortOrder = obj.sortPriority
> -            else:
> -                sortOrder = 0
> -
> -            if obj.hidden == 0 or showHidden == 1:
> -                lst.append(((obj.name, obj), sortOrder))
> +            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:
> +                        lst.append(((obj.name, obj), sortOrder))
>          except (ImportError, AttributeError):
>              log.warning ("module import of %s failed: %s", mainName,
>              sys.exc_type)
>  
> diff --git a/pyanaconda/installclasses/fedora.py
> b/pyanaconda/installclasses/fedora.py
> index 1fe192b..d2dbb73 100644
> --- a/pyanaconda/installclasses/fedora.py
> +++ b/pyanaconda/installclasses/fedora.py
> @@ -23,7 +23,7 @@ from pyanaconda import network
>  from pyanaconda import nm
>  from pyanaconda.i18n import N_
>  
> -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 ed8511e..5931432 100644
> --- a/pyanaconda/installclasses/rhel.py
> +++ b/pyanaconda/installclasses/rhel.py
> @@ -23,7 +23,7 @@ from pyanaconda.product import productName
>  from pyanaconda import network
>  from pyanaconda import nm
>  
> -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
Looks good to me - thanks & ACK! :)
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 


More information about the anaconda-patches mailing list