Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
Description
It would be very nice to have functionality for importing an existing Python project into Qt Creator. I guess it is really about generating the .pyproject file. For now I'm using the following Python script to generate it, where I can specify which file types to include:
import os #Which file types to add to the project file file_types = (".py", ".xml", ".dtd", ".sh") #Open a project file and write the needed start of the project file syntax projectFileName = "MyProject.pyproject" f = open(projectFileName, "w") f.write("{\n\t\"files\": [") #Walk recursively through the folder structure and write all files #with the given file types into the project file. nFiles = 0 for dirpath, dirnames, files in os.walk('.'): for file_name in files: if (file_name.endswith(file_types)): if (len(dirpath) == 1): f.write("\"" + file_name + "\",") #Root folder else: f.write("\"" + dirpath[2:] + "/" + file_name + "\",") #Need relative path down in the folder tree nFiles += 1 #Remove trailing comma after the last file name f.seek(-1, os.SEEK_END) f.truncate() #Write ending syntax and close the project file f.write("]\n}") f.close() print "Created and added " + str(nFiles) + " files to the project file: " + projectFileName + "."