Created
October 14, 2013 10:26
-
-
Save ismaild/6973692 to your computer and use it in GitHub Desktop.
Create sublime projects from a root directory with all your code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Create sublime projects from a root directory with all your code | |
Sublime projects are just JSON files, describing the project | |
''' | |
import os | |
SUBLIME_PROJECT_DIR = 'sublime_projects' | |
SUBLIME_PROJECT_EXT = '.sublime-project' | |
pwd = os.path.dirname(os.path.realpath(__file__)) | |
sublime_projects_path = os.path.join(pwd, SUBLIME_PROJECT_DIR, '*' + SUBLIME_PROJECT_EXT) | |
def directory_list(path): | |
return [ | |
directory for directory in os.listdir(path) if directory[0] != '.' and os.path.isdir(directory) | |
] | |
def sublime_project_contents(directory): | |
return '''{ | |
"folders": | |
[ | |
{ | |
"path": "%s" | |
} | |
] | |
}''' % ('../' + directory) | |
def create_sublime_project(directory): | |
project_file_path = os.path.join(pwd, SUBLIME_PROJECT_DIR, directory + SUBLIME_PROJECT_EXT) | |
if not os.path.exists(project_file_path): | |
project_file = open(project_file_path, 'w') | |
project_file.write(sublime_project_contents(directory)) | |
project_file.close() | |
def main(): | |
for directory in directory_list(pwd): | |
create_sublime_project(directory) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment