From: Andrew Gaffney Date: Sun, 11 Jan 2009 00:36:09 +0000 (-0600) Subject: add .gitignore file with *.py[co] X-Git-Tag: CATALYST-2.0.10~3^2~242 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3c9b5477e56aa74c6e67baaddf80554759c4c599;p=catalyst.git add .gitignore file with *.py[co] --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..539da741 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.py[co] diff --git a/ChangeLog b/ChangeLog index 1b535cac..ab2b6660 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,18 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney -arch/alpha.py, + -arch/amd64.py, -arch/arm.py, -arch/hppa.py, -arch/ia64.py, -arch/mips.py, + -arch/powerpc.py, -arch/s390.py, -arch/sh.py, -arch/sparc.py, + -arch/x86.py, +modules/catalyst/arch/__init__.py, + +modules/catalyst/arch/alpha.py, +modules/catalyst/arch/amd64.py, + +modules/catalyst/arch/arm.py, +modules/catalyst/arch/hppa.py, + +modules/catalyst/arch/ia64.py, +modules/catalyst/arch/mips.py, + +modules/catalyst/arch/powerpc.py, +modules/catalyst/arch/s390.py, + +modules/catalyst/arch/sh.py, +modules/catalyst/arch/sparc.py, + +modules/catalyst/arch/x86.py, modules/catalyst/util.py, +.gitignore: + --help + 10 Jan 2009; Andrew Gaffney catalyst: Change __version__ to 2.99 for catalyst_3 branch diff --git a/modules/catalyst/arch/__init__.py b/modules/catalyst/arch/__init__.py new file mode 100644 index 00000000..e4de205d --- /dev/null +++ b/modules/catalyst/arch/__init__.py @@ -0,0 +1,50 @@ +""" +Parent module of all arch modules +""" + +import os +import imp +import catalyst.util + +# This hard-coded list of arch is here until I find a good way to get a list of +# other modules contained in the same dir as this file +__arch_module_list = ( + "alpha", + "amd64", + "arm", + "hppa", + "ia64", + "mips", + "powerpc", + "s390", + "sh", + "sparc", + "x86" +) + +class arches: + + __arch_modules = None + + 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')] + return arch_module_list + + def get_arches(self): + self.archmap = {} + self.subarchmap = {} + machinemap = {} + # We don't know if this works yet +# for x in self.find_arch_modules(): + for x in __arch_module_list: + 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.") + diff --git a/arch/alpha.py b/modules/catalyst/arch/alpha.py similarity index 100% rename from arch/alpha.py rename to modules/catalyst/arch/alpha.py diff --git a/arch/amd64.py b/modules/catalyst/arch/amd64.py similarity index 100% rename from arch/amd64.py rename to modules/catalyst/arch/amd64.py diff --git a/arch/arm.py b/modules/catalyst/arch/arm.py similarity index 100% rename from arch/arm.py rename to modules/catalyst/arch/arm.py diff --git a/arch/hppa.py b/modules/catalyst/arch/hppa.py similarity index 100% rename from arch/hppa.py rename to modules/catalyst/arch/hppa.py diff --git a/arch/ia64.py b/modules/catalyst/arch/ia64.py similarity index 100% rename from arch/ia64.py rename to modules/catalyst/arch/ia64.py diff --git a/arch/mips.py b/modules/catalyst/arch/mips.py similarity index 100% rename from arch/mips.py rename to modules/catalyst/arch/mips.py diff --git a/arch/powerpc.py b/modules/catalyst/arch/powerpc.py similarity index 100% rename from arch/powerpc.py rename to modules/catalyst/arch/powerpc.py diff --git a/arch/s390.py b/modules/catalyst/arch/s390.py similarity index 100% rename from arch/s390.py rename to modules/catalyst/arch/s390.py diff --git a/arch/sh.py b/modules/catalyst/arch/sh.py similarity index 100% rename from arch/sh.py rename to modules/catalyst/arch/sh.py diff --git a/arch/sparc.py b/modules/catalyst/arch/sparc.py similarity index 100% rename from arch/sparc.py rename to modules/catalyst/arch/sparc.py diff --git a/arch/x86.py b/modules/catalyst/arch/x86.py similarity index 100% rename from arch/x86.py rename to modules/catalyst/arch/x86.py diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index ff12086d..63955824 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -12,3 +12,10 @@ def capture_traceback(): def print_traceback(): for x in capture_traceback(): print x + +def load_module(name): + try: + exec("import " + name) + return sys.modules[name] + except Exception: + return None