createProjects.py and dot(hidden) files

Hi all,

I was just trying out the new createProjects.py script and it wasn’t working for me since I’m using subversion :-\

The script copies everything from certain directories so it includes hidden files. I made a quick fix for myself to work around it. I just filter out all entries starting with a ‘.’ from the results of os.listdir. Here’s a diff from my current OF pull.

Rg,

Arnaud

  
diff --git a/scripts/linux/createProjects.py b/scripts/linux/createProjects.py  
index 2251dc4..d77b535 100755  
--- a/scripts/linux/createProjects.py  
+++ b/scripts/linux/createProjects.py  
@@ -86,7 +86,7 @@ def addAddon(project,addon):  
     if fullCBP:  
         if not os.path.exists(os.path.join(of_root,'addons',addon,'libs')):  
             return  
-        for libdir in os.listdir(os.path.join(of_root,'addons',addon,'libs')):  
+        for libdir in filter(nodot, os.listdir(os.path.join(of_root,'addons',ad  
             if not os.path.isdir(os.path.join(of_root,'addons',addon,'libs',lib  
                 continue  
             basefolder = os.path.join('addons',addon,'libs',libdir);  
@@ -194,7 +194,7 @@ def createProject(project_path):  
   
     if not os.path.exists(os.path.join(project_path,'src')):  
         os.mkdir(os.path.join(project_path , 'src'))  
-        for file in os.listdir(os.path.join(templates_path , 'src')):  
+        for file in filter(nodot, os.listdir(os.path.join(templates_path , 'src  
             shutil.copyfile(os.path.join(templates_path , 'src' , file), os.pat  
   
     if not os.path.exists(os.path.join(project_path , 'bin')):  
@@ -207,6 +207,9 @@ def createProject(project_path):  
     createWorkspace(project_path)  
   
   
+def nodot(item):   
+    return item[0] != '.'  
+  
   
 parser = argparse.ArgumentParser(description='OF linux project generator')  
 parser.add_argument('project_path', metavar='project_path', nargs='?')  
@@ -217,9 +220,10 @@ project_path = parser.parse_args().project_path  
 fullCBP = parser.parse_args().not_mk  
   
 if project_path==None: #parse all examples  
-    for example in os.listdir(os.path.join(of_root,'apps','examples')):  
+    for example in filter(nodot, os.listdir(os.path.join(of_root,'apps','exampl  
+        print example  
         createProject(os.path.join(of_root,'apps','examples',example))  
-    for example in os.listdir(os.path.join(of_root,'apps','addonsExamples')):  
+    for example in filter(nodot, os.listdir(os.path.join(of_root,'apps','addons  
         createProject(os.path.join(of_root,'apps','addonsExamples',example))  
 else:  
     createProject(project_path)  

it seems like some lines are incomplete in your patch

See how this goes ::slight_smile:

  
----------------------- scripts/linux/createProjects.py -----------------------  
index 2251dc4..d77b535 100755  
@@ -86,7 +86,7 @@ def addAddon(project,addon):  
     if fullCBP:  
         if not os.path.exists(os.path.join(of_root,'addons',addon,'libs')):  
             return  
-        for libdir in os.listdir(os.path.join(of_root,'addons',addon,'libs')):  
+        for libdir in filter(nodot, os.listdir(os.path.join(of_root,'addons',addon,'libs'))):  
             if not os.path.isdir(os.path.join(of_root,'addons',addon,'libs',libdir)):  
                 continue  
             basefolder = os.path.join('addons',addon,'libs',libdir);  
@@ -194,7 +194,7 @@ def createProject(project_path):  
   
     if not os.path.exists(os.path.join(project_path,'src')):  
         os.mkdir(os.path.join(project_path , 'src'))  
-        for file in os.listdir(os.path.join(templates_path , 'src')):  
+        for file in filter(nodot, os.listdir(os.path.join(templates_path , 'src'))):  
             shutil.copyfile(os.path.join(templates_path , 'src' , file), os.path.join(project_path , 'src' , file))  
   
     if not os.path.exists(os.path.join(project_path , 'bin')):  
@@ -207,6 +207,9 @@ def createProject(project_path):  
     createWorkspace(project_path)  
   
   
+def nodot(item):   
+    return item[0] != '.'  
+  
   
 parser = argparse.ArgumentParser(description='OF linux project generator')  
 parser.add_argument('project_path', metavar='project_path', nargs='?')  
@@ -217,9 +220,10 @@ project_path = parser.parse_args().project_path  
 fullCBP = parser.parse_args().not_mk  
   
 if project_path==None: #parse all examples  
-    for example in os.listdir(os.path.join(of_root,'apps','examples')):  
+    for example in filter(nodot, os.listdir(os.path.join(of_root,'apps','examples'))):  
+        print example  
         createProject(os.path.join(of_root,'apps','examples',example))  
-    for example in os.listdir(os.path.join(of_root,'apps','addonsExamples')):  
+    for example in filter(nodot, os.listdir(os.path.join(of_root,'apps','addonsExamples'))):  
         createProject(os.path.join(of_root,'apps','addonsExamples',example))  
 else:  
     createProject(project_path)