Move target module loading logic into build_target_map() in catalyst.target module
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 01:54:36 +0000 (19:54 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 01:54:36 +0000 (19:54 -0600)
ChangeLog
catalyst
modules/catalyst/target/__init__.py
modules/catalyst/target/generic_stage_target.py

index 758c6a1b0d3b37c7ff1c6822f2e8ee79e555468b..d8e2325e771fdf12d5d9a96fba4e4d9e377f956a 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> catalyst,
+  modules/catalyst/target/__init__.py,
+  modules/catalyst/target/generic_stage_target.py:
+  Move target module loading logic into build_target_map() in
+  catalyst.target module
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org> catalyst,
   modules/catalyst/target/embedded_target.py,
   modules/catalyst/target/grp_target.py,
index 4de6fe48609258497fb4405fbaf428f6f827e856..e050987ed0250c8334094a742ba559dc5378d171 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -167,12 +167,9 @@ def parse_config(myconfig):
 
 def import_modules():
        # import catalyst's own modules (i.e. catalyst_support and the arch modules)
-       targetmap={}
-
-       targets = catalyst.target.targets()
-       for x in targets.get_targets():
-               targetmap.update(x.__target_map)
+       import catalyst.target
 
+       targetmap = catalyst.target.build_target_map()
        return targetmap
 
 def build_target(addlargs, targetmap):
@@ -287,7 +284,7 @@ if __name__ == "__main__":
 
        # import configuration file and import our main module using those settings
        parse_config(myconfig)
-       sys.path.append(conf_values["sharedir"]+"/modules")
+
        from catalyst_support import *
        
        # Start checking that digests are valid now that the hash_map was imported from catalyst_support
index 99e1a7fb55f4b20d2f2db5734a7ff58beb42f9a0..8a90e2ddaaf632ceddf412a584196fa068675b56 100644 (file)
@@ -28,3 +28,12 @@ class targets:
                                        "happens due to a syntax error, which should be reported as " \
                                        "a bug.")
                return self._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)
+       return target_map
index 8cbed1ba38edf8cfab04e60b7e1e31f0e0430a06..76ce57d930f91ff6d0a7c0369fda92e2c87a80cd 100644 (file)
@@ -49,17 +49,17 @@ class generic_stage_target(generic_target):
                previously. -agaffney
                """
 
-               self.archmap = {}
                self.subarchmap = {}
                machinemap = {}
+
                arches = catalyst.arch.arches()
+               arch_modules = arches.get_arches()
                for x in arches.get_arches():
-                       tmpsubarchmap, tmpmachinemap = self.archmap[x].register()
-                       self.subarchmap.update(x.__subarch_map)
-                       for machine in x.__machine_map:
-                               machinemap[machine] = x
-                       for subarch in x.__subarch_map:
-                               machinemap[subarch] = x
+                       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]
 
                if self.settings.has_key("chost"):
                        hostmachine = self.settings["chost"].split("-")[0]