Home Download Buy Blog Forum Support

Create files from sublime plugin

Create files from sublime plugin

Postby NightWolf007 on Sat Apr 06, 2013 6:10 pm

I can't understand why this easy plugin don't work (don't create file).
Code: Select all
class ExampleCommand(sublime_plugin.TextCommand):
   def run(self, edit):
      f = open("my.sublime-snippet", "w")
      f.write("Hello world")
      f.close()

But after any changes it works correctly.
Can anyone help me to understand this?
NightWolf007
 
Posts: 3
Joined: Sat Apr 06, 2013 5:59 pm

Re: Create files from sublime plugin

Postby skuroda on Sat Apr 06, 2013 9:32 pm

Are you sure it didn't just create the file somewhere you weren't expecting?
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Create files from sublime plugin

Postby NightWolf007 on Sat Apr 06, 2013 9:35 pm

Oh, sorry, I found it in \System32, but why? I thinks that it must appeare in folder with plugin. I tried to change this plugin and resave it and after that it works. But after restarting sublime text it doesn't work again.
P.S. And sorry for my bad english.
NightWolf007
 
Posts: 3
Joined: Sat Apr 06, 2013 5:59 pm

Re: Create files from sublime plugin

Postby skuroda on Sat Apr 06, 2013 11:36 pm

Probably has to do with how/where the plugin is being executed from. Why not give the full path so you know exactly where it is being created. For example, you can use sublime.packages_path() to get the packages directory. You can then append the package name and the snippet, which are things you are defining.
Last edited by skuroda on Sat Apr 06, 2013 11:56 pm, edited 1 time in total.
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Create files from sublime plugin

Postby NightWolf007 on Sat Apr 06, 2013 11:43 pm

Ok. Thank you for help.
NightWolf007
 
Posts: 3
Joined: Sat Apr 06, 2013 5:59 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests