Add the const string containing the pattern of the cpu definition filenames
[bertos.git] / wizard / bertos_utils.py
index d09b889ce0c80aa372b6f2f34593853c9d0075e2..99bdca23f7b248463f1dcd42452795736b4f1871 100644 (file)
@@ -12,6 +12,8 @@
 import os
 import fnmatch
 
+import const
+
 def isBertosDir(directory):
    return os.path.exists(directory + "/VERSION")
 
@@ -24,10 +26,21 @@ def createBertosProject(directory):
     open(directory + "/project.bertos", "w")
 
 def findDefinitions(ftype, path):
-    l = os.walk(path)
-    definitions = {}
-    for element in l:
+    L = os.walk(path)
+    for element in L:
         for filename in element[2]:
-            if fnmatch.fnmatch(filename, "*." + ftype):
-                defintions[filename] = element[0]
-    return definitions
\ No newline at end of file
+            if fnmatch.fnmatch(filename, ftype):
+                yield (filename, element[0])
+
+def loadCpuInfos(path):
+    cpuInfos = []
+    for definition in findDefinitions(const.CPU_DEFINITION, path):
+        D = {}
+        D.update(const.CPU_DEF)
+        def include(filename, dict = D, directory=definition[1]):
+            execfile(directory + "/" + filename, {}, D)
+        D["include"] = include
+        include(definition[0], D)
+        D["CPU_NAME"] = definition[0].split(".")[0]
+        cpuInfos.append(D)
+    return cpuInfos