I have a sublime text plugin that watches for the creation of files beginning with lp_
When a file with lp_ prefix is created the plugin creates a folder of the same name with an images folder within.
I would like to watch different areas of my site and create the relevant folder within the nearest lp folder to the created file.
For example I have the following folder strucure
Root > desktop > Root > desktop > lp
Root > Mobile > Root > Mobile > lp
Root > Tablet > Root > Tablet > lp
When a file with lp_ prefix is created in either 'device' folder I would like folder to be created within the nearest lp folder.
The plugin below is along the right lines but I am unsure as how to set rules for targeting specific folders.
import sublime, sublime_plugin, os
# We extend event listener
class ExampleCommand(sublime_plugin.EventListener):
# This method is called every time a file is saved (not only the first time is saved)
def on_post_save_async(self, view):
variables = view.window().extract_variables()
fileBaseName = variables['file_base_name'] # File name without extension
path = '/Users/jameshusband/Dropbox/development/remote/http://ift.tt/1P3thlB' + fileBaseName
imagepath = path + '/images/'
if fileBaseName.startswith('lp_') and not os.path.exists(path):
os.mkdir(path)
os.mkdir(imagepath)
Could anyone point me in the right direction for this? I am not very experienced with Python so am unsure of the best way to achieve my goal.
Aucun commentaire:
Enregistrer un commentaire