Condense code that checks for various things in 'options' to use a loop
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 17:58:28 +0000 (11:58 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 17:58:28 +0000 (11:58 -0600)
ChangeLog
catalyst

index 2271a72a92bd36d1992e86486a03820b9656aaa3..aee3dadc04faba844202e9da7f707e051d0f9b39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
 # Distributed under the GPL v2
 
+  11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org> catalyst:
+  Condense code that checks for various things in 'options' to use a loop
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
   modules/catalyst/arch/__init__.py, modules/catalyst/target/__init__.py,
   modules/catalyst/target/generic_stage.py:
index 18e72862d4876a11e9035e8b7d0aed8682b9edbd..f427c233c546f36d8bc0bd5bde817e84c4d2968b 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -6,8 +6,9 @@
 
 import os, sys, getopt
 
+# This assumes that our modules are in a sub-dir named "modules" in the
+# directory that the main catalyst binary is in
 __selfpath__ = os.path.abspath(os.path.dirname(__file__))
-
 sys.path.append(__selfpath__ + "/modules")
 
 import catalyst.config
@@ -103,60 +104,29 @@ def parse_config(myconfig):
                        print "Setting",x,"to default value \""+confdefaults[x]+"\""
                        conf_values[x]=confdefaults[x]
 
+       options = (
+               ("autoresume", "AUTORESUME", "Autoresuming support enabled."),
+               ("ccache", "CCACHE", "Compiler cache support enabled."),
+               ("clear-autoresume", "CLEAR_AUTORESUME", "Cleaning autoresume flags support enabled"),
+#              ("compress", "COMPRESS", "Compression enabled."),
+               ("distcc", "DISTCC", "Distcc support enabled."),
+               ("icecream", "ICECREAM", "Icecream compiler cluster support enabled."),
+               ("kerncache", "KERNCACHE", "Kernel cache support enabled."),
+               ("pkgcache", "PKGCACHE", "Package cache support enabled."),
+               ("purge", "PURGE", "Purge support enabled."),
+               ("seedcache", "SEEDCACHE", "Seed cache support enabled."),
+               ("snapcache", "SNAPCACHE", "Snapshot cache support enabled."),
+               ("metadata_overlay", "METADATA_OVERLAY", "Use of metadata_overlay module for portage enabled."),
+#              ("tarball", "TARBALL", "Tarball creation enabled.")
+       )
+
        split_options = conf_values["options"].split()
 
        # parse out the rest of the options from the config file
-       if "autoresume" in split_options:
-               print "Autoresuming support enabled."
-               conf_values["AUTORESUME"]="1"
-
-       if "ccache" in split_options:
-               print "Compiler cache support enabled."
-               conf_values["CCACHE"]="1"
-
-       if "clear-autoresume" in split_options:
-               print "Cleaning autoresume flags support enabled."
-               conf_values["CLEAR_AUTORESUME"]="1"
-
-#      if "compress" in split_options:
-#              print "Compression enabled."
-#              conf_values["COMPRESS"]="1"
-
-       if "distcc" in split_options:
-               print "Distcc support enabled."
-               conf_values["DISTCC"]="1"
-
-       if "icecream" in split_options:
-               print "Icecream compiler cluster support enabled."
-               conf_values["ICECREAM"]="1"
-
-       if "kerncache" in split_options:
-               print "Kernel cache support enabled."
-               conf_values["KERNCACHE"]="1"
-
-       if "pkgcache" in split_options:
-               print "Package cache support enabled."
-               conf_values["PKGCACHE"]="1"
-
-       if "purge" in split_options:
-               print "Purge support enabled."
-               conf_values["PURGE"]="1"
-
-       if "seedcache" in split_options:
-               print "Seed cache support enabled."
-               conf_values["SEEDCACHE"]="1"
-
-       if "snapcache" in split_options:
-               print "Snapshot cache support enabled."
-               conf_values["SNAPCACHE"]="1"
-
-       if "metadata_overlay" in conf_values["options"].split():
-               print "Use of metadata_overlay module for portage enabled."
-               conf_values["METADATA_OVERLAY"]="1"
-
-#      if "tarball" in split_options:
-#              print "Tarball creation enabled."
-#              conf_values["TARBALL"]="1"
+       for x in options:
+               if x[0] in split_options:
+                       print x[2]
+                       conf_values[x[1]] = "1"
 
        if "digests" in myconf:
                conf_values["digests"]=myconf["digests"]
@@ -221,7 +191,6 @@ def verify_digest_and_hash_functions():
                        print "Catalyst aborting...."
                        sys.exit(2)
 
-
 if __name__ == "__main__":
 
        show_version()