Get rid of arches and targets classes and move functions into the module instead
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 17:44:13 +0000 (11:44 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 17:44:13 +0000 (11:44 -0600)
ChangeLog
modules/catalyst/arch/__init__.py
modules/catalyst/target/__init__.py
modules/catalyst/target/generic_stage.py

index a50829db5ff52228817fa0209393dae22b24e1b8..2271a72a92bd36d1992e86486a03820b9656aaa3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
 # Distributed under the GPL v2
 
+  11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+  modules/catalyst/arch/__init__.py, modules/catalyst/target/__init__.py,
+  modules/catalyst/target/generic_stage.py:
+  Get rid of arches and targets classes and move functions into the module
+  instead
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
   targets/embedded/embedded-chroot.sh,
   targets/embedded/embedded-controller.sh, targets/grp/grp-controller.sh,
index f421e60bc296366ad85641b27ba1f051b219de3b..1e6fa10912d194598e7f451ec7e548dd95dcbf7f 100644 (file)
@@ -9,25 +9,21 @@ import catalyst.util
 # This is only until we move all the output stuff into catalyst.output
 from catalyst.support import msg
 
-class arches:
-
-       def __init__(self):
-               self._arch_modules = {}
-
-       def find_arch_modules(self):
-               search_dir = os.path.abspath(os.path.dirname(__file__))
-               arch_module_list = [x[:-3] for x in os.listdir(search_dir) \
-                       if x.endswith('.py') and not x.startswith('__')]
-               return arch_module_list
-
-       def get_arches(self):
-               for x in self.find_arch_modules():
-                       self._arch_modules[x] = catalyst.util.load_module("catalyst.arch." + x)
-                       if self._arch_modules[x] is None:
-                               msg("Cannot import catalyst.arch." + x + ". This usually only " + \
-                                       "happens due to a syntax error, which should be reported as " \
-                                       "a bug.")
-               return self._arch_modules
+def find_arch_modules(self):
+       search_dir = os.path.abspath(os.path.dirname(__file__))
+       arch_module_list = [x[:-3] for x in os.listdir(search_dir) \
+               if x.endswith('.py') and not x.startswith('__')]
+       return arch_module_list
+
+def get_arches(self):
+       arch_modules = {}
+       for x in find_arch_modules():
+               arch_modules[x] = catalyst.util.load_module("catalyst.arch." + x)
+               if arch_modules[x] is None:
+                       msg("Cannot import catalyst.arch." + x + ". This usually only " + \
+                               "happens due to a syntax error, which should be reported as " \
+                               "a bug.")
+       return arch_modules
 
 class generic_arch:
 
index a482efa75f2a3f6b33626e0d0c18bd66c5feb4d4..7f8602b41ba68cc79355deddd0b1be65bd706cdb 100644 (file)
@@ -9,31 +9,26 @@ import catalyst.util
 # This is only until we move all the output stuff into catalyst.output
 from catalyst.support import msg
 
-class targets:
+def find_target_modules():
+       search_dir = os.path.abspath(os.path.dirname(__file__))
+       target_module_list = [x[:-3] for x in os.listdir(search_dir) \
+               if x.endswith('.py') and not x.startswith('__')]
+       return target_module_list
 
-       def __init__(self):
-               self._target_modules = {}
-
-       def find_target_modules(self):
-               search_dir = os.path.abspath(os.path.dirname(__file__))
-               target_module_list = [x[:-3] for x in os.listdir(search_dir) \
-                       if x.endswith('.py') and not x.startswith('__')]
-               return target_module_list
-
-       def get_targets(self):
-               for x in self.find_target_modules():
-                       self._target_modules[x] = catalyst.util.load_module("catalyst.target." + x)
-                       if self._target_modules[x] is None:
-                               msg("Cannot import catalyst.target." + x + ". This usually only " + \
-                                       "happens due to a syntax error, which should be reported as " \
-                                       "a bug.")
-               return self._target_modules
+def get_targets():
+       target_modules = {}
+       for x in find_target_modules():
+               target_modules[x] = catalyst.util.load_module("catalyst.target." + x)
+               if target_modules[x] is None:
+                       msg("Cannot import catalyst.target." + x + ". This usually only " + \
+                               "happens due to a syntax error, which should be reported as " \
+                               "a bug.")
+       return target_modules
 
 def build_target_map():
        target_map = {}
-       targets_obj = targets()
-       target_modules = targets_obj.get_targets()
-       for x in target_modules:
-               if hasattr(target_modules[x], '__target_map'):
-                       target_map.update(target_modules[x].__target_map)
+       targets = get_targets()
+       for x in targets:
+               if hasattr(targets[x], '__target_map'):
+                       target_map.update(targets[x].__target_map)
        return target_map
index e6744a292fa58d672868c9781cdae9505df055a5..f4865127d09fceff9442ed604227bf92ae5f32cd 100644 (file)
@@ -52,14 +52,13 @@ class generic_stage_target(generic_target):
                self.subarchmap = {}
                machinemap = {}
 
-               arches = catalyst.arch.arches()
-               arch_modules = arches.get_arches()
-               for x in arches.get_arches():
-                       self.subarchmap.update(arch_modules[x].__subarch_map)
-                       for machine in arch_modules[x].__machine_map:
-                               machinemap[machine] = arch_modules[x]
-                       for subarch in arch_modules[x].__subarch_map:
-                               machinemap[subarch] = arch_modules[x]
+               arches = catalyst.arch.get_arches()
+               for x in arches:
+                       self.subarchmap.update(arches[x].__subarch_map)
+                       for machine in arches[x].__machine_map:
+                               machinemap[machine] = arches[x]
+                       for subarch in arches[x].__subarch_map:
+                               machinemap[subarch] = arches[x]
 
                if "chost" in self.settings:
                        hostmachine = self.settings["chost"].split("-")[0]