4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
16 def clFiles(file_dict, directory):
18 Creates the list of the lines for the files founded in file_dict, using
19 directory as the base folder.
22 filelist.append("<VirtualDirectory Name=\"%s\">" %os.path.basename(directory))
23 for f in file_dict[directory]["files"]:
24 filelist.append("<File Name=\"%s\"/>" %os.path.join(directory, f))
25 for d in file_dict[directory]["dirs"]:
26 filelist += clFiles(file_dict, os.path.join(directory, d))
27 filelist.append("</VirtualDirectory>")
30 def findSources(path):
32 Analyzes the directory tree from path and return a dict with filename and
36 for root, dirs, files in os.walk(path):
37 if root.find("svn") == -1:
38 file_dict[root] = {"dirs": [], "files": []}
40 if dir.find("svn") == -1:
41 file_dict[root]["dirs"].append(dir)
43 if file.endswith(const.EXTENSION_FILTER):
44 file_dict[root]["files"].append(file)
47 def codeliteProjectGenerator(project_info):
49 Returns the string rapresenting the codelite project.
51 template = open("cltemplates/bertos.project").read()
52 filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), project_info.info("PROJECT_PATH")))
53 while template.find("$filelist") != -1:
54 template = template.replace("$filelist", filelist)
55 project_name = os.path.basename(project_info.info("PROJECT_PATH"))
56 while template.find("$project") != -1:
57 template = template.replace("$project", project_name)
60 def codeliteWorkspaceGenerator(project_info):
62 Returns the string rapresentig the codelite workspace.
64 template = open("cltemplates/bertos.workspace").read()
65 project_name = os.path.basename(project_info.info("PROJECT_PATH"))
66 while template.find("$project") != -1:
67 template = template.replace("$project", project_name)