From: Andrew Gaffney Date: Sun, 11 Jan 2009 17:44:13 +0000 (-0600) Subject: Get rid of arches and targets classes and move functions into the module instead X-Git-Tag: CATALYST-2.0.10~3^2~212 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9ee68c6c17f3171f01f33cb50086bb08f16982a9;p=catalyst.git Get rid of arches and targets classes and move functions into the module instead --- diff --git a/ChangeLog b/ChangeLog index a50829db..2271a72a 100644 --- 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 + 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 targets/embedded/embedded-chroot.sh, targets/embedded/embedded-controller.sh, targets/grp/grp-controller.sh, diff --git a/modules/catalyst/arch/__init__.py b/modules/catalyst/arch/__init__.py index f421e60b..1e6fa109 100644 --- a/modules/catalyst/arch/__init__.py +++ b/modules/catalyst/arch/__init__.py @@ -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: diff --git a/modules/catalyst/target/__init__.py b/modules/catalyst/target/__init__.py index a482efa7..7f8602b4 100644 --- a/modules/catalyst/target/__init__.py +++ b/modules/catalyst/target/__init__.py @@ -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 diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index e6744a29..f4865127 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -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]