Parse the filename for find the cpu name
[bertos.git] / wizard / bertos_utils.py
index e5a21d9b4989fa898ee518f9e55d936d88df9b66..0f0dc709bcd5e4041509fedd0a7d8a258479769b 100644 (file)
@@ -24,10 +24,20 @@ 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):
-                definitions[filename] = element[0]
-    return definitions
\ No newline at end of file
+                yield (filename, element[0])
+
+def loadCpuInfos(path):
+    cpuInfos = []
+    for definition in findDefinitions("cdef", path):
+        D = {}
+        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