add .gitignore file with *.py[co]
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 00:36:09 +0000 (18:36 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 00:36:48 +0000 (18:36 -0600)
15 files changed:
.gitignore [new file with mode: 0644]
ChangeLog
modules/catalyst/arch/__init__.py [new file with mode: 0644]
modules/catalyst/arch/alpha.py [moved from arch/alpha.py with 100% similarity]
modules/catalyst/arch/amd64.py [moved from arch/amd64.py with 100% similarity]
modules/catalyst/arch/arm.py [moved from arch/arm.py with 100% similarity]
modules/catalyst/arch/hppa.py [moved from arch/hppa.py with 100% similarity]
modules/catalyst/arch/ia64.py [moved from arch/ia64.py with 100% similarity]
modules/catalyst/arch/mips.py [moved from arch/mips.py with 100% similarity]
modules/catalyst/arch/powerpc.py [moved from arch/powerpc.py with 100% similarity]
modules/catalyst/arch/s390.py [moved from arch/s390.py with 100% similarity]
modules/catalyst/arch/sh.py [moved from arch/sh.py with 100% similarity]
modules/catalyst/arch/sparc.py [moved from arch/sparc.py with 100% similarity]
modules/catalyst/arch/x86.py [moved from arch/x86.py with 100% similarity]
modules/catalyst/util.py

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..539da74
--- /dev/null
@@ -0,0 +1 @@
+*.py[co]
index 1b535cacc3cbcfb6806d47153f59435cd705a8cf..ab2b66605b6fd6908b16788d16d55b4e7208b95f 100644 (file)
--- 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 <agaffney@gentoo.org> -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 <agaffney@gentoo.org> 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 (file)
index 0000000..e4de205
--- /dev/null
@@ -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.")
+
similarity index 100%
rename from arch/alpha.py
rename to modules/catalyst/arch/alpha.py
similarity index 100%
rename from arch/amd64.py
rename to modules/catalyst/arch/amd64.py
similarity index 100%
rename from arch/arm.py
rename to modules/catalyst/arch/arm.py
similarity index 100%
rename from arch/hppa.py
rename to modules/catalyst/arch/hppa.py
similarity index 100%
rename from arch/ia64.py
rename to modules/catalyst/arch/ia64.py
similarity index 100%
rename from arch/mips.py
rename to modules/catalyst/arch/mips.py
similarity index 100%
rename from arch/s390.py
rename to modules/catalyst/arch/s390.py
similarity index 100%
rename from arch/sh.py
rename to modules/catalyst/arch/sh.py
similarity index 100%
rename from arch/sparc.py
rename to modules/catalyst/arch/sparc.py
similarity index 100%
rename from arch/x86.py
rename to modules/catalyst/arch/x86.py
index ff12086dbe38854a22a4195c692738c9ec34b138..639558246b6554e94931e6ca0df48b8f2ae12884 100644 (file)
@@ -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