Create the wizard plugins infrastructure
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 2 Apr 2009 12:55:32 +0000 (12:55 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 2 Apr 2009 12:55:32 +0000 (12:55 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2467 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py
wizard/codelite_project.py [deleted file]
wizard/plugins/__init__.py [new file with mode: 0644]
wizard/plugins/codelite_project.py [new file with mode: 0644]

index dd876c283f09809542fa664ea05cb0df0d2d0f08..1b8715ffe9efe6ac04107eac51e872c5b9526524 100644 (file)
@@ -17,7 +17,7 @@ import shutil
 import pickle
 
 import const
-import codelite_project
+from plugins import codelite_project
 import DefineException
 
 def isBertosDir(directory):
@@ -77,10 +77,7 @@ def createBertosProject(project_info):
     open(prjdir + "/main.c", "w").write(main)
     ## Codelite project files
     if "codelite" in project_info.info("OUTPUT"):
-        workspace = codelite_project.codeliteWorkspaceGenerator(project_info)
-        open(directory + "/" + os.path.basename(prjdir) + ".workspace", "w").write(workspace)
-        project = codelite_project.codeliteProjectGenerator(project_info)
-        open(directory + "/" + os.path.basename(prjdir) + ".project", "w").write(project)
+        codelite_project.createProject(project_info)
 
 def mkGenerator(project_info, makefile):
     """
diff --git a/wizard/codelite_project.py b/wizard/codelite_project.py
deleted file mode 100644 (file)
index a8739d0..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-# encoding: utf-8
-#
-# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# $Id:$
-#
-# Author: Lorenzo Berni <duplo@develer.com>
-#
-
-import os
-
-import const
-
-def clFiles(file_dict, directory):
-    """
-    Creates the list of the lines for the files founded in file_dict, using
-    directory as the base folder.
-    """
-    filelist = []
-    filelist.append("<VirtualDirectory Name=\"%s\">" %os.path.basename(directory))
-    for f in file_dict[directory]["files"]:
-        filelist.append("<File Name=\"%s\"/>" %os.path.join(directory, f))
-    for d in file_dict[directory]["dirs"]:
-        filelist += clFiles(file_dict, os.path.join(directory, d))
-    filelist.append("</VirtualDirectory>")
-    return filelist
-
-def findSources(path):
-    """
-    Analyzes the directory tree from path and return a dict with filename and
-    path.
-    """
-    file_dict = {}
-    for root, dirs, files in os.walk(path):
-        if root.find("svn") == -1:
-            file_dict[root] = {"dirs": [], "files": []}
-            for dir in dirs:
-                if dir.find("svn") == -1:
-                    file_dict[root]["dirs"].append(dir)
-            for file in files:
-                if file.endswith(const.EXTENSION_FILTER):
-                    file_dict[root]["files"].append(file)
-    return file_dict
-
-def codeliteProjectGenerator(project_info):
-    """
-    Returns the string rapresenting the codelite project.
-    """
-    template = open("cltemplates/bertos.project").read()
-    filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), project_info.info("PROJECT_PATH")))
-    while template.find("$filelist") != -1:
-        template = template.replace("$filelist", filelist)
-    project_name = os.path.basename(project_info.info("PROJECT_PATH"))
-    while template.find("$project") != -1:
-        template = template.replace("$project", project_name)
-    return template
-
-def codeliteWorkspaceGenerator(project_info):
-    """
-    Returns the string rapresentig the codelite workspace.
-    """
-    template = open("cltemplates/bertos.workspace").read()
-    project_name = os.path.basename(project_info.info("PROJECT_PATH"))
-    while template.find("$project") != -1:
-        template = template.replace("$project", project_name)
-    return template
diff --git a/wizard/plugins/__init__.py b/wizard/plugins/__init__.py
new file mode 100644 (file)
index 0000000..0174745
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
\ No newline at end of file
diff --git a/wizard/plugins/codelite_project.py b/wizard/plugins/codelite_project.py
new file mode 100644 (file)
index 0000000..c55c7dc
--- /dev/null
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+import os
+
+import const
+
+def clFiles(file_dict, directory):
+    """
+    Creates the list of the lines for the files founded in file_dict, using
+    directory as the base folder.
+    """
+    filelist = []
+    filelist.append("<VirtualDirectory Name=\"%s\">" %os.path.basename(directory))
+    for f in file_dict[directory]["files"]:
+        filelist.append("<File Name=\"%s\"/>" %os.path.join(directory, f))
+    for d in file_dict[directory]["dirs"]:
+        filelist += clFiles(file_dict, os.path.join(directory, d))
+    filelist.append("</VirtualDirectory>")
+    return filelist
+
+def findSources(path):
+    """
+    Analyzes the directory tree from path and return a dict with filename and
+    path.
+    """
+    file_dict = {}
+    for root, dirs, files in os.walk(path):
+        if root.find("svn") == -1:
+            file_dict[root] = {"dirs": [], "files": []}
+            for dir in dirs:
+                if dir.find("svn") == -1:
+                    file_dict[root]["dirs"].append(dir)
+            for file in files:
+                if file.endswith(const.EXTENSION_FILTER):
+                    file_dict[root]["files"].append(file)
+    return file_dict
+
+def codeliteProjectGenerator(project_info):
+    """
+    Returns the string rapresenting the codelite project.
+    """
+    template = open("cltemplates/bertos.project").read()
+    filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), project_info.info("PROJECT_PATH")))
+    while template.find("$filelist") != -1:
+        template = template.replace("$filelist", filelist)
+    project_name = os.path.basename(project_info.info("PROJECT_PATH"))
+    while template.find("$project") != -1:
+        template = template.replace("$project", project_name)
+    return template
+
+def codeliteWorkspaceGenerator(project_info):
+    """
+    Returns the string rapresentig the codelite workspace.
+    """
+    template = open("cltemplates/bertos.workspace").read()
+    project_name = os.path.basename(project_info.info("PROJECT_PATH"))
+    while template.find("$project") != -1:
+        template = template.replace("$project", project_name)
+    return template
+
+def createProject(project_info):
+    """
+    Function that creates codelite projects.
+    """
+    directory = project_info.info("PROJECT_PATH")
+    prjdir = directory + "/" + os.path.basename(directory)
+    workspace = codeliteWorkspaceGenerator(project_info)
+    open(directory + "/" + os.path.basename(prjdir) + ".workspace", "w").write(workspace)
+    project = codeliteProjectGenerator(project_info)
+    open(directory + "/" + os.path.basename(prjdir) + ".project", "w").write(project)